i2c: stm32f7: Make structure stm32f7_i2c_algo constant
Subsystems (3)
PATCH 1/1 i2c: stm32f7: Make structure stm32f7_i2c_algo constant
Static structure stm32f7_i2c_algo, of type i2c_algorithm, is used only when it is assigned to constant field algo of a variable having type i2c_adapter. As stm32f7_i2c_algo is therefore never modified, make it const as well to protect it from unintended modification. Issue found with Coccinelle.
--- drivers/i2c/busses/i2c-stm32f7.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-stm32f7.c +1 -1
@@ -1809,7 +1809,7 @@ static u32 stm32f7_i2c_func(struct i2c_adapter *adap)I2C_FUNC_SMBUS_I2C_BLOCK ; } -static struct i2c_algorithm stm32f7_i2c_algo = { +static const struct i2c_algorithm stm32f7_i2c_algo = { .master_xfer = stm32f7_i2c_xfer, .smbus_xfer = stm32f7_i2c_smbus_xfer, .functionality = stm32f7_i2c_func,
Signature · 1 line
2.19.1
Quoted 8 lines · Nishka Dasgupta
Static structure
stm32f7_i2c_algo, of typei2c_algorithm, is used only when it is assigned to constant field algo of a variable having typei2c_adapter. Asstm32f7_i2c_algois therefore never modified, make it const as well to protect it from unintended modification. Issue found with Coccinelle.Signed-off-by Nishka Dasgupta <[email protected]>---
Are you guys okay with this patch?
Quoted 19 lines
drivers/i2c/busses/i2c-stm32f7.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/i2c/busses/i2c-stm32f7.c +1
-1@@ -1809,7 +1809,7 @@ static u32 stm32f7_i2c_func(struct i2c_adapter *adap)I2C_FUNC_SMBUS_I2C_BLOCK ; } -static struct i2c_algorithm stm32f7_i2c_algo = { +static const struct i2c_algorithm stm32f7_i2c_algo = { .master_xfer = stm32f7_i2c_xfer, .smbus_xfer = stm32f7_i2c_smbus_xfer, .functionality = stm32f7_i2c_func,Signature · 1 line
2.19.1
Pierre Yves MORDRET
Acked-byHi Wolfram
Sorry for the delay.
BR
Quoted 31 lines · Wolfram Sang
Quoted 8 lines · Nishka Dasgupta
Static structure
stm32f7_i2c_algo, of typei2c_algorithm, is used only when it is assigned to constant field algo of a variable having typei2c_adapter. Asstm32f7_i2c_algois therefore never modified, make it const as well to protect it from unintended modification. Issue found with Coccinelle.Signed-off-by Nishka Dasgupta <[email protected]>---
Are you guys okay with this patch?
Quoted 19 lines
drivers/i2c/busses/i2c-stm32f7.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/i2c/busses/i2c-stm32f7.c +1
-1@@ -1809,7 +1809,7 @@ static u32 stm32f7_i2c_func(struct i2c_adapter *adap)I2C_FUNC_SMBUS_I2C_BLOCK ; } -static struct i2c_algorithm stm32f7_i2c_algo = { +static const struct i2c_algorithm stm32f7_i2c_algo = { .master_xfer = stm32f7_i2c_xfer, .smbus_xfer = stm32f7_i2c_smbus_xfer, .functionality = stm32f7_i2c_func,Signature · 1 line
2.19.1
Wolfram Sang
AppliedQuoted 7 lines · Nishka Dasgupta
Static structure
stm32f7_i2c_algo, of typei2c_algorithm, is used only when it is assigned to constant field algo of a variable having typei2c_adapter. Asstm32f7_i2c_algois therefore never modified, make it const as well to protect it from unintended modification. Issue found with Coccinelle.Signed-off-by Nishka Dasgupta <[email protected]>
Applied to for-next, thanks!