pinctrl: st: constify gpio_chip structure
Subsystems (3)
PATCH 1/1 pinctrl: st: 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 21671 3632 128 25431 6357 drivers/pinctrl/pinctrl-st.o
after:
text data bss dec hex filename 21366 3576 128 25070 61ee drivers/pinctrl/pinctrl-st.o
--- drivers/pinctrl/pinctrl-st.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/pinctrl-st.c +1 -1
@@ -1442,7 +1442,7 @@ static void st_gpio_irqmux_handler(struct irq_desc *desc)chained_irq_exit (chip, desc); } -static struct gpio_chip st_gpio_template = { +static const struct gpio_chip st_gpio_template = { .request = gpiochip_generic_request, .free = gpiochip_generic_free, .get = st_gpio_get,
Signature · 1 line
2.5.0
Hi Gustavo
Quoted 55 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:
text data bss dec hex filename 21671 3632 128 25431 6357 drivers/pinctrl/pinctrl-st.oafter:
text data bss dec hex filename 21366 3576 128 25070 61ee drivers/pinctrl/pinctrl-st.oSigned-off-by Gustavo A. R. Silva <[email protected]>--- drivers/pinctrl/pinctrl-st.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pinctrl/pinctrl-st.c +0
-0
drivers/pinctrl/pinctrl-st.c static void st_gpio_irqmux_handler(struct irq_desc *desc) · line 1448
Quoted 8 lines
drivers/pinctrl/pinctrl-st.c +1
-1@@ -1442,7 +1442,7 @@ static void st_gpio_irqmux_handler(struct irq_desc *desc)chained_irq_exit (chip, desc); } -static struct gpio_chip st_gpio_template = { +static const struct gpio_chip st_gpio_template = { .request = gpiochip_generic_request, .free = gpiochip_generic_free, .get = st_gpio_get,
Thanks
Hi Patrice,
Quoting Patrice CHOTARD <[email protected]>:
Quoted 70 lines
Hi Gustavo
Quoted 62 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:
text data bss dec hex filename 21671 3632 128 25431 6357 drivers/pinctrl/pinctrl-st.oafter:
text data bss dec hex filename 21366 3576 128 25070 61ee drivers/pinctrl/pinctrl-st.oSigned-off-by Gustavo A. R. Silva <[email protected]>--- drivers/pinctrl/pinctrl-st.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pinctrl/pinctrl-st.c +1
-1@@ -1442,7 +1442,7 @@ static void st_gpio_irqmux_handler(struct irq_desc *desc)chained_irq_exit (chip ,desc ); } -static struct gpio_chip st_gpio_template = { +static const struct gpio_chip st_gpio_template = { .request = gpiochip_generic_request, .free = gpiochip_generic_free,Quoted 2 lines
.get =
st_gpio_get,Acked-by Patrice Chotard <[email protected]>
Quoted 1 line
Thanks
Glad to help. :)
Thanks
--
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 21671 3632 128 25431 6357 drivers/pinctrl/pinctrl-st.oafter:
text data bss dec hex filename 21366 3576 128 25070 61ee drivers/pinctrl/pinctrl-st.oSigned-off-by Gustavo A. R. Silva <[email protected]>
Patch applied with Patrice's ACK.
Yours,
Linus Walleij