Lines Matching refs:adc
26 * Lock protecting access to adc->tx_buff and rx_buff,
76 static int ads8344_adc_conversion(struct ads8344 *adc, int channel,
79 struct spi_device *spi = adc->spi;
82 adc->tx_buf = ADS8344_START;
84 adc->tx_buf |= ADS8344_SINGLE_END;
85 adc->tx_buf |= ADS8344_CHANNEL(channel);
86 adc->tx_buf |= ADS8344_CLOCK_INTERNAL;
88 ret = spi_write(spi, &adc->tx_buf, 1);
94 ret = spi_read(spi, adc->rx_buf, sizeof(adc->rx_buf));
98 return adc->rx_buf[0] << 9 | adc->rx_buf[1] << 1 | adc->rx_buf[2] >> 7;
105 struct ads8344 *adc = iio_priv(iio);
109 mutex_lock(&adc->lock);
110 *value = ads8344_adc_conversion(adc, channel->address,
112 mutex_unlock(&adc->lock);
118 *value = regulator_get_voltage(adc->reg);
144 struct ads8344 *adc;
147 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc));
151 adc = iio_priv(indio_dev);
152 adc->spi = spi;
153 mutex_init(&adc->lock);
161 adc->reg = devm_regulator_get(&spi->dev, "vref");
162 if (IS_ERR(adc->reg))
163 return PTR_ERR(adc->reg);
165 ret = regulator_enable(adc->reg);
169 ret = devm_add_action_or_reset(&spi->dev, ads8344_reg_disable, adc->reg);