iio: st_sensors: Drop the protection on _avail functions
authorMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 7 Feb 2022 14:38:32 +0000 (15:38 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 10 Apr 2022 15:15:02 +0000 (16:15 +0100)
The use of a lock there seems pointless. Besides preventing to read
these information from userspace while buffers are enabled (which is not
supposed to happen), it only protect read accesses over static const
values, which are never supposed to be written anyway.

Drop these lock calls.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Cc: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20220207143840.707510-6-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/common/st_sensors/st_sensors_core.c

index fa9bcdf..829ffe5 100644 (file)
@@ -641,7 +641,6 @@ ssize_t st_sensors_sysfs_sampling_frequency_avail(struct device *dev,
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
        struct st_sensor_data *sdata = iio_priv(indio_dev);
 
-       mutex_lock(&indio_dev->mlock);
        for (i = 0; i < ST_SENSORS_ODR_LIST_MAX; i++) {
                if (sdata->sensor_settings->odr.odr_avl[i].hz == 0)
                        break;
@@ -649,7 +648,6 @@ ssize_t st_sensors_sysfs_sampling_frequency_avail(struct device *dev,
                len += scnprintf(buf + len, PAGE_SIZE - len, "%d ",
                                sdata->sensor_settings->odr.odr_avl[i].hz);
        }
-       mutex_unlock(&indio_dev->mlock);
        buf[len - 1] = '\n';
 
        return len;
@@ -663,7 +661,6 @@ ssize_t st_sensors_sysfs_scale_avail(struct device *dev,
        struct iio_dev *indio_dev = dev_to_iio_dev(dev);
        struct st_sensor_data *sdata = iio_priv(indio_dev);
 
-       mutex_lock(&indio_dev->mlock);
        for (i = 0; i < ST_SENSORS_FULLSCALE_AVL_MAX; i++) {
                if (sdata->sensor_settings->fs.fs_avl[i].num == 0)
                        break;
@@ -673,7 +670,6 @@ ssize_t st_sensors_sysfs_scale_avail(struct device *dev,
 
                len += scnprintf(buf + len, PAGE_SIZE - len, "%u.%06u ", q, r);
        }
-       mutex_unlock(&indio_dev->mlock);
        buf[len - 1] = '\n';
 
        return len;