Lines Matching full:st
78 struct ad7887_state *st = iio_priv(indio_dev); in ad7887_ring_preenable() local
83 st->ring_msg = &st->msg[AD7887_CH0]; in ad7887_ring_preenable()
86 st->ring_msg = &st->msg[AD7887_CH1]; in ad7887_ring_preenable()
88 spi_sync(st->spi, st->ring_msg); in ad7887_ring_preenable()
91 st->ring_msg = &st->msg[AD7887_CH0_CH1]; in ad7887_ring_preenable()
100 struct ad7887_state *st = iio_priv(indio_dev); in ad7887_ring_postdisable() local
103 return spi_sync(st->spi, &st->msg[AD7887_CH0]); in ad7887_ring_postdisable()
116 struct ad7887_state *st = iio_priv(indio_dev); in ad7887_trigger_handler() local
119 b_sent = spi_sync(st->spi, st->ring_msg); in ad7887_trigger_handler()
123 iio_push_to_buffers_with_timestamp(indio_dev, st->data, in ad7887_trigger_handler()
138 static int ad7887_scan_direct(struct ad7887_state *st, unsigned ch) in ad7887_scan_direct() argument
140 int ret = spi_sync(st->spi, &st->msg[ch]); in ad7887_scan_direct()
144 return (st->data[(ch * 2)] << 8) | st->data[(ch * 2) + 1]; in ad7887_scan_direct()
154 struct ad7887_state *st = iio_priv(indio_dev); in ad7887_read_raw() local
161 ret = ad7887_scan_direct(st, chan->address); in ad7887_read_raw()
170 if (st->reg) { in ad7887_read_raw()
171 *val = regulator_get_voltage(st->reg); in ad7887_read_raw()
176 *val = st->chip_info->int_vref_mv; in ad7887_read_raw()
236 struct ad7887_state *st; in ad7887_probe() local
241 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ad7887_probe()
245 st = iio_priv(indio_dev); in ad7887_probe()
248 st->reg = devm_regulator_get(&spi->dev, "vref"); in ad7887_probe()
249 if (IS_ERR(st->reg)) in ad7887_probe()
250 return PTR_ERR(st->reg); in ad7887_probe()
252 ret = regulator_enable(st->reg); in ad7887_probe()
257 st->chip_info = in ad7887_probe()
261 st->spi = spi; in ad7887_probe()
278 st->tx_cmd_buf[0] = AD7887_CH_AIN0 | mode; in ad7887_probe()
280 st->xfer[0].rx_buf = &st->data[0]; in ad7887_probe()
281 st->xfer[0].tx_buf = &st->tx_cmd_buf[0]; in ad7887_probe()
282 st->xfer[0].len = 2; in ad7887_probe()
284 spi_message_init(&st->msg[AD7887_CH0]); in ad7887_probe()
285 spi_message_add_tail(&st->xfer[0], &st->msg[AD7887_CH0]); in ad7887_probe()
288 st->tx_cmd_buf[2] = AD7887_CH_AIN1 | mode; in ad7887_probe()
290 st->xfer[1].rx_buf = &st->data[0]; in ad7887_probe()
291 st->xfer[1].tx_buf = &st->tx_cmd_buf[2]; in ad7887_probe()
292 st->xfer[1].len = 2; in ad7887_probe()
294 st->xfer[2].rx_buf = &st->data[2]; in ad7887_probe()
295 st->xfer[2].tx_buf = &st->tx_cmd_buf[0]; in ad7887_probe()
296 st->xfer[2].len = 2; in ad7887_probe()
298 spi_message_init(&st->msg[AD7887_CH0_CH1]); in ad7887_probe()
299 spi_message_add_tail(&st->xfer[1], &st->msg[AD7887_CH0_CH1]); in ad7887_probe()
300 spi_message_add_tail(&st->xfer[2], &st->msg[AD7887_CH0_CH1]); in ad7887_probe()
302 st->xfer[3].rx_buf = &st->data[2]; in ad7887_probe()
303 st->xfer[3].tx_buf = &st->tx_cmd_buf[2]; in ad7887_probe()
304 st->xfer[3].len = 2; in ad7887_probe()
306 spi_message_init(&st->msg[AD7887_CH1]); in ad7887_probe()
307 spi_message_add_tail(&st->xfer[3], &st->msg[AD7887_CH1]); in ad7887_probe()
309 indio_dev->channels = st->chip_info->channel; in ad7887_probe()
312 indio_dev->channels = &st->chip_info->channel[1]; in ad7887_probe()
329 if (st->reg) in ad7887_probe()
330 regulator_disable(st->reg); in ad7887_probe()
338 struct ad7887_state *st = iio_priv(indio_dev); in ad7887_remove() local
342 if (st->reg) in ad7887_remove()
343 regulator_disable(st->reg); in ad7887_remove()