* [PATCH] gpio: gpio-stmpe: make various char arrays static const, shrinks object size
@ 2017-11-28 18:23 Colin King
2017-11-29 8:19 ` walter harms
2017-12-02 12:05 ` Linus Walleij
0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2017-11-28 18:23 UTC (permalink / raw)
To: Linus Walleij, linux-gpio; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Don't populate the read-only arrays edge_det_values, rise_values and
fall_values on the stack but instead make them static and constify them.
Makes the object code smaller by over 240 bytes:
Before:
text data bss dec hex filename
9525 2520 192 12237 2fcd drivers/gpio/gpio-stmpe.o
After:
text data bss dec hex filename
9025 2776 192 11993 2ed9 drivers/gpio/gpio-stmpe.o
(gcc version 7.2.0 x86_64)
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/gpio/gpio-stmpe.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
index e6e5cca624a7..e3d048e65339 100644
--- a/drivers/gpio/gpio-stmpe.c
+++ b/drivers/gpio/gpio-stmpe.c
@@ -273,15 +273,21 @@ static void stmpe_dbg_show_one(struct seq_file *s,
u8 fall_reg;
u8 irqen_reg;
- char *edge_det_values[] = {"edge-inactive",
- "edge-asserted",
- "not-supported"};
- char *rise_values[] = {"no-rising-edge-detection",
- "rising-edge-detection",
- "not-supported"};
- char *fall_values[] = {"no-falling-edge-detection",
- "falling-edge-detection",
- "not-supported"};
+ static const char * const edge_det_values[] = {
+ "edge-inactive",
+ "edge-asserted",
+ "not-supported"
+ };
+ static const char * const rise_values[] = {
+ "no-rising-edge-detection",
+ "rising-edge-detection",
+ "not-supported"
+ };
+ static const char * const fall_values[] = {
+ "no-falling-edge-detection",
+ "falling-edge-detection",
+ "not-supported"
+ };
#define NOT_SUPPORTED_IDX 2
u8 edge_det = NOT_SUPPORTED_IDX;
u8 rise = NOT_SUPPORTED_IDX;
--
2.14.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] gpio: gpio-stmpe: make various char arrays static const, shrinks object size
2017-11-28 18:23 [PATCH] gpio: gpio-stmpe: make various char arrays static const, shrinks object size Colin King
@ 2017-11-29 8:19 ` walter harms
2017-12-02 12:05 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: walter harms @ 2017-11-29 8:19 UTC (permalink / raw)
To: Colin King; +Cc: Linus Walleij, linux-gpio, kernel-janitors, linux-kernel
Am 28.11.2017 19:23, schrieb Colin King:
> From: Colin Ian King <colin.king@canonical.com>
>
> Don't populate the read-only arrays edge_det_values, rise_values and
> fall_values on the stack but instead make them static and constify them.
> Makes the object code smaller by over 240 bytes:
>
> Before:
> text data bss dec hex filename
> 9525 2520 192 12237 2fcd drivers/gpio/gpio-stmpe.o
>
> After:
> text data bss dec hex filename
> 9025 2776 192 11993 2ed9 drivers/gpio/gpio-stmpe.o
>
> (gcc version 7.2.0 x86_64)
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/gpio/gpio-stmpe.c | 24 +++++++++++++++---------
> 1 file changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
> index e6e5cca624a7..e3d048e65339 100644
> --- a/drivers/gpio/gpio-stmpe.c
> +++ b/drivers/gpio/gpio-stmpe.c
> @@ -273,15 +273,21 @@ static void stmpe_dbg_show_one(struct seq_file *s,
> u8 fall_reg;
> u8 irqen_reg;
>
> - char *edge_det_values[] = {"edge-inactive",
> - "edge-asserted",
> - "not-supported"};
> - char *rise_values[] = {"no-rising-edge-detection",
> - "rising-edge-detection",
> - "not-supported"};
> - char *fall_values[] = {"no-falling-edge-detection",
> - "falling-edge-detection",
> - "not-supported"};
> + static const char * const edge_det_values[] = {
> + "edge-inactive",
> + "edge-asserted",
> + "not-supported"
> + };
> + static const char * const rise_values[] = {
> + "no-rising-edge-detection",
> + "rising-edge-detection",
> + "not-supported"
> + };
> + static const char * const fall_values[] = {
> + "no-falling-edge-detection",
> + "falling-edge-detection",
> + "not-supported"
> + };
> #define NOT_SUPPORTED_IDX 2
@maintainer:
the define here is hard to find, perhaps i should be move to a place
where i can be found more easily. Like the beginning of line.
re,
wh
> u8 edge_det = NOT_SUPPORTED_IDX;
> u8 rise = NOT_SUPPORTED_IDX;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gpio: gpio-stmpe: make various char arrays static const, shrinks object size
2017-11-28 18:23 [PATCH] gpio: gpio-stmpe: make various char arrays static const, shrinks object size Colin King
2017-11-29 8:19 ` walter harms
@ 2017-12-02 12:05 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2017-12-02 12:05 UTC (permalink / raw)
To: Colin King; +Cc: linux-gpio, kernel-janitors, linux-kernel
On Tue, Nov 28, 2017 at 7:23 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Don't populate the read-only arrays edge_det_values, rise_values and
> fall_values on the stack but instead make them static and constify them.
> Makes the object code smaller by over 240 bytes:
>
> Before:
> text data bss dec hex filename
> 9525 2520 192 12237 2fcd drivers/gpio/gpio-stmpe.o
>
> After:
> text data bss dec hex filename
> 9025 2776 192 11993 2ed9 drivers/gpio/gpio-stmpe.o
>
> (gcc version 7.2.0 x86_64)
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-02 12:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-28 18:23 [PATCH] gpio: gpio-stmpe: make various char arrays static const, shrinks object size Colin King
2017-11-29 8:19 ` walter harms
2017-12-02 12:05 ` Linus Walleij
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).