]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: core: annotate masklength as __private
authorNuno Sa <nuno.sa@analog.com>
Fri, 26 Jul 2024 08:23:15 +0000 (10:23 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 3 Aug 2024 09:13:43 +0000 (10:13 +0100)
Now that all users are using the proper accessors, we can mark
masklength as __private so that no one tries to write. We also get help
from checkers in warning us in case someone does it.

To access the private field from IIO core code, we need to use the
ACCESS_PRIVATE() macro.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240726-dev-iio-masklength-private3-v1-23-82913fc0fb87@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/industrialio-buffer.c
include/linux/iio/iio.h

index 3d0b1d25fdd7c5272cb5bbd28591ed3e11a8f88c..8104696cd47509682123fddad5e7a616cdb7dbfc 100644 (file)
@@ -2269,7 +2269,7 @@ int iio_buffers_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
 
                for (i = 0; i < indio_dev->num_channels; i++)
                        ml = max(ml, channels[i].scan_index + 1);
-               indio_dev->masklength = ml;
+               ACCESS_PRIVATE(indio_dev, masklength) = ml;
        }
 
        if (!iio_dev_opaque->attached_buffers_cnt)
index dd6bbc468283e0e604d8f653c1445ad2676e0e01..f6c0499853bbae6bdae53191923a0d20e4a2a21a 100644 (file)
@@ -609,7 +609,7 @@ struct iio_dev {
        int                             scan_bytes;
 
        const unsigned long             *available_scan_masks;
-       unsigned                        masklength;
+       unsigned                        __private masklength;
        const unsigned long             *active_scan_mask;
        bool                            scan_timestamp;
        struct iio_trigger              *trig;
@@ -861,7 +861,7 @@ static inline const struct iio_scan_type
  */
 static inline unsigned int iio_get_masklength(const struct iio_dev *indio_dev)
 {
-       return indio_dev->masklength;
+       return ACCESS_PRIVATE(indio_dev, masklength);
 }
 
 /**