diff mbox series

iio: proximity: aw96103: Constify struct iio_info​

Message ID da4918af46fef03903ab0e9fdcb4f23e014f3821.1733522812.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State Accepted
Headers show
Series iio: proximity: aw96103: Constify struct iio_info​ | expand

Commit Message

Christophe JAILLET Dec. 6, 2024, 10:07 p.m. UTC
'struct iio_info' is not modified in this driver.

Constifying this structure moves some data to a read-only section, so
increase overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig:
Before:
======
   text	   data	    bss	    dec	    hex	filename
  17366	   1454	     16	  18836	   4994	drivers/iio/proximity/aw96103.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
  17526	   1294	     16	  18836	   4994	drivers/iio/proximity/aw96103.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only
---
 drivers/iio/proximity/aw96103.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jonathan Cameron Dec. 7, 2024, 5:55 p.m. UTC | #1
On Fri,  6 Dec 2024 23:07:23 +0100
Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:

> 'struct iio_info' is not modified in this driver.
> 
> Constifying this structure moves some data to a read-only section, so
> increase overall security, especially when the structure holds some
> function pointers.
> 
> On a x86_64, with allmodconfig:
> Before:
> ======
>    text	   data	    bss	    dec	    hex	filename
>   17366	   1454	     16	  18836	   4994	drivers/iio/proximity/aw96103.o
> 
> After:
> =====
>    text	   data	    bss	    dec	    hex	filename
>   17526	   1294	     16	  18836	   4994	drivers/iio/proximity/aw96103.o
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Applied. Thanks
Jonathan

> ---
> Compile tested only
> ---
>  drivers/iio/proximity/aw96103.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/proximity/aw96103.c b/drivers/iio/proximity/aw96103.c
> index cdd254da9e50..3472a2c36e44 100644
> --- a/drivers/iio/proximity/aw96103.c
> +++ b/drivers/iio/proximity/aw96103.c
> @@ -433,7 +433,7 @@ static int aw96103_write_event_config(struct iio_dev *indio_dev,
>  				  state ? BIT(chan->channel) : 0);
>  }
>  
> -static struct iio_info iio_info = {
> +static const struct iio_info iio_info = {
>  	.read_raw = aw96103_read_raw,
>  	.read_event_value = aw96103_read_event_val,
>  	.write_event_value = aw96103_write_event_val,
diff mbox series

Patch

diff --git a/drivers/iio/proximity/aw96103.c b/drivers/iio/proximity/aw96103.c
index cdd254da9e50..3472a2c36e44 100644
--- a/drivers/iio/proximity/aw96103.c
+++ b/drivers/iio/proximity/aw96103.c
@@ -433,7 +433,7 @@  static int aw96103_write_event_config(struct iio_dev *indio_dev,
 				  state ? BIT(chan->channel) : 0);
 }
 
-static struct iio_info iio_info = {
+static const struct iio_info iio_info = {
 	.read_raw = aw96103_read_raw,
 	.read_event_value = aw96103_read_event_val,
 	.write_event_value = aw96103_write_event_val,