drivers/char/sonypi.c: make 3 structs static
Subsystems (2)
PATCH 1/1 drivers/char/sonypi.c: make 3 structs static
This patch makes three needlessly global structs static.
---
drivers/char/sonypi.c | 76 +++++++++++++++++++++++++++++++++++++++++- drivers/char/sonypi.h | 74 ---------------------------------------- 2 files changed, 75 insertions(+), 75 deletions(-)
drivers/char/sonypi.h renamed from drivers/char/sonypi.h.old +0 -74
@@ -304,86 +304,12 @@ { 0, 0 } }; -struct sonypi_eventtypes { -int model; -u8 data; -unsigned long mask; -struct sonypi_event * events; -} sonypi_eventtypes[] = { - {SONYPI_DEVICE_MODEL_TYPE1 ,0 ,0xffffffff , sonypi_releaseev }, - {SONYPI_DEVICE_MODEL_TYPE1 ,0x70 ,SONYPI_MEYE_MASK , sonypi_meyeev }, - {SONYPI_DEVICE_MODEL_TYPE1 ,0x30 ,SONYPI_LID_MASK , sonypi_lidev }, - {SONYPI_DEVICE_MODEL_TYPE1 ,0x60 ,SONYPI_CAPTURE_MASK , sonypi_captureev }, - {SONYPI_DEVICE_MODEL_TYPE1 ,0x10 ,SONYPI_JOGGER_MASK , sonypi_joggerev }, - {SONYPI_DEVICE_MODEL_TYPE1 ,0x20 ,SONYPI_FNKEY_MASK , sonypi_fnkeyev }, - {SONYPI_DEVICE_MODEL_TYPE1 ,0x30 ,SONYPI_BLUETOOTH_MASK , sonypi_blueev }, - {SONYPI_DEVICE_MODEL_TYPE1 ,0x40 ,SONYPI_PKEY_MASK , sonypi_pkeyev }, - {SONYPI_DEVICE_MODEL_TYPE1 ,0x30 ,SONYPI_MEMORYSTICK_MASK , sonypi_memorystickev }, - {SONYPI_DEVICE_MODEL_TYPE1 ,0x40 ,SONYPI_BATTERY_MASK , sonypi_batteryev }, - - {SONYPI_DEVICE_MODEL_TYPE2 ,0 ,0xffffffff , sonypi_releaseev }, - {SONYPI_DEVICE_MODEL_TYPE2 ,0x38 ,SONYPI_LID_MASK , sonypi_lidev }, - {SONYPI_DEVICE_MODEL_TYPE2 ,0x11 ,SONYPI_JOGGER_MASK , sonypi_joggerev }, - {SONYPI_DEVICE_MODEL_TYPE2 ,0x61 ,SONYPI_CAPTURE_MASK , sonypi_captureev }, - {SONYPI_DEVICE_MODEL_TYPE2 ,0x21 ,SONYPI_FNKEY_MASK , sonypi_fnkeyev }, - {SONYPI_DEVICE_MODEL_TYPE2 ,0x31 ,SONYPI_BLUETOOTH_MASK , sonypi_blueev }, - {SONYPI_DEVICE_MODEL_TYPE2 ,0x08 ,SONYPI_PKEY_MASK , sonypi_pkeyev }, - {SONYPI_DEVICE_MODEL_TYPE2 ,0x11 ,SONYPI_BACK_MASK , sonypi_backev }, - {SONYPI_DEVICE_MODEL_TYPE2 ,0x08 ,SONYPI_HELP_MASK , sonypi_helpev }, - {SONYPI_DEVICE_MODEL_TYPE2 ,0x21 ,SONYPI_ZOOM_MASK , sonypi_zoomev }, - {SONYPI_DEVICE_MODEL_TYPE2 ,0x20 ,SONYPI_THUMBPHRASE_MASK , sonypi_thumbphraseev }, - {SONYPI_DEVICE_MODEL_TYPE2 ,0x31 ,SONYPI_MEMORYSTICK_MASK , sonypi_memorystickev }, - {SONYPI_DEVICE_MODEL_TYPE2 ,0x41 ,SONYPI_BATTERY_MASK , sonypi_batteryev }, - {SONYPI_DEVICE_MODEL_TYPE2 ,0x31 ,SONYPI_PKEY_MASK , sonypi_pkeyev }, - - {0 } -}; -#define SONYPI_BUF_SIZE 128/* The name of the devices for the input device drivers */ #define SONYPI_JOG_INPUTNAME "Sony Vaio Jogdial"#define SONYPI_KEY_INPUTNAME "Sony Vaio Keys" -/* Correspondance table between sonypi events and input layer events */ -struct { -int sonypiev; -int inputev; -} sonypi_inputkeys[] = { - {SONYPI_EVENT_CAPTURE_PRESSED ,KEY_CAMERA }, - {SONYPI_EVENT_FNKEY_ONLY ,KEY_FN }, - {SONYPI_EVENT_FNKEY_ESC ,KEY_FN_ESC }, - {SONYPI_EVENT_FNKEY_F1 ,KEY_FN_F1 }, - {SONYPI_EVENT_FNKEY_F2 ,KEY_FN_F2 }, - {SONYPI_EVENT_FNKEY_F3 ,KEY_FN_F3 }, - {SONYPI_EVENT_FNKEY_F4 ,KEY_FN_F4 }, - {SONYPI_EVENT_FNKEY_F5 ,KEY_FN_F5 }, - {SONYPI_EVENT_FNKEY_F6 ,KEY_FN_F6 }, - {SONYPI_EVENT_FNKEY_F7 ,KEY_FN_F7 }, - {SONYPI_EVENT_FNKEY_F8 ,KEY_FN_F8 }, - {SONYPI_EVENT_FNKEY_F9 ,KEY_FN_F9 }, - {SONYPI_EVENT_FNKEY_F10 ,KEY_FN_F10 }, - {SONYPI_EVENT_FNKEY_F11 ,KEY_FN_F11 }, - {SONYPI_EVENT_FNKEY_F12 ,KEY_FN_F12 }, - {SONYPI_EVENT_FNKEY_1 ,KEY_FN_1 }, - {SONYPI_EVENT_FNKEY_2 ,KEY_FN_2 }, - {SONYPI_EVENT_FNKEY_D ,KEY_FN_D }, - {SONYPI_EVENT_FNKEY_E ,KEY_FN_E }, - {SONYPI_EVENT_FNKEY_F ,KEY_FN_F }, - {SONYPI_EVENT_FNKEY_S ,KEY_FN_S }, - {SONYPI_EVENT_FNKEY_B ,KEY_FN_B }, - {SONYPI_EVENT_BLUETOOTH_PRESSED ,KEY_BLUE }, - {SONYPI_EVENT_BLUETOOTH_ON ,KEY_BLUE }, - {SONYPI_EVENT_PKEY_P1 ,KEY_PROG1 }, - {SONYPI_EVENT_PKEY_P2 ,KEY_PROG2 }, - {SONYPI_EVENT_PKEY_P3 ,KEY_PROG3 }, - {SONYPI_EVENT_BACK_PRESSED ,KEY_BACK }, - {SONYPI_EVENT_HELP_PRESSED ,KEY_HELP }, - {SONYPI_EVENT_ZOOM_PRESSED ,KEY_ZOOM }, - {SONYPI_EVENT_THUMBPHRASE_PRESSED ,BTN_THUMB }, - {0 ,0 }, -}; -struct sonypi_device {struct pci_dev *dev;struct platform_device *pdev;
drivers/char/sonypi.c renamed from drivers/char/sonypi.c.old +75 -1
88 lines not on this page · raw message
Quoted 9 lines · Adrian Bunk
This patch makes three needlessly global structs static.
Signed-off-by Adrian Bunk <[email protected]>---
drivers/char/sonypi.c | 76 +++++++++++++++++++++++++++++++++++++++++- drivers/char/sonypi.h | 74 ---------------------------------------- 2 files changed, 75 insertions(+), 75 deletions(-)
sonypi.h is a "local" header file used only by sonypi.c.
I would like to keep those tables in sonypi.h rather than putting all into sonypi.c (or we could as well remove sonypi.h and put all the contents into the .c).
What about:
sonypi.c | 2 +- sonypi.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/char/sonypi.h +2 -2
@@ -304,7 +304,7 @@ static struct sonypi_event sonypi_batter { 0, 0 } }; -struct sonypi_eventtypes { +static struct sonypi_eventtypes { int model; u8 data; unsigned long mask;
@@ -347,7 +347,7 @@ struct sonypi_eventtypes {#define SONYPI_KEY_INPUTNAME "Sony Vaio Keys"/* Correspondance table between sonypi events and input layer events */ -struct { +static struct {int sonypiev;int inputev; } sonypi_inputkeys[] = {
drivers/char/sonypi.c +1 -1
@@ -645,7 +645,7 @@ static struct file_operations sonypi_mis .ioctl = sonypi_misc_ioctl, }; -struct miscdevice sonypi_misc_device = { +static struct miscdevice sonypi_misc_device = { .minor =-1 , .name ="sonypi" , .fops = &sonypi_misc_fops,
Quoted 1 line
Signature · 1 line
Stelian Pop <[email protected]>
Quoted 12 lines · Stelian Pop
Quoted 9 lines · Adrian Bunk
This patch makes three needlessly global structs static.
Signed-off-by Adrian Bunk <[email protected]>---
drivers/char/sonypi.c | 76 +++++++++++++++++++++++++++++++++++++++++- drivers/char/sonypi.h | 74 ---------------------------------------- 2 files changed, 75 insertions(+), 75 deletions(-)
Quoted 8 lines
sonypi.his a "local" header file used only bysonypi.c.I would like to keep those tables in
sonypi.hrather than putting all intosonypi.c(or we could as well removesonypi.hand put all the contents into the .c).What about:
...
That's also OK with me.
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 7 lines · Stelian Pop
sonypi.his a "local" header file used only bysonypi.c.I would like to keep those tables in
sonypi.hrather than putting all intosonypi.c(or we could as well removesonypi.hand put all the contents into the .c).
Hi,
What is the point of having an .h file if it is not used by anyone? Judging by the fact that it completely protected by #ifdef __KERNEL__ there should be no userspace clients either.
I always thought that the only time .h is needed is when you define interface to your code. I'd fold it to sonpypi.c.
Signature · 1 line
Dmitry
Quoted 9 lines · Dmitry Torokhov
Quoted 7 lines · Stelian Pop
sonypi.his a "local" header file used only bysonypi.c.I would like to keep those tables in
sonypi.hrather than putting all intosonypi.c(or we could as well removesonypi.hand put all the contents into the .c).
Quoted 8 lines
Hi,
What is the point of having an .h file if it is not used by anyone? Judging by the fact that it completely protected by #ifdef
__KERNEL__there should be no userspace clients either.I always thought that the only time .h is needed is when you define interface to your code. I'd fold it to
sonpypi.c.
It isn't strictly *needed*, but it does separate a bit the data structures and the constants (in the .h) from the code (in the .c).
Stelian.
Signature · 1 line
Stelian Pop <[email protected]>
Quoted 17 lines · Stelian Pop
Quoted 15 lines · Dmitry Torokhov
Quoted 7 lines · Stelian Pop
sonypi.his a "local" header file used only bysonypi.c.I would like to keep those tables in
sonypi.hrather than putting all intosonypi.c(or we could as well removesonypi.hand put all the contents into the .c).Hi,
What is the point of having an .h file if it is not used by anyone? Judging by the fact that it completely protected by #ifdef
__KERNEL__there should be no userspace clients either.
Quoted 5 lines
Quoted 2 lines
I always thought that the only time .h is needed is when you define interface to your code. I'd fold it to
sonpypi.c.It isn't strictly *needed*, but it does separate a bit the data structures and the constants (in the .h) from the code (in the .c).
Right, but why is it a good thing? Is it more convenient to review/edit 2 files instead of one? And that header even defines (as opposed to declaring) bunch of static variables in header file. They are internal to the module, they do not form an _interface_.
Signature · 1 line
Dmitry