pinctrl: bcm2835: constify gpio_chip structure
Subsystems (4)
PATCH 1/1 pinctrl: bcm2835: constify gpio_chip structure
This structure is only used to copy into other structure, so declare it as const.
This issue was detected using Coccinelle and the following semantic patch:
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct gpio_chip i at p = { ... };
@ok@
identifier r.i;
expression e;
position p;
@@
e = i at p;
@bad@
position p != {r.p,ok.p};
identifier r.i;
struct gpio_chip e;
@@
e at i@p
@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
struct gpio_chip i = { ... };
In the following log you can see a significant difference in the code size and data segment, hence in the dec segment. This log is the output of the size command, before and after the code change:
before:
text data bss dec hex filename 18958 9000 128 28086 6db6 drivers/pinctrl/bcm/pinctrl-bcm2835.o
after:
text data bss dec hex filename 18764 8912 128 27804 6c9c drivers/pinctrl/bcm/pinctrl-bcm2835.o
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +1 -1
@@ -353,7 +353,7 @@ static int bcm2835_gpio_direction_output(struct gpio_chip *chip,return pinctrl_gpio_direction_output (chip->base + offset); } -static struct gpio_chip bcm2835_gpio_chip = { +static const struct gpio_chip bcm2835_gpio_chip = { .label =MODULE_NAME , .owner =THIS_MODULE , .request = gpiochip_generic_request,
Signature · 1 line
2.5.0
Quoted 4 lines · Gustavo A. R. Silva
This structure is only used to copy into other structure, so declare it as const.
This issue was detected using Coccinelle and the following semantic patch:
Quoted 19 lines
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pinctrl/bcm/pinctrl-bcm2835.c +1
-1@@ -353,7 +353,7 @@ static int bcm2835_gpio_direction_output(struct gpio_chip *chip,return pinctrl_gpio_direction_output (chip->base + offset); } -static struct gpio_chip bcm2835_gpio_chip = { +static const struct gpio_chip bcm2835_gpio_chip = { .label =MODULE_NAME , .owner =THIS_MODULE , .request = gpiochip_generic_request,Signature · 1 line
2.5.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170712/1e036ba0/attachment.sig>
Quoted 7 lines · Eric Anholt
Quoted 4 lines · Gustavo A. R. Silva
This structure is only used to copy into other structure, so declare it as const.
This issue was detected using Coccinelle and the following semantic patch:
Acked-by Eric Anholt <[email protected]>
Thank you, Eric
Quoted 19 lines
Quoted 19 lines
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pinctrl/bcm/pinctrl-bcm2835.c +1
-1@@ -353,7 +353,7 @@ static int bcm2835_gpio_direction_output(struct gpio_chip *chip,return pinctrl_gpio_direction_output (chip->base + offset); } -static struct gpio_chip bcm2835_gpio_chip = { +static const struct gpio_chip bcm2835_gpio_chip = { .label =MODULE_NAME , .owner =THIS_MODULE , .request = gpiochip_generic_request,Signature · 1 line
2.5.0
Signature · 1 line
Gustavo A. R. Silva
Quoted 37 lines · Gustavo A. R. Silva
This structure is only used to copy into other structure, so declare it as const.
This issue was detected using Coccinelle and the following semantic patch:
@r disable optional_qualifier@
identifier i;
position p;
@@
static structgpio_chipi at p = { ... };@ok@
identifier r.i;
expression e;
position p;
@@
e = i at p;@bad@
position p != {r.p,ok.p};
identifier r.i;
structgpio_chipe;
@@
e at i@p@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
structgpio_chipi = { ... };In the following log you can see a significant difference in the code size and data segment, hence in the dec segment. This log is the output of the size command, before and after the code change:
before:
Quoted 8 lines
text data bss dec hex filename 18958 9000 128 28086 6db6 drivers/pinctrl/bcm/pinctrl-bcm2835.oafter:
text data bss dec hex filename 18764 8912 128 27804 6c9c drivers/pinctrl/bcm/pinctrl-bcm2835.oSigned-off-by Gustavo A. R. Silva <[email protected]>
Patch applied with Eric's ACK.
Yours,
Linus Walleij