]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
media: flexcop-i2c: Constify struct i2c_algorithm
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sat, 29 Mar 2025 14:26:42 +0000 (15:26 +0100)
committerHans Verkuil <hverkuil@xs4all.nl>
Tue, 17 Jun 2025 08:35:14 +0000 (10:35 +0200)
'struct i2c_algorithm' 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, as an example:
Before:
======
   text    data     bss     dec     hex filename
   6645     216      16    6877    1add drivers/media/common/b2c2/flexcop-i2c.o

After:
=====
   text    data     bss     dec     hex filename
   6721     160      16    6897    1af1 drivers/media/common/b2c2/flexcop-i2c.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/common/b2c2/flexcop-i2c.c

index 1f1eaa807811b569d3a65566c3860a6d7d5845c7..21edf870d927c254b2dc03bd14dc75ef3fd62db7 100644 (file)
@@ -209,7 +209,7 @@ static u32 flexcop_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm flexcop_algo = {
+static const struct i2c_algorithm flexcop_algo = {
        .master_xfer    = flexcop_master_xfer,
        .functionality  = flexcop_i2c_func,
 };