summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Cercueil <paul@crapouillou.net>2021-06-18 14:30:04 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2021-07-19 10:51:59 +0200
commit0e0761f86f10253425edac56df9950c172b923ea (patch)
tree4aba4800d82fb01f5714be966c860d23123d2175
parentAdd startup time for each chip using inv_mpu6050 driver (diff)
downloadlinux-0e0761f86f10253425edac56df9950c172b923ea.tar.xz
linux-0e0761f86f10253425edac56df9950c172b923ea.zip
iio: core: Forbid use of both labels and extended names
Extended names are a problem for user-space as they make the filenames in sysfs sometimes not parsable. They are now deprecated in favor of labels. This change makes sure that a device driver won't provide both labels and extended names for its channels. It has never been the case and we don't want it to happen. Signed-off-by: Paul Cercueil <paul@crapouillou.net> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> Link: https://lore.kernel.org/r/20210618123005.49867-2-paul@crapouillou.net Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r--drivers/iio/industrialio-core.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 6d2175eb7af2..7e3c92efdfa0 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -1858,6 +1858,24 @@ static int iio_check_unique_scan_index(struct iio_dev *indio_dev)
return 0;
}
+static int iio_check_extended_name(const struct iio_dev *indio_dev)
+{
+ unsigned int i;
+
+ if (!indio_dev->info->read_label)
+ return 0;
+
+ for (i = 0; i < indio_dev->num_channels; i++) {
+ if (indio_dev->channels[i].extend_name) {
+ dev_err(&indio_dev->dev,
+ "Cannot use labels and extend_name at the same time\n");
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
static const struct iio_buffer_setup_ops noop_ring_setup_ops;
int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
@@ -1882,6 +1900,10 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
if (ret < 0)
return ret;
+ ret = iio_check_extended_name(indio_dev);
+ if (ret < 0)
+ return ret;
+
iio_device_register_debugfs(indio_dev);
ret = iio_buffers_alloc_sysfs_and_mask(indio_dev);