]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: dvb-usb-v2: Constify struct i2c_algorithm
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sat, 7 Sep 2024 20:30:42 +0000 (22:30 +0200)
committerHans Verkuil <hverkuil@xs4all.nl>
Fri, 21 Feb 2025 09:33:14 +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_usbv2_i2c_init()

On a x86_64, with allmodconfig, as an example:
Before:
======
   text    data     bss     dec     hex filename
  35366    5832      36   41234    a112 drivers/media/usb/dvb-usb-v2/af9015.o

After:
=====
   text    data     bss     dec     hex filename
  35430    5768      36   41234    a112 drivers/media/usb/dvb-usb-v2/af9015.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
13 files changed:
drivers/media/usb/dvb-usb-v2/af9015.c
drivers/media/usb/dvb-usb-v2/af9035.c
drivers/media/usb/dvb-usb-v2/anysee.c
drivers/media/usb/dvb-usb-v2/au6610.c
drivers/media/usb/dvb-usb-v2/az6007.c
drivers/media/usb/dvb-usb-v2/ce6230.c
drivers/media/usb/dvb-usb-v2/dvb_usb.h
drivers/media/usb/dvb-usb-v2/dvbsky.c
drivers/media/usb/dvb-usb-v2/ec168.c
drivers/media/usb/dvb-usb-v2/gl861.c
drivers/media/usb/dvb-usb-v2/lmedm04.c
drivers/media/usb/dvb-usb-v2/mxl111sf.c
drivers/media/usb/dvb-usb-v2/rtl28xxu.c

index 4014f7d07330f65f7645a6c3a32b17373f0d7cd2..3eddc40377bfa3500ca5a77950d80ac8143d77b0 100644 (file)
@@ -260,7 +260,7 @@ static u32 af9015_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm af9015_i2c_algo = {
+static const struct i2c_algorithm af9015_i2c_algo = {
        .master_xfer = af9015_i2c_xfer,
        .functionality = af9015_i2c_func,
 };
index 218f712f56b17c2e50d83700f025237cc0321bde..17062672ea066c462cbf0ecc0263cbf28e3e521b 100644 (file)
@@ -483,7 +483,7 @@ static u32 af9035_i2c_functionality(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm af9035_i2c_algo = {
+static const struct i2c_algorithm af9035_i2c_algo = {
        .master_xfer = af9035_i2c_master_xfer,
        .functionality = af9035_i2c_functionality,
 };
index bea12cdc85e8ba576182a139e7533985fc26c5c5..64bddca5303ce16ad241d07ebfd1b23fd1e3b8b5 100644 (file)
@@ -235,7 +235,7 @@ static u32 anysee_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm anysee_i2c_algo = {
+static const struct i2c_algorithm anysee_i2c_algo = {
        .master_xfer   = anysee_master_xfer,
        .functionality = anysee_i2c_func,
 };
index be223fc8aa14d9700cbcbe851d6919d353c58ebf..c20a9469f564d28bc6d59514863f2620e06f5f8a 100644 (file)
@@ -115,7 +115,7 @@ static u32 au6610_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm au6610_i2c_algo = {
+static const struct i2c_algorithm au6610_i2c_algo = {
        .master_xfer   = au6610_i2c_xfer,
        .functionality = au6610_i2c_func,
 };
index 2410054ddb2c345909fad792bd815e5a0584e7c3..65ef045b74caca82b48b59b437512d1598575e41 100644 (file)
@@ -838,7 +838,7 @@ static u32 az6007_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm az6007_i2c_algo = {
+static const struct i2c_algorithm az6007_i2c_algo = {
        .master_xfer = az6007_i2c_xfer,
        .functionality = az6007_i2c_func,
 };
index d3b5cb4a24daf9c47a4903a3618aee977abeafd3..7ebaf3ee449182548ea0c5a30c58be1bcd869c94 100644 (file)
@@ -154,7 +154,7 @@ static u32 ce6230_i2c_functionality(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm ce6230_i2c_algorithm = {
+static const struct i2c_algorithm ce6230_i2c_algorithm = {
        .master_xfer   = ce6230_i2c_master_xfer,
        .functionality = ce6230_i2c_functionality,
 };
index 288c15a7d72be5966bdd6d64aafd35bc48a3f033..ecdc20d45132ee86a00e49d092aafa73407d837e 100644 (file)
@@ -243,7 +243,7 @@ struct dvb_usb_device_properties {
        int (*download_firmware) (struct dvb_usb_device *,
                        const struct firmware *);
 
-       struct i2c_algorithm *i2c_algo;
+       const struct i2c_algorithm *i2c_algo;
 
        unsigned int num_adapters;
        int (*get_adapter_count) (struct dvb_usb_device *);
index 1221c924312adbafde97376d3a0859eb3c075349..ceac0ea21daba04b16c149c1bdfbf28f12ee9010 100644 (file)
@@ -169,7 +169,7 @@ static u32 dvbsky_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm dvbsky_i2c_algo = {
+static const struct i2c_algorithm dvbsky_i2c_algo = {
        .master_xfer   = dvbsky_i2c_xfer,
        .functionality = dvbsky_i2c_func,
 };
index 0e4773fc025c9e74f8c86a451e9df60b513ccc8f..973b32356b17ec19d799755d20bb68363ef49bc2 100644 (file)
@@ -176,7 +176,7 @@ static u32 ec168_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm ec168_i2c_algo = {
+static const struct i2c_algorithm ec168_i2c_algo = {
        .master_xfer   = ec168_i2c_xfer,
        .functionality = ec168_i2c_func,
 };
index c71e7b93476dec5c76a692f0b7cefc2b02e8858f..0538170ccf29a8fe21475df4f9637cf53aa6a9f1 100644 (file)
@@ -162,7 +162,7 @@ static u32 gl861_i2c_functionality(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm gl861_i2c_algo = {
+static const struct i2c_algorithm gl861_i2c_algo = {
        .master_xfer   = gl861_i2c_master_xfer,
        .functionality = gl861_i2c_functionality,
 };
index f0537b741d1352c5c18d3070badd38d0593eda49..0c510035805b4dc019d85572fee51a22195350cc 100644 (file)
@@ -559,7 +559,7 @@ static u32 lme2510_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm lme2510_i2c_algo = {
+static const struct i2c_algorithm lme2510_i2c_algo = {
        .master_xfer   = lme2510_i2c_xfer,
        .functionality = lme2510_i2c_func,
 };
index cd5861a30b6f853a4eca87234624425087a3d236..870ac3c8b085d4614356217a93cf81709e5eb0bc 100644 (file)
@@ -911,7 +911,7 @@ static u32 mxl111sf_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm mxl111sf_i2c_algo = {
+static const struct i2c_algorithm mxl111sf_i2c_algo = {
        .master_xfer   = mxl111sf_i2c_xfer,
        .functionality = mxl111sf_i2c_func,
 #ifdef NEED_ALGO_CONTROL
index f7884bb56fccff29205c95f20b00fd098cec3ee3..487c6ab784abd605ac19d0b9ed295f32558303d9 100644 (file)
@@ -290,7 +290,7 @@ static u32 rtl28xxu_i2c_func(struct i2c_adapter *adapter)
        return I2C_FUNC_I2C;
 }
 
-static struct i2c_algorithm rtl28xxu_i2c_algo = {
+static const struct i2c_algorithm rtl28xxu_i2c_algo = {
        .master_xfer   = rtl28xxu_i2c_xfer,
        .functionality = rtl28xxu_i2c_func,
 };