[PATCH v1] meson saradc: add iio device attrib to switch channel 7 mux

George Stark gnstark at sberdevices.ru
Sat May 27 14:37:49 PDT 2023


Hi Andy

Thanks for review. I fixed it in patch v2

Best regards
George


On 5/27/23 11:21, Andy Shevchenko wrote:
> On Wed, May 24, 2023 at 03:01:11AM +0300, George Stark wrote:
>> Patch adds two sysfs nodes: chan7_mux to set mux state
>> and chan7_mux_available to show available mux states.
>> Mux can be used to debug and calibrate adc by
>> switching and measuring well-known inputs like gnd, vdd etc.
> GND
> Vdd
>
> ...
>
>> +static ssize_t chan7_mux_store(struct device *dev,
>> +			       struct device_attribute *attr,
>> +			       const char *buf, size_t count)
>> +{
>> +	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>> +	int i;
>> +
>> +	for (i = 0; i < ARRAY_SIZE(chan7_vol); i++)
>> +		if (!strcmp(chan7_vol[i], buf)) {
>> +			meson_sar_adc_set_chan7_mux(indio_dev, i);
>> +			return count;
>> +		}
>> +
>> +	return -EINVAL;
> NIH sysfs_match_string().
>
>> +}
> ...
>
>> +static IIO_DEVICE_ATTR_RW(chan7_mux, -1);
>> +static IIO_DEVICE_ATTR_RO(chan7_mux_available, -1);
> Place each of them near to the respective callback(s),
>
> ...
>
>> +static struct attribute *meson_sar_adc_attrs[] = {
>> +	&iio_dev_attr_chan7_mux_available.dev_attr.attr,
>> +	&iio_dev_attr_chan7_mux.dev_attr.attr,
>> +	NULL,
> No comma for the terminator entry.
>
>> +};





More information about the linux-arm-kernel mailing list