}
}
-static int ingenic_adc_read_chan_info_raw(struct iio_dev *iio_dev,
- struct iio_chan_spec const *chan,
- int *val)
+static int __ingenic_adc_read_chan(struct ingenic_adc *adc,
+ struct iio_chan_spec const *chan,
+ int *val)
{
int cmd, ret, engine = (chan->channel == INGENIC_ADC_BATTERY);
- struct ingenic_adc *adc = iio_priv(iio_dev);
-
- ret = clk_enable(adc->clk);
- if (ret) {
- dev_err(iio_dev->dev.parent, "Failed to enable clock: %d\n",
- ret);
- return ret;
- }
- /* We cannot sample the aux channels in parallel. */
- mutex_lock(&adc->aux_lock);
if (adc->soc_data->has_aux_md && engine == 0) {
switch (chan->channel) {
case INGENIC_ADC_AUX0:
ret = ingenic_adc_capture(adc, engine);
if (ret)
- goto out;
+ return ret;
switch (chan->channel) {
case INGENIC_ADC_AUX0:
break;
}
- ret = IIO_VAL_INT;
-out:
+ return IIO_VAL_INT;
+}
+
+static int ingenic_adc_read_chan_info_raw(struct iio_dev *iio_dev,
+ struct iio_chan_spec const *chan,
+ int *val)
+{
+ struct ingenic_adc *adc = iio_priv(iio_dev);
+ int ret;
+
+ ret = clk_enable(adc->clk);
+ if (ret) {
+ dev_err(iio_dev->dev.parent, "Failed to enable clock: %d\n", ret);
+ return ret;
+ }
+
+ /* We cannot sample the aux channels in parallel. */
+ mutex_lock(&adc->aux_lock);
+ ret = __ingenic_adc_read_chan(adc, chan, val);
mutex_unlock(&adc->aux_lock);
+
clk_disable(adc->clk);
return ret;