]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: dvb-usb: Constify struct i2c_algorithm
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sat, 7 Sep 2024 20:36:29 +0000 (22:36 +0200)
committerHans Verkuil <hverkuil@xs4all.nl>
Fri, 21 Feb 2025 09:33:12 +0000 (10:33 +0100)
'struct i2c_algorithm' are not modified in these drivers.

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

More over, dvb_usb_device_properties->i2c_algo seems to only be copied in
i2c_adapter->algo, which is already a "const struct i2c_algorithm".
This is done in dvb_usb_i2c_init()

On a x86_64, with allmodconfig, as an example:
Before:
======
   text    data     bss     dec     hex filename
  30571    5916      36   36523    8eab drivers/media/usb/dvb-usb/af9005.o

After:
=====
   text    data     bss     dec     hex filename
  30667    5852      36   36555    8ecb drivers/media/usb/dvb-usb/af9005.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
12 files changed:
drivers/media/usb/dvb-usb/af9005.c
drivers/media/usb/dvb-usb/az6027.c
drivers/media/usb/dvb-usb/cxusb.c
drivers/media/usb/dvb-usb/digitv.c
drivers/media/usb/dvb-usb/dtv5100.c
drivers/media/usb/dvb-usb/dvb-usb.h
drivers/media/usb/dvb-usb/dw2102.c
drivers/media/usb/dvb-usb/m920x.c
drivers/media/usb/dvb-usb/opera1.c
drivers/media/usb/dvb-usb/pctv452e.c
drivers/media/usb/dvb-usb/technisat-usb2.c
drivers/media/usb/dvb-usb/ttusb2.c

