On Mon, 24 Feb 2025 20:33:16 +0200
Matti Vaittinen <mazziesaccount@xxxxxxxxx> wrote:
There are ADC ICs which may have some of the AIN pins usable for otherI think it's worth exploring if we can tweak this slightly to make
functions. These ICs may have some of the AIN pins wired so that they
should not be used for ADC.
(Preferred?) way for marking pins which can be used as ADC inputs is to
add corresponding channels@N nodes in the device tree as described in
the ADC binding yaml.
that something a driver specifies. Either skip the unspecified or
fill them with default values depending on a parameter.
Would make this code cover the existing cases better.
Might be a little fiddly as we'd want to maintain ordering so
the code would need to index slightly differently. I've not tried it
so maybe not worth it for now.
+
+int iio_adc_device_num_channels(struct device *dev)
+{
+ return device_get_child_node_count_named(dev, "channel");
+}
+EXPORT_SYMBOL_GPL(iio_adc_device_num_channels);
Maybe one to promote to a static inline in the header and avoid need for
the export given it is very simple.
+
+ if (max_chan_id != -1)
+ if (ch > max_chan_id)
+ return -ERANGE;
Might as well combine.
if (max_chan_id != -1 && ch > max_chan_id)
return -ERANGE;