linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] constify i2c_adapter_quirks structures
@ 2016-10-15 17:32 Julia Lawall
  2016-10-15 17:32 ` [PATCH 1/2] i2c: bcm-iproc: " Julia Lawall
  2016-10-15 17:32 ` [PATCH 2/2] i2c: " Julia Lawall
  0 siblings, 2 replies; 5+ messages in thread
From: Julia Lawall @ 2016-10-15 17:32 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: kernel-janitors, Wolfram Sang, linux-i2c, linux-kernel

Constify i2c_adapter_quirks structures.

---

 drivers/i2c/busses/i2c-axxia.c      |    2 +-
 drivers/i2c/busses/i2c-bcm-iproc.c  |    2 +-
 drivers/i2c/busses/i2c-dln2.c       |    2 +-
 drivers/i2c/busses/i2c-viperboard.c |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] i2c: bcm-iproc: constify i2c_adapter_quirks structures
  2016-10-15 17:32 [PATCH 0/2] constify i2c_adapter_quirks structures Julia Lawall
@ 2016-10-15 17:32 ` Julia Lawall
  2016-10-17 17:49   ` Ray Jui
  2016-10-15 17:32 ` [PATCH 2/2] i2c: " Julia Lawall
  1 sibling, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2016-10-15 17:32 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Scott Branden, Jon Mason, Ray Jui, kernel-janitors, linux-kernel,
	bcm-kernel-feedback-list, linux-i2c, linux-arm-kernel

Check for i2c_adapter_quirks structures that are only stored in the
quirks field of an i2c_adapter structure.  This field is declared
const, so i2c_adapter_quirks structures that have this property can be
declared as const also.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct i2c_adapter_quirks i@p = { ... };

@ok@
identifier r.i;
struct i2c_adapter e;
position p;
@@
e.quirks = &i@p;

@bad@
position p != {r.p,ok.p};
identifier r.i;
struct i2c_adapter_quirks e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct i2c_adapter_quirks i = { ... };
// </smpl>

The effect on the layout of the .o file is shown by the following
output of the size command, first before then after the
transformation:

   text    data     bss     dec     hex filename
   3458     744       8    4210    1072 drivers/i2c/busses/i2c-bcm-iproc.o
   3490     720       8    4218    107a drivers/i2c/busses/i2c-bcm-iproc.o

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/i2c/busses/i2c-bcm-iproc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c b/drivers/i2c/busses/i2c-bcm-iproc.c
index 326b3db..318df55 100644
--- a/drivers/i2c/busses/i2c-bcm-iproc.c
+++ b/drivers/i2c/busses/i2c-bcm-iproc.c
@@ -395,7 +395,7 @@ static uint32_t bcm_iproc_i2c_functionality(struct i2c_adapter *adap)
 	.functionality = bcm_iproc_i2c_functionality,
 };
 
-static struct i2c_adapter_quirks bcm_iproc_i2c_quirks = {
+static const struct i2c_adapter_quirks bcm_iproc_i2c_quirks = {
 	/* need to reserve one byte in the FIFO for the slave address */
 	.max_read_len = M_TX_RX_FIFO_SIZE - 1,
 };

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] i2c: constify i2c_adapter_quirks structures
  2016-10-15 17:32 [PATCH 0/2] constify i2c_adapter_quirks structures Julia Lawall
  2016-10-15 17:32 ` [PATCH 1/2] i2c: bcm-iproc: " Julia Lawall
@ 2016-10-15 17:32 ` Julia Lawall
  2016-11-18  1:00   ` [2/2] " Wolfram Sang
  1 sibling, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2016-10-15 17:32 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: kernel-janitors, linux-i2c, linux-kernel

Check for i2c_adapter_quirks structures that are only stored in the
quirks field of an i2c_adapter structure.  This field is declared
const, so i2c_adapter_quirks structures that have this property can be
declared as const also.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct i2c_adapter_quirks i@p = { ... };

@ok@
identifier r.i;
struct i2c_adapter e;
position p;
@@
e.quirks = &i@p;

@bad@
position p != {r.p,ok.p};
identifier r.i;
struct i2c_adapter_quirks e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct i2c_adapter_quirks i = { ... };
// </smpl>

