]> www.infradead.org Git - users/willy/xarray.git/commitdiff
i2c: rzv2m: Constify struct i2c_algorithm
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sat, 29 Mar 2025 14:37:07 +0000 (15:37 +0100)
committerAndi Shyti <andi@smida.it>
Mon, 19 May 2025 20:23:54 +0000 (22:23 +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
  11027     646      16   11689    2da9 drivers/i2c/busses/i2c-rzv2m.o

After:
=====
   text    data     bss     dec     hex filename
  11107     566      16   11689    2da9 drivers/i2c/busses/i2c-rzv2m.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
Link: https://lore.kernel.org/r/537d93441ced53bffa6553b8ec93d007e64cb9a5.1743258995.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
drivers/i2c/busses/i2c-rzv2m.c

index 53762cc56d284abffaabf63e2c8a7eb8b3188d23..b0e9c0b624292c7af4b7a6d3ee0e0978657c65c2 100644 (file)
@@ -402,7 +402,7 @@ static const struct i2c_adapter_quirks rzv2m_i2c_quirks = {
        .flags = I2C_AQ_NO_ZERO_LEN,
 };
 
-static struct i2c_algorithm rzv2m_i2c_algo = {
+static const struct i2c_algorithm rzv2m_i2c_algo = {
        .xfer = rzv2m_i2c_xfer,
        .functionality = rzv2m_i2c_func,
 };