* [PATCH v2] sony-laptop: constify spic_attribute_group and sony_laptop_input_index.
@ 2017-06-30 5:09 Arvind Yadav
2017-06-30 16:13 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Arvind Yadav @ 2017-06-30 5:09 UTC (permalink / raw)
To: malattia, dvhart, andy; +Cc: platform-driver-x86, linux-kernel
attribute_groups are not supposed to change at runtime. All functions
working with attribute_groups provided by <linux/sysfs.h> work with const
attribute_group. So mark the non-const structs as const.
File size before:
text data bss dec hex filename
31273 5176 372 36821 8fd5 drivers/platform/x86/sony-laptop.o
File size After adding 'const':
text data bss dec hex filename
31337 5112 372 36821 8fd5 drivers/platform/x86/sony-laptop.o
Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
Changes in v2:
Resolve warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-array-qualifiers]
key_dev->keycode = &sony_laptop_input_keycode_map;
drivers/platform/x86/sony-laptop.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index aa2ee51..bfae795 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -222,7 +222,7 @@ struct sony_laptop_keypress {
/* Correspondance table between sonypi events
* and input layer indexes in the keymap
*/
-static int sony_laptop_input_index[] = {
+static const int sony_laptop_input_index[] = {
-1, /* 0 no event */
-1, /* 1 SONYPI_EVENT_JOGDIAL_DOWN */
-1, /* 2 SONYPI_EVENT_JOGDIAL_UP */
@@ -4032,7 +4032,7 @@ struct device_attribute spic_attr_##_name = __ATTR(_name, \
NULL
};
-static struct attribute_group spic_attribute_group = {
+static const struct attribute_group spic_attribute_group = {
.attrs = spic_attributes
};
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] sony-laptop: constify spic_attribute_group and sony_laptop_input_index.
2017-06-30 5:09 [PATCH v2] sony-laptop: constify spic_attribute_group and sony_laptop_input_index Arvind Yadav
@ 2017-06-30 16:13 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2017-06-30 16:13 UTC (permalink / raw)
To: Arvind Yadav
Cc: Mattia Dongili, dvhart, Andy Shevchenko, Platform Driver, linux-kernel
On Fri, Jun 30, 2017 at 8:09 AM, Arvind Yadav <arvind.yadav.cs@gmail.com> wrote:
> attribute_groups are not supposed to change at runtime. All functions
> working with attribute_groups provided by <linux/sysfs.h> work with const
> attribute_group. So mark the non-const structs as const.
>
> File size before:
> text data bss dec hex filename
> 31273 5176 372 36821 8fd5 drivers/platform/x86/sony-laptop.o
>
> File size After adding 'const':
> text data bss dec hex filename
> 31337 5112 372 36821 8fd5 drivers/platform/x86/sony-laptop.o
>
A bit late, Arnd's patch has been applied. Please, test it beforehand next time.
Thanks.
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
> Changes in v2:
> Resolve warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-array-qualifiers]
> key_dev->keycode = &sony_laptop_input_keycode_map;
>
> drivers/platform/x86/sony-laptop.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
> index aa2ee51..bfae795 100644
> --- a/drivers/platform/x86/sony-laptop.c
> +++ b/drivers/platform/x86/sony-laptop.c
> @@ -222,7 +222,7 @@ struct sony_laptop_keypress {
> /* Correspondance table between sonypi events
> * and input layer indexes in the keymap
> */
> -static int sony_laptop_input_index[] = {
> +static const int sony_laptop_input_index[] = {
> -1, /* 0 no event */
> -1, /* 1 SONYPI_EVENT_JOGDIAL_DOWN */
> -1, /* 2 SONYPI_EVENT_JOGDIAL_UP */
> @@ -4032,7 +4032,7 @@ struct device_attribute spic_attr_##_name = __ATTR(_name, \
> NULL
> };
>
> -static struct attribute_group spic_attribute_group = {
> +static const struct attribute_group spic_attribute_group = {
> .attrs = spic_attributes
> };
>
> --
> 1.9.1
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-30 16:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-30 5:09 [PATCH v2] sony-laptop: constify spic_attribute_group and sony_laptop_input_index Arvind Yadav
2017-06-30 16:13 ` Andy Shevchenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.