The effect on the layout of the .o files is shown by the following
output of the size command, first before then after the
transformation:

   text    data     bss     dec     hex filename
   3651     472       8    4131    1023 drivers/i2c/busses/i2c-axxia.o
   3683     440       8    4131    1023 drivers/i2c/busses/i2c-axxia.o

   text    data     bss     dec     hex filename
   1069     216       0    1285     505 drivers/i2c/busses/i2c-dln2.o
   1101     192       0    1293     50d drivers/i2c/busses/i2c-dln2.o

   text    data     bss     dec     hex filename
   3211     484       1    3696     e70 drivers/i2c/busses/i2c-viperboard.o
   3243     460       1    3704     e78 drivers/i2c/busses/i2c-viperboard.o

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/i2c/busses/i2c-axxia.c      |    2 +-
 drivers/i2c/busses/i2c-dln2.c       |    2 +-
 drivers/i2c/busses/i2c-viperboard.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-axxia.c b/drivers/i2c/busses/i2c-axxia.c
index 4351a93..13f0748 100644
--- a/drivers/i2c/busses/i2c-axxia.c
+++ b/drivers/i2c/busses/i2c-axxia.c
@@ -489,7 +489,7 @@ static u32 axxia_i2c_func(struct i2c_adapter *adap)
 	.functionality = axxia_i2c_func,
 };
 
-static struct i2c_adapter_quirks axxia_i2c_quirks = {
+static const struct i2c_adapter_quirks axxia_i2c_quirks = {
 	.max_read_len = 255,
 	.max_write_len = 255,
 };
diff --git a/drivers/i2c/busses/i2c-dln2.c b/drivers/i2c/busses/i2c-dln2.c
index 8acda2a..69075a3 100644
--- a/drivers/i2c/busses/i2c-dln2.c
+++ b/drivers/i2c/busses/i2c-dln2.c
@@ -182,7 +182,7 @@ static u32 dln2_i2c_func(struct i2c_adapter *a)
 	.functionality = dln2_i2c_func,
 };
 
-static struct i2c_adapter_quirks dln2_i2c_quirks = {
+static const struct i2c_adapter_quirks dln2_i2c_quirks = {
 	.max_read_len = DLN2_I2C_MAX_XFER_SIZE,
 	.max_write_len = DLN2_I2C_MAX_XFER_SIZE,
 };
diff --git a/drivers/i2c/busses/i2c-viperboard.c b/drivers/i2c/busses/i2c-viperboard.c
index 543456a..e4be86b 100644
--- a/drivers/i2c/busses/i2c-viperboard.c
+++ b/drivers/i2c/busses/i2c-viperboard.c
@@ -354,7 +354,7 @@ static u32 vprbrd_i2c_func(struct i2c_adapter *i2c)
 	.functionality	= vprbrd_i2c_func,
 };
 
-static struct i2c_adapter_quirks vprbrd_quirks = {
+static const struct i2c_adapter_quirks vprbrd_quirks = {
 	.max_read_len = 2048,
 	.max_write_len = 2048,
 };

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] i2c: bcm-iproc: constify i2c_adapter_quirks structures
  2016-10-15 17:32 ` [PATCH 1/2] i2c: bcm-iproc: " Julia Lawall
@ 2016-10-17 17:49   ` Ray Jui
  0 siblings, 0 replies; 5+ messages in thread
From: Ray Jui @ 2016-10-17 17:49 UTC (permalink / raw)
  To: Julia Lawall, Wolfram Sang
  Cc: kernel-janitors, Ray Jui, Scott Branden, Jon Mason,
	bcm-kernel-feedback-list, linux-i2c, linux-arm-kernel,
	linux-kernel

Hi Julia,

On 10/15/2016 10:32 AM, Julia Lawall wrote:
> Check for i2c_adapter_quirks structures that are only stored in the
> quirks field of an i2c_adapter structure.  This field is declared
> const, so i2c_adapter_quirks structures that have this property can be
> declared as const also.
>
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @r disable optional_qualifier@
> identifier i;
> position p;
> @@
> static struct i2c_adapter_quirks i@p = { ... };
>
> @ok@
> identifier r.i;
> struct i2c_adapter e;
> position p;
> @@
> e.quirks = &i@p;
>
> @bad@
> position p != {r.p,ok.p};
> identifier r.i;
> struct i2c_adapter_quirks e;
> @@
> e@i@p
>
> @depends on !bad disable optional_qualifier@
> identifier r.i;
> @@
> static
> +const
>  struct i2c_adapter_quirks i = { ... };
> // </smpl>
>
> The effect on the layout of the .o file is shown by the following
> output of the size command, first before then after the
> transformation:
>
>    text    data     bss     dec     hex filename
>    3458     744       8    4210    1072 drivers/i2c/busses/i2c-bcm-iproc.o
>    3490     720       8    4218    107a drivers/i2c/busses/i2c-bcm-iproc.o
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---
>  drivers/i2c/busses/i2c-bcm-iproc.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c b/drivers/i2c/busses/i2c-bcm-iproc.c
> index 326b3db..318df55 100644
> --- a/drivers/i2c/busses/i2c-bcm-iproc.c
> +++ b/drivers/i2c/busses/i2c-bcm-iproc.c
> @@ -395,7 +395,7 @@ static uint32_t bcm_iproc_i2c_functionality(struct i2c_adapter *adap)
>  	.functionality = bcm_iproc_i2c_functionality,
>  };
>
> -static struct i2c_adapter_quirks bcm_iproc_i2c_quirks = {
> +static const struct i2c_adapter_quirks bcm_iproc_i2c_quirks = {
>  	/* need to reserve one byte in the FIFO for the slave address */
>  	.max_read_len = M_TX_RX_FIFO_SIZE - 1,
>  };
>

Change looks good. Thanks.

Acked-by: Ray Jui <ray.jui@broadcom.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [2/2] i2c: constify i2c_adapter_quirks structures
  2016-10-15 17:32 ` [PATCH 2/2] i2c: " Julia Lawall
@ 2016-11-18  1:00   ` Wolfram Sang
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2016-11-18  1:00 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Wolfram Sang, kernel-janitors, linux-i2c, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1805 bytes --]

On Sat, Oct 15, 2016 at 07:32:02PM +0200, Julia Lawall wrote:
> Check for i2c_adapter_quirks structures that are only stored in the
> quirks field of an i2c_adapter structure.  This field is declared
> const, so i2c_adapter_quirks structures that have this property can be
> declared as const also.
> 
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @r disable optional_qualifier@
> identifier i;
> position p;
> @@
> static struct i2c_adapter_quirks i@p = { ... };
> 
> @ok@
> identifier r.i;
> struct i2c_adapter e;
> position p;
> @@
> e.quirks = &i@p;
> 
> @bad@
> position p != {r.p,ok.p};
> identifier r.i;
> struct i2c_adapter_quirks e;
> @@
> e@i@p
> 
> @depends on !bad disable optional_qualifier@
> identifier r.i;
> @@
> static
> +const
>  struct i2c_adapter_quirks i = { ... };
> // </smpl>
> 
> The effect on the layout of the .o files is shown by the following
> output of the size command, first before then after the
> transformation:
> 
>    text    data     bss     dec     hex filename
>    3651     472       8    4131    1023 drivers/i2c/busses/i2c-axxia.o
>    3683     440       8    4131    1023 drivers/i2c/busses/i2c-axxia.o
> 
>    text    data     bss     dec     hex filename
>    1069     216       0    1285     505 drivers/i2c/busses/i2c-dln2.o
>    1101     192       0    1293     50d drivers/i2c/busses/i2c-dln2.o
> 
>    text    data     bss     dec     hex filename
>    3211     484       1    3696     e70 drivers/i2c/busses/i2c-viperboard.o
>    3243     460       1    3704     e78 drivers/i2c/busses/i2c-viperboard.o
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Squashed with the other similar patch and applied to for-next, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-11-18  1:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-15 17:32 [PATCH 0/2] constify i2c_adapter_quirks structures Julia Lawall
2016-10-15 17:32 ` [PATCH 1/2] i2c: bcm-iproc: " Julia Lawall
2016-10-17 17:49   ` Ray Jui
2016-10-15 17:32 ` [PATCH 2/2] i2c: " Julia Lawall
2016-11-18  1:00   ` [2/2] " Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).