diff mbox series

i2c: synquacer: Make synquacer_i2c_ops constant

Message ID 20190819075854.1960-1-nishkadg.linux@gmail.com
State Accepted
Headers show
Series i2c: synquacer: Make synquacer_i2c_ops constant | expand

Commit Message

Nishka Dasgupta Aug. 19, 2019, 7:58 a.m. UTC
Static structure synquacer_i2c_ops, of type i2c_adapter, is only used
when it is copied into a field of another structure. It is not itself
modified. Hence make it const to protect it from unintended
modification.
Issue found with Coccinelle.

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

Comments

Wolfram Sang Sept. 3, 2019, 6:05 p.m. UTC | #1
On Mon, Aug 19, 2019 at 01:28:54PM +0530, Nishka Dasgupta wrote:
> Static structure synquacer_i2c_ops, of type i2c_adapter, is only used
> when it is copied into a field of another structure. It is not itself
> modified. Hence make it const to protect it from unintended
> modification.
> Issue found with Coccinelle.
> 
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> ---

Ard, are you okay with this patch?

>  drivers/i2c/busses/i2c-synquacer.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-synquacer.c b/drivers/i2c/busses/i2c-synquacer.c
> index f724c8e6b360..39762f0611b1 100644
> --- a/drivers/i2c/busses/i2c-synquacer.c
> +++ b/drivers/i2c/busses/i2c-synquacer.c
> @@ -526,7 +526,7 @@ static const struct i2c_algorithm synquacer_i2c_algo = {
>  	.functionality	= synquacer_i2c_functionality,
>  };
>  
> -static struct i2c_adapter synquacer_i2c_ops = {
> +static const struct i2c_adapter synquacer_i2c_ops = {
>  	.owner		= THIS_MODULE,
>  	.name		= "synquacer_i2c-adapter",
>  	.algo		= &synquacer_i2c_algo,
> -- 
> 2.19.1
>
Ard Biesheuvel Sept. 3, 2019, 6:15 p.m. UTC | #2
On Tue, 3 Sep 2019 at 11:05, Wolfram Sang <wsa@the-dreams.de> wrote:
>
> On Mon, Aug 19, 2019 at 01:28:54PM +0530, Nishka Dasgupta wrote:
> > Static structure synquacer_i2c_ops, of type i2c_adapter, is only used
> > when it is copied into a field of another structure. It is not itself
> > modified. Hence make it const to protect it from unintended
> > modification.
> > Issue found with Coccinelle.
> >
> > Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> > ---
>
> Ard, are you okay with this patch?
>

Yes, absolutely.

Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> >  drivers/i2c/busses/i2c-synquacer.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-synquacer.c b/drivers/i2c/busses/i2c-synquacer.c
> > index f724c8e6b360..39762f0611b1 100644
> > --- a/drivers/i2c/busses/i2c-synquacer.c
> > +++ b/drivers/i2c/busses/i2c-synquacer.c
> > @@ -526,7 +526,7 @@ static const struct i2c_algorithm synquacer_i2c_algo = {
> >       .functionality  = synquacer_i2c_functionality,
> >  };
> >
> > -static struct i2c_adapter synquacer_i2c_ops = {
> > +static const struct i2c_adapter synquacer_i2c_ops = {
> >       .owner          = THIS_MODULE,
> >       .name           = "synquacer_i2c-adapter",
> >       .algo           = &synquacer_i2c_algo,
> > --
> > 2.19.1
> >
Wolfram Sang Sept. 3, 2019, 6:17 p.m. UTC | #3
On Mon, Aug 19, 2019 at 01:28:54PM +0530, Nishka Dasgupta wrote:
> Static structure synquacer_i2c_ops, of type i2c_adapter, is only used
> when it is copied into a field of another structure. It is not itself
> modified. Hence make it const to protect it from unintended
> modification.
> Issue found with Coccinelle.
> 
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>

Applied to for-next, thanks!
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-synquacer.c b/drivers/i2c/busses/i2c-synquacer.c
index f724c8e6b360..39762f0611b1 100644
--- a/drivers/i2c/busses/i2c-synquacer.c
+++ b/drivers/i2c/busses/i2c-synquacer.c
@@ -526,7 +526,7 @@  static const struct i2c_algorithm synquacer_i2c_algo = {
 	.functionality	= synquacer_i2c_functionality,
 };
 
-static struct i2c_adapter synquacer_i2c_ops = {
+static const struct i2c_adapter synquacer_i2c_ops = {
 	.owner		= THIS_MODULE,
 	.name		= "synquacer_i2c-adapter",
 	.algo		= &synquacer_i2c_algo,