iio: Mark iio_device_type as const
authorLars-Peter Clausen <lars@metafoo.de>
Sun, 31 Oct 2021 08:04:21 +0000 (09:04 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 17 Nov 2021 17:51:35 +0000 (17:51 +0000)
The iio_device_type struct is never modified, mark it as const. This allows
it to be placed in a read-only memory section, which will protect against
accidental or deliberate modification.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20211031080421.2086-1-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/iio_core.h
drivers/iio/industrialio-core.c

index 61e318431de99ae8647be4831cac5503a0904edb..501e286702ef0a6e0d517f1e484480f7fc059c91 100644 (file)
@@ -16,7 +16,7 @@ struct iio_buffer;
 struct iio_chan_spec;
 struct iio_dev;
 
-extern struct device_type iio_device_type;
+extern const struct device_type iio_device_type;
 
 struct iio_dev_buffer_pair {
        struct iio_dev          *indio_dev;
index d94d26b11473fd07e07a18c3cba96d9a7195a933..20d5178ca0739a23af17ec6d24d9ccaa4eb3b285 100644 (file)
@@ -1622,7 +1622,7 @@ static void iio_dev_release(struct device *device)
        kfree(iio_dev_opaque);
 }
 
-struct device_type iio_device_type = {
+const struct device_type iio_device_type = {
        .name = "iio_device",
        .release = iio_dev_release,
 };