Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: Mark iio_device_type as const
@ 2021-10-31  8:04 Lars-Peter Clausen
  2021-11-03 17:51 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Lars-Peter Clausen @ 2021-10-31  8:04 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

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>
---
 drivers/iio/iio_core.h          | 2 +-
 drivers/iio/industrialio-core.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/iio_core.h b/drivers/iio/iio_core.h
index 61e318431de9..501e286702ef 100644
--- a/drivers/iio/iio_core.h
+++ b/drivers/iio/iio_core.h
@@ -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;
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 463a63d5bf56..737518efa38f 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -1619,7 +1619,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,
 };
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iio: Mark iio_device_type as const
  2021-10-31  8:04 [PATCH] iio: Mark iio_device_type as const Lars-Peter Clausen
@ 2021-11-03 17:51 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2021-11-03 17:51 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On Sun, 31 Oct 2021 09:04:21 +0100
Lars-Peter Clausen <lars@metafoo.de> wrote:

> 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>
Applied to the togreg branch of iio.git which will be only visible
as testing for 0-day to poke at it until after the merge window.

Thanks,

Jonathan

> ---
>  drivers/iio/iio_core.h          | 2 +-
>  drivers/iio/industrialio-core.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/iio_core.h b/drivers/iio/iio_core.h
> index 61e318431de9..501e286702ef 100644
> --- a/drivers/iio/iio_core.h
> +++ b/drivers/iio/iio_core.h
> @@ -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;
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 463a63d5bf56..737518efa38f 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -1619,7 +1619,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,
>  };


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-03 17:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-31  8:04 [PATCH] iio: Mark iio_device_type as const Lars-Peter Clausen
2021-11-03 17:51 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox