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(-)
--- linux-2.6.11-rc2-mm2-full/drivers/char/sonypi.h.old 2005-01-31 15:34:19.000000000 +0100
+++ linux-2.6.11-rc2-mm2-full/drivers/char/sonypi.h 2005-01-31 15:37:10.000000000 +0100
@@ -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;
--- linux-2.6.11-rc2-mm2-full/drivers/char/sonypi.c.old 2005-01-31 15:34:30.000000000 +0100
+++ linux-2.6.11-rc2-mm2-full/drivers/char/sonypi.c 2005-01-31 15:37:35.000000000 +0100
@@ -53,6 +53,80 @@
#include "sonypi.h"
#include <linux/sonypi.h>
+static 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 }
+};
+
+/* Correspondance table between sonypi events and input layer events */
+static 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 },
+};
+
MODULE_AUTHOR("Stelian Pop <[email protected]>");
MODULE_DESCRIPTION("Sony Programmable I/O Control Device driver");
MODULE_LICENSE("GPL");
@@ -648,7 +722,7 @@
.ioctl = sonypi_misc_ioctl,
};
-struct miscdevice sonypi_misc_device = {
+static struct miscdevice sonypi_misc_device = {
.minor = -1,
.name = "sonypi",
.fops = &sonypi_misc_fops,
On Mon, Jan 31, 2005 at 06:35:08PM +0100, Adrian Bunk wrote:
> 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(-)
Index: drivers/char/sonypi.h
===================================================================
--- a/drivers/char/sonypi.h (revision 26543)
+++ b/drivers/char/sonypi.h (working copy)
@@ -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[] = {
Index: drivers/char/sonypi.c
===================================================================
--- a/drivers/char/sonypi.c (revision 26543)
+++ b/drivers/char/sonypi.c (working copy)
@@ -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,
>
--
Stelian Pop <[email protected]>
On Mon, Jan 31, 2005 at 10:49:05PM +0100, Stelian Pop wrote:
> On Mon, Jan 31, 2005 at 06:35:08PM +0100, Adrian Bunk wrote:
>
> > 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:
>...
That's also OK with me.
cu
Adrian
--
"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 Seed
On Mon, 31 Jan 2005 22:49:05 +0100, Stelian Pop <[email protected]> wrote:
>
> 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).
>
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.
--
Dmitry
On Mon, Jan 31, 2005 at 05:13:22PM -0500, Dmitry Torokhov wrote:
> On Mon, 31 Jan 2005 22:49:05 +0100, Stelian Pop <[email protected]> wrote:
> >
> > 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).
> >
>
> 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.
--
Stelian Pop <[email protected]>
On Mon, 31 Jan 2005 23:27:54 +0100, Stelian Pop <[email protected]> wrote:
> On Mon, Jan 31, 2005 at 05:13:22PM -0500, Dmitry Torokhov wrote:
>
> > On Mon, 31 Jan 2005 22:49:05 +0100, Stelian Pop <[email protected]> wrote:
> > >
> > > 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).
> > >
> >
> > 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).
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_.
--
Dmitry