Re: [PATCH] i2c: busses: make i2c_adapter_quirks const

From: Wolfram Sang
Date: Tue Aug 29 2017 - 16:33:47 EST


On Mon, Aug 21, 2017 at 05:42:04PM +0530, Bhumika Goyal wrote:
> Make these const as they are only stored as a reference in the quirks
> field of an i2c_adapter structure, which is const.
>
> Done using Coccinelle:
> @match disable optional_qualifier@
> identifier s;
> @@
> static struct i2c_adapter_quirks s = {...};
>
> @ref@
> position p;
> identifier match.s;
> @@
> s@p
>
> @good1@
> identifier y;
> position ref.p;
> identifier match.s;
> @@
> struct i2c_adapter y = {...,.quirks=&s@p,...};
>
> @good2@
> struct i2c_adapter y;
> identifier match.s;
> position ref.p;
> @@
> y.quirks = &s@p
>
> @bad depends on !good1 && !good2@
> position ref.p;
> identifier match.s;
> @@
> s@p
>
> @depends on forall !bad disable optional_qualifier@
> identifier match.s;
> @@
> static
> + const
> struct i2c_adapter_quirks s;
>
> Signed-off-by: Bhumika Goyal <bhumirks@xxxxxxxxx>

Removed the cocci script from the commit message and applied to
for-next, thanks!

Attachment: signature.asc
Description: PGP signature