index 7ddda6fb0fbdb3313405a7064cbc34c8a4ca1d55..a4bede7e8a1daa6c6bbe92df0449ce497e8976cd 100644 (file)
@@ -445,7 +445,7 @@ static u32 af9005_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm af9005_i2c_algo = {
+static const struct i2c_algorithm af9005_i2c_algo = {
        .master_xfer = af9005_i2c_xfer,
        .functionality = af9005_i2c_func,
 };
index 156a299d4a2bd0bcb81bd62a23e5d2a8bb0d00eb..056935d3cbd6d63262f8302b6e14a17fdecea0d6 100644 (file)
@@ -1062,7 +1062,7 @@ static u32 az6027_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm az6027_i2c_algo = {
+static const struct i2c_algorithm az6027_i2c_algo = {
        .master_xfer   = az6027_i2c_xfer,
        .functionality = az6027_i2c_func,
 };
index 9b4d4b86d5f4175835b854f48b43dcf19a6f44cf..f44529b40989b11aadd94e1a171b18b1ef035300 100644 (file)
@@ -287,7 +287,7 @@ static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
 }
 
-static struct i2c_algorithm cxusb_i2c_algo = {
+static const struct i2c_algorithm cxusb_i2c_algo = {
        .master_xfer   = cxusb_i2c_xfer,
        .functionality = cxusb_i2c_func,
 };
index 5a9bc630ba77d0c914c5768cbbb85d5d39b9f3d3..ab229ab1a8588f05346a176b719bd72f60d59baf 100644 (file)
@@ -88,7 +88,7 @@ static u32 digitv_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm digitv_i2c_algo = {
+static const struct i2c_algorithm digitv_i2c_algo = {
        .master_xfer   = digitv_i2c_xfer,
        .functionality = digitv_i2c_func,
 };
index 5eb4c995c7589b3824ff416b85441861158067d1..3d85c6f7f6ecf401a6e60ed4f5d77f4c510a28fe 100644 (file)
@@ -97,7 +97,7 @@ static u32 dtv5100_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm dtv5100_i2c_algo = {
+static const struct i2c_algorithm dtv5100_i2c_algo = {
        .master_xfer   = dtv5100_i2c_xfer,
        .functionality = dtv5100_i2c_func,
 };
index a06f08f9915bc8af6e5cdaf618b8c161ede81cc5..550006a8d86f8bd32226097541775b1084ff9693 100644 (file)
@@ -309,7 +309,7 @@ struct dvb_usb_device_properties {
                struct dvb_rc core;
        } rc;
 
-       struct i2c_algorithm *i2c_algo;
+       const struct i2c_algorithm *i2c_algo;
 
        int generic_bulk_ctrl_endpoint;
        int generic_bulk_ctrl_endpoint_response;
index a21ba81163ba8a1e3588293d880a6c0b6f6c24e0..4fecf2f965e9a08a923d012c32e926b919bb3379 100644 (file)
@@ -839,37 +839,37 @@ static u32 dw210x_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm dw2102_i2c_algo = {
+static const struct i2c_algorithm dw2102_i2c_algo = {
        .master_xfer = dw2102_i2c_transfer,
        .functionality = dw210x_i2c_func,
 };
 
-static struct i2c_algorithm dw2102_serit_i2c_algo = {
+static const struct i2c_algorithm dw2102_serit_i2c_algo = {
        .master_xfer = dw2102_serit_i2c_transfer,
        .functionality = dw210x_i2c_func,
 };
 
-static struct i2c_algorithm dw2102_earda_i2c_algo = {
+static const struct i2c_algorithm dw2102_earda_i2c_algo = {
        .master_xfer = dw2102_earda_i2c_transfer,
        .functionality = dw210x_i2c_func,
 };
 
-static struct i2c_algorithm dw2104_i2c_algo = {
+static const struct i2c_algorithm dw2104_i2c_algo = {
        .master_xfer = dw2104_i2c_transfer,
        .functionality = dw210x_i2c_func,
 };
 
-static struct i2c_algorithm dw3101_i2c_algo = {
+static const struct i2c_algorithm dw3101_i2c_algo = {
        .master_xfer = dw3101_i2c_transfer,
        .functionality = dw210x_i2c_func,
 };
 
-static struct i2c_algorithm s6x0_i2c_algo = {
+static const struct i2c_algorithm s6x0_i2c_algo = {
        .master_xfer = s6x0_i2c_transfer,
        .functionality = dw210x_i2c_func,
 };
 
-static struct i2c_algorithm su3000_i2c_algo = {
+static const struct i2c_algorithm su3000_i2c_algo = {
        .master_xfer = su3000_i2c_transfer,
        .functionality = dw210x_i2c_func,
 };
index 9ef0cd944286e5ed98d3021d2bc13bdad92a9ec1..45337ba0a0a326cb63b1d20316f415e9b62b1e6a 100644 (file)
@@ -319,7 +319,7 @@ static u32 m920x_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm m920x_i2c_algo = {
+static const struct i2c_algorithm m920x_i2c_algo = {
        .master_xfer   = m920x_i2c_xfer,
        .functionality = m920x_i2c_func,
 };
index 86bfcc641cf312385f6d6be9c106265caf1d47da..3c79cc6848b4071aeef23f4b211f78c4f0a01810 100644 (file)
@@ -155,7 +155,7 @@ static u32 opera1_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm opera1_i2c_algo = {
+static const struct i2c_algorithm opera1_i2c_algo = {
        .master_xfer = opera1_i2c_xfer,
        .functionality = opera1_i2c_func,
 };
index cbaa300264f84c9ac5f421ee572d8dea4fd37d59..5094de9a312e86ee7c04b4e8612954e859410b2e 100644 (file)
@@ -906,7 +906,7 @@ static struct stb6100_config stb6100_config = {
 };
 
 
-static struct i2c_algorithm pctv452e_i2c_algo = {
+static const struct i2c_algorithm pctv452e_i2c_algo = {
        .master_xfer   = pctv452e_i2c_xfer,
        .functionality = pctv452e_i2c_func
 };
index 8d49baa3b7ad7de6ff780229c27dfe931f107c1e..1e43aab2bc27fff140f8f3068cd887bae9cfd13f 100644 (file)
@@ -199,7 +199,7 @@ static u32 technisat_usb2_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm technisat_usb2_i2c_algo = {
+static const struct i2c_algorithm technisat_usb2_i2c_algo = {
        .master_xfer   = technisat_usb2_i2c_xfer,
        .functionality = technisat_usb2_i2c_func,
 };
index 0f2eccae46cefd74a8cb88b16d7776eeda1aacc6..acde6149d2784e1cea7ec3150c95e78aa8883dfa 100644 (file)
@@ -434,7 +434,7 @@ static u32 ttusb2_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm ttusb2_i2c_algo = {
+static const struct i2c_algorithm ttusb2_i2c_algo = {
        .master_xfer   = ttusb2_i2c_xfer,
        .functionality = ttusb2_i2c_func,
 };