* [PATCH] mfd: twl4030-irq: remove unnecessary static in twl4030_init_irq()
@ 2017-07-17 16:26 Gustavo A. R. Silva
2017-07-18 8:45 ` Lee Jones
0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2017-07-17 16:26 UTC (permalink / raw)
To: Tony Lindgren, Lee Jones; +Cc: linux-omap, linux-kernel, Gustavo A. R. Silva
Remove unnecessary static on local variable twl4030_irq_chip.
Such variable is initialized before being used, on every
execution path throughout the function. The static has no
benefit and, removing it reduces the object file size.
This issue was detected using Coccinelle and the following semantic patch:
@bad exists@
position p;
identifier x;
type T;
@@
static T x@p;
...
x = <+...x...+>
@@
identifier x;
expression e;
type T;
position p != bad.p;
@@
-static
T x@p;
... when != x
when strict
?x = e;
In the following log you can see a significant difference in the object
file size. This log is the output of the size command, before and after
the code change:
before:
text data bss dec hex filename
7076 2400 640 10116 2784 drivers/mfd/twl4030-irq.o
after:
text data bss dec hex filename
7119 2344 320 9783 2637 drivers/mfd/twl4030-irq.o
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/mfd/twl4030-irq.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index 378c02d..65d5500 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -685,7 +685,7 @@ int twl4030_sih_setup(struct device *dev, int module, int irq_base)
int twl4030_init_irq(struct device *dev, int irq_num)
{
- static struct irq_chip twl4030_irq_chip;
+ struct irq_chip twl4030_irq_chip;
int status, i;
int irq_base, irq_end, nr_irqs;
struct device_node *node = dev->of_node;
--
2.5.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] mfd: twl4030-irq: remove unnecessary static in twl4030_init_irq()
2017-07-17 16:26 [PATCH] mfd: twl4030-irq: remove unnecessary static in twl4030_init_irq() Gustavo A. R. Silva
@ 2017-07-18 8:45 ` Lee Jones
0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2017-07-18 8:45 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: Tony Lindgren, linux-omap, linux-kernel
On Mon, 17 Jul 2017, Gustavo A. R. Silva wrote:
> Remove unnecessary static on local variable twl4030_irq_chip.
> Such variable is initialized before being used, on every
> execution path throughout the function. The static has no
> benefit and, removing it reduces the object file size.
>
> This issue was detected using Coccinelle and the following semantic patch:
>
> @bad exists@
> position p;
> identifier x;
> type T;
> @@
>
> static T x@p;
> ...
> x = <+...x...+>
>
> @@
> identifier x;
> expression e;
> type T;
> position p != bad.p;
> @@
>
> -static
> T x@p;
> ... when != x
> when strict
> ?x = e;
>
> In the following log you can see a significant difference in the object
> file size. This log is the output of the size command, before and after
> the code change:
>
> before:
> text data bss dec hex filename
> 7076 2400 640 10116 2784 drivers/mfd/twl4030-irq.o
>
> after:
> text data bss dec hex filename
> 7119 2344 320 9783 2637 drivers/mfd/twl4030-irq.o
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> drivers/mfd/twl4030-irq.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
Applied, thanks.
> diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
> index 378c02d..65d5500 100644
> --- a/drivers/mfd/twl4030-irq.c
> +++ b/drivers/mfd/twl4030-irq.c
> @@ -685,7 +685,7 @@ int twl4030_sih_setup(struct device *dev, int module, int irq_base)
>
> int twl4030_init_irq(struct device *dev, int irq_num)
> {
> - static struct irq_chip twl4030_irq_chip;
> + struct irq_chip twl4030_irq_chip;
> int status, i;
> int irq_base, irq_end, nr_irqs;
> struct device_node *node = dev->of_node;
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-07-18 8:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-17 16:26 [PATCH] mfd: twl4030-irq: remove unnecessary static in twl4030_init_irq() Gustavo A. R. Silva
2017-07-18 8:45 ` Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox