Lines Matching full:st
84 struct ad7887_state *st = iio_priv(indio_dev); in ad7887_ring_preenable() local
89 st->ring_msg = &st->msg[AD7887_CH0]; in ad7887_ring_preenable()
92 st->ring_msg = &st->msg[AD7887_CH1]; in ad7887_ring_preenable()
94 spi_sync(st->spi, st->ring_msg); in ad7887_ring_preenable()
97 st->ring_msg = &st->msg[AD7887_CH0_CH1]; in ad7887_ring_preenable()
106 struct ad7887_state *st = iio_priv(indio_dev); in ad7887_ring_postdisable() local
109 return spi_sync(st->spi, &st->msg[AD7887_CH0]); in ad7887_ring_postdisable()
122 struct ad7887_state *st = iio_priv(indio_dev); in ad7887_trigger_handler() local
125 b_sent = spi_sync(st->spi, st->ring_msg); in ad7887_trigger_handler()
129 iio_push_to_buffers_with_timestamp(indio_dev, st->data, in ad7887_trigger_handler()
142 static int ad7887_scan_direct(struct ad7887_state *st, unsigned ch) in ad7887_scan_direct() argument
144 int ret = spi_sync(st->spi, &st->msg[ch]); in ad7887_scan_direct()
148 return (st->data[(ch * 2)] << 8) | st->data[(ch * 2) + 1]; in ad7887_scan_direct()
158 struct ad7887_state *st = iio_priv(indio_dev); in ad7887_read_raw() local
165 ret = ad7887_scan_direct(st, chan->address); in ad7887_read_raw()
174 if (st->reg) { in ad7887_read_raw()
175 *val = regulator_get_voltage(st->reg); in ad7887_read_raw()
180 *val = st->chip_info->int_vref_mv; in ad7887_read_raw()
238 struct ad7887_state *st; in ad7887_probe() local
243 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ad7887_probe()
247 st = iio_priv(indio_dev); in ad7887_probe()
250 st->reg = devm_regulator_get(&spi->dev, "vref"); in ad7887_probe()
251 if (IS_ERR(st->reg)) in ad7887_probe()
252 return PTR_ERR(st->reg); in ad7887_probe()
254 ret = regulator_enable(st->reg); in ad7887_probe()
259 st->chip_info = in ad7887_probe()
263 st->spi = spi; in ad7887_probe()
277 st->tx_cmd_buf[0] = AD7887_CH_AIN0 | mode; in ad7887_probe()
279 st->xfer[0].rx_buf = &st->data[0]; in ad7887_probe()
280 st->xfer[0].tx_buf = &st->tx_cmd_buf[0]; in ad7887_probe()
281 st->xfer[0].len = 2; in ad7887_probe()
283 spi_message_init(&st->msg[AD7887_CH0]); in ad7887_probe()
284 spi_message_add_tail(&st->xfer[0], &st->msg[AD7887_CH0]); in ad7887_probe()
287 st->tx_cmd_buf[2] = AD7887_CH_AIN1 | mode; in ad7887_probe()
289 st->xfer[1].rx_buf = &st->data[0]; in ad7887_probe()
290 st->xfer[1].tx_buf = &st->tx_cmd_buf[2]; in ad7887_probe()
291 st->xfer[1].len = 2; in ad7887_probe()
293 st->xfer[2].rx_buf = &st->data[2]; in ad7887_probe()
294 st->xfer[2].tx_buf = &st->tx_cmd_buf[0]; in ad7887_probe()
295 st->xfer[2].len = 2; in ad7887_probe()
297 spi_message_init(&st->msg[AD7887_CH0_CH1]); in ad7887_probe()
298 spi_message_add_tail(&st->xfer[1], &st->msg[AD7887_CH0_CH1]); in ad7887_probe()
299 spi_message_add_tail(&st->xfer[2], &st->msg[AD7887_CH0_CH1]); in ad7887_probe()
301 st->xfer[3].rx_buf = &st->data[2]; in ad7887_probe()
302 st->xfer[3].tx_buf = &st->tx_cmd_buf[2]; in ad7887_probe()
303 st->xfer[3].len = 2; in ad7887_probe()
305 spi_message_init(&st->msg[AD7887_CH1]); in ad7887_probe()
306 spi_message_add_tail(&st->xfer[3], &st->msg[AD7887_CH1]); in ad7887_probe()
308 indio_dev->channels = st->chip_info->dual_channels; in ad7887_probe()
309 indio_dev->num_channels = st->chip_info->num_dual_channels; in ad7887_probe()
311 indio_dev->channels = st->chip_info->channels; in ad7887_probe()
312 indio_dev->num_channels = st->chip_info->num_channels; in ad7887_probe()
328 if (st->reg) in ad7887_probe()
329 regulator_disable(st->reg); in ad7887_probe()
337 struct ad7887_state *st = iio_priv(indio_dev); in ad7887_remove() local
341 if (st->reg) in ad7887_remove()
342 regulator_disable(st->reg); in ad7887_remove()