On Wed, May 24, 2023 at 03:01:11AM +0300, George Stark wrote:
Patch adds two sysfs nodes: chan7_mux to set mux stateGND
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.
Vdd
...
+static ssize_t chan7_mux_store(struct device *dev,NIH sysfs_match_string().
+ 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;
+}...
+static IIO_DEVICE_ATTR_RW(chan7_mux, -1);Place each of them near to the respective callback(s),
+static IIO_DEVICE_ATTR_RO(chan7_mux_available, -1);
...
+static struct attribute *meson_sar_adc_attrs[] = {No comma for the terminator entry.
+ &iio_dev_attr_chan7_mux_available.dev_attr.attr,
+ &iio_dev_attr_chan7_mux.dev_attr.attr,
+ NULL,
+};