i2c: taos-evm: Make structure tsl2550_info constant
diff mbox series

Message ID 20190819074601.326-1-nishkadg.linux@gmail.com
State Accepted
Headers show
Series
  • i2c: taos-evm: Make structure tsl2550_info constant
Related show

Commit Message

Nishka Dasgupta Aug. 19, 2019, 7:46 a.m. UTC
Static structure tsl2550_info, of type i2c_board_info, is referenced
only twice: the first time in arguments to dev_info() (which does not
modify it) and the second time as the last argument to function
i2c_new_device() (where the corresponding parameter is declared as
const). As tsl2550_info is therefore never modified, make it const to
protect it from unintended modifications.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
 drivers/i2c/busses/i2c-taos-evm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jean Delvare Aug. 28, 2019, 9:57 a.m. UTC | #1
On Mon, 19 Aug 2019 13:16:01 +0530, Nishka Dasgupta wrote:
> Static structure tsl2550_info, of type i2c_board_info, is referenced
> only twice: the first time in arguments to dev_info() (which does not
> modify it) and the second time as the last argument to function
> i2c_new_device() (where the corresponding parameter is declared as
> const). As tsl2550_info is therefore never modified, make it const to
> protect it from unintended modifications.
> Issue found with Coccinelle.
> 
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> ---
>  drivers/i2c/busses/i2c-taos-evm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-taos-evm.c b/drivers/i2c/busses/i2c-taos-evm.c
> index c82e78f57386..056df6b2538a 100644
> --- a/drivers/i2c/busses/i2c-taos-evm.c
> +++ b/drivers/i2c/busses/i2c-taos-evm.c
> @@ -39,7 +39,7 @@ struct taos_data {
>  };
>  
>  /* TAOS TSL2550 EVM */
> -static struct i2c_board_info tsl2550_info = {
> +static const struct i2c_board_info tsl2550_info = {
>  	I2C_BOARD_INFO("tsl2550", 0x39),
>  };
>  

Reviewed-by: Jean Delvare <jdelvare@suse.de>

Thanks,
Wolfram Sang Aug. 29, 2019, 8:05 p.m. UTC | #2
On Mon, Aug 19, 2019 at 01:16:01PM +0530, Nishka Dasgupta wrote:
> Static structure tsl2550_info, of type i2c_board_info, is referenced
> only twice: the first time in arguments to dev_info() (which does not
> modify it) and the second time as the last argument to function
> i2c_new_device() (where the corresponding parameter is declared as
> const). As tsl2550_info is therefore never modified, make it const to
> protect it from unintended modifications.
> Issue found with Coccinelle.
> 
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>

Applied to for-next, thanks!

Patch
diff mbox series

diff --git a/drivers/i2c/busses/i2c-taos-evm.c b/drivers/i2c/busses/i2c-taos-evm.c
index c82e78f57386..056df6b2538a 100644
--- a/drivers/i2c/busses/i2c-taos-evm.c
+++ b/drivers/i2c/busses/i2c-taos-evm.c
@@ -39,7 +39,7 @@  struct taos_data {
 };
 
 /* TAOS TSL2550 EVM */
-static struct i2c_board_info tsl2550_info = {
+static const struct i2c_board_info tsl2550_info = {
 	I2C_BOARD_INFO("tsl2550", 0x39),
 };