Lines Matching refs:st
41 static inline int tle62x0_write(struct tle62x0_state *st) in tle62x0_write() argument
43 unsigned char *buff = st->tx_buff; in tle62x0_write()
44 unsigned int gpio_state = st->gpio_state; in tle62x0_write()
48 if (st->nr_gpio == 16) { in tle62x0_write()
55 dev_dbg(&st->us->dev, "buff %3ph\n", buff); in tle62x0_write()
57 return spi_write(st->us, buff, (st->nr_gpio == 16) ? 3 : 2); in tle62x0_write()
60 static inline int tle62x0_read(struct tle62x0_state *st) in tle62x0_read() argument
62 unsigned char *txbuff = st->tx_buff; in tle62x0_read()
65 .rx_buf = st->rx_buff, in tle62x0_read()
66 .len = (st->nr_gpio * 2) / 8, in tle62x0_read()
78 return spi_sync(st->us, &msg); in tle62x0_read()
102 struct tle62x0_state *st = dev_get_drvdata(dev); in tle62x0_status_show() local
104 unsigned char *buff = st->rx_buff; in tle62x0_status_show()
109 mutex_lock(&st->lock); in tle62x0_status_show()
110 ret = tle62x0_read(st); in tle62x0_status_show()
113 mutex_unlock(&st->lock); in tle62x0_status_show()
117 for (ptr = 0; ptr < (st->nr_gpio * 2)/8; ptr += 1) { in tle62x0_status_show()
124 for (ptr = 0; ptr < st->nr_gpio; ptr++) { in tle62x0_status_show()
130 mutex_unlock(&st->lock); in tle62x0_status_show()
139 struct tle62x0_state *st = dev_get_drvdata(dev); in tle62x0_gpio_show() local
143 mutex_lock(&st->lock); in tle62x0_gpio_show()
144 value = (st->gpio_state >> gpio_num) & 1; in tle62x0_gpio_show()
145 mutex_unlock(&st->lock); in tle62x0_gpio_show()
154 struct tle62x0_state *st = dev_get_drvdata(dev); in tle62x0_gpio_store() local
165 mutex_lock(&st->lock); in tle62x0_gpio_store()
168 st->gpio_state |= 1 << gpio_num; in tle62x0_gpio_store()
170 st->gpio_state &= ~(1 << gpio_num); in tle62x0_gpio_store()
172 tle62x0_write(st); in tle62x0_gpio_store()
173 mutex_unlock(&st->lock); in tle62x0_gpio_store()
244 struct tle62x0_state *st; in tle62x0_probe() local
255 st = kzalloc(sizeof(struct tle62x0_state), GFP_KERNEL); in tle62x0_probe()
256 if (st == NULL) in tle62x0_probe()
259 st->us = spi; in tle62x0_probe()
260 st->nr_gpio = pdata->gpio_count; in tle62x0_probe()
261 st->gpio_state = pdata->init_state; in tle62x0_probe()
263 mutex_init(&st->lock); in tle62x0_probe()
280 spi_set_drvdata(spi, st); in tle62x0_probe()
290 kfree(st); in tle62x0_probe()
296 struct tle62x0_state *st = spi_get_drvdata(spi); in tle62x0_remove() local
299 for (ptr = 0; ptr < st->nr_gpio; ptr++) in tle62x0_remove()
303 kfree(st); in tle62x0_remove()