Lines Matching refs:st

83 	struct ad7887_state *st = iio_priv(indio_dev);  in ad7887_ring_preenable()  local
88 st->ring_msg = &st->msg[AD7887_CH0]; in ad7887_ring_preenable()
91 st->ring_msg = &st->msg[AD7887_CH1]; in ad7887_ring_preenable()
93 spi_sync(st->spi, st->ring_msg); in ad7887_ring_preenable()
96 st->ring_msg = &st->msg[AD7887_CH0_CH1]; in ad7887_ring_preenable()
105 struct ad7887_state *st = iio_priv(indio_dev); in ad7887_ring_postdisable() local
108 return spi_sync(st->spi, &st->msg[AD7887_CH0]); in ad7887_ring_postdisable()
115 struct ad7887_state *st = iio_priv(indio_dev); in ad7887_trigger_handler() local
118 b_sent = spi_sync(st->spi, st->ring_msg); in ad7887_trigger_handler()
122 iio_push_to_buffers_with_timestamp(indio_dev, st->data, in ad7887_trigger_handler()
135 static int ad7887_scan_direct(struct ad7887_state *st, unsigned ch) in ad7887_scan_direct() argument
137 int ret = spi_sync(st->spi, &st->msg[ch]); in ad7887_scan_direct()
141 return (st->data[(ch * 2)] << 8) | st->data[(ch * 2) + 1]; in ad7887_scan_direct()
151 struct ad7887_state *st = iio_priv(indio_dev); in ad7887_read_raw() local
158 ret = ad7887_scan_direct(st, chan->address); in ad7887_read_raw()
167 if (st->reg) { in ad7887_read_raw()
168 *val = regulator_get_voltage(st->reg); in ad7887_read_raw()
173 *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()
249 st->reg = devm_regulator_get_optional(&spi->dev, "vref"); in ad7887_probe()
250 if (IS_ERR(st->reg)) { in ad7887_probe()
251 if (PTR_ERR(st->reg) != -ENODEV) in ad7887_probe()
252 return PTR_ERR(st->reg); in ad7887_probe()
254 st->reg = NULL; in ad7887_probe()
257 if (st->reg) { in ad7887_probe()
258 ret = regulator_enable(st->reg); in ad7887_probe()
262 ret = devm_add_action_or_reset(&spi->dev, ad7887_reg_disable, st->reg); in ad7887_probe()
267 st->chip_info = in ad7887_probe()
270 st->spi = spi; in ad7887_probe()
279 if (!st->reg) in ad7887_probe()
284 st->tx_cmd_buf[0] = AD7887_CH_AIN0 | mode; in ad7887_probe()
286 st->xfer[0].rx_buf = &st->data[0]; in ad7887_probe()
287 st->xfer[0].tx_buf = &st->tx_cmd_buf[0]; in ad7887_probe()
288 st->xfer[0].len = 2; in ad7887_probe()
290 spi_message_init(&st->msg[AD7887_CH0]); in ad7887_probe()
291 spi_message_add_tail(&st->xfer[0], &st->msg[AD7887_CH0]); in ad7887_probe()
294 st->tx_cmd_buf[2] = AD7887_CH_AIN1 | mode; in ad7887_probe()
296 st->xfer[1].rx_buf = &st->data[0]; in ad7887_probe()
297 st->xfer[1].tx_buf = &st->tx_cmd_buf[2]; in ad7887_probe()
298 st->xfer[1].len = 2; in ad7887_probe()
300 st->xfer[2].rx_buf = &st->data[2]; in ad7887_probe()
301 st->xfer[2].tx_buf = &st->tx_cmd_buf[0]; in ad7887_probe()
302 st->xfer[2].len = 2; in ad7887_probe()
304 spi_message_init(&st->msg[AD7887_CH0_CH1]); in ad7887_probe()
305 spi_message_add_tail(&st->xfer[1], &st->msg[AD7887_CH0_CH1]); in ad7887_probe()
306 spi_message_add_tail(&st->xfer[2], &st->msg[AD7887_CH0_CH1]); in ad7887_probe()
308 st->xfer[3].rx_buf = &st->data[2]; in ad7887_probe()
309 st->xfer[3].tx_buf = &st->tx_cmd_buf[2]; in ad7887_probe()
310 st->xfer[3].len = 2; in ad7887_probe()
312 spi_message_init(&st->msg[AD7887_CH1]); in ad7887_probe()
313 spi_message_add_tail(&st->xfer[3], &st->msg[AD7887_CH1]); in ad7887_probe()
315 indio_dev->channels = st->chip_info->dual_channels; in ad7887_probe()
316 indio_dev->num_channels = st->chip_info->num_dual_channels; in ad7887_probe()
318 indio_dev->channels = st->chip_info->channels; in ad7887_probe()
319 indio_dev->num_channels = st->chip_info->num_channels; in ad7887_probe()