Add patches accepted for 2.6.22-rc4
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / releases / upstream / 2.6.20-rc2 / 0022-ACPI-ibm-acpi-style-fixes-and-cruft-removal.txt
blobfc368731a790313c0079ccb28c1572afcbedd299
1 From 9a8e1738c1136a857c1fd3ae0c5019f9767427ad Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Sat, 25 Nov 2006 16:36:00 -0200
4 Subject: [PATCH 22/28] ACPI: ibm-acpi: style fixes and cruft removal
6 This patch just fixes style, move some #defines to enums, and removes some
7 old cruft.
9 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
10 ---
11  drivers/acpi/ibm_acpi.c |  100 ++++++++++++++++++++---------------------------
12  1 files changed, 43 insertions(+), 57 deletions(-)
14 diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c
15 index 36e2667..8bb41bd 100644
16 --- a/drivers/acpi/ibm_acpi.c
17 +++ b/drivers/acpi/ibm_acpi.c
18 @@ -78,9 +78,11 @@
19  #include <linux/init.h>
20  #include <linux/types.h>
21  #include <linux/string.h>
23  #include <linux/proc_fs.h>
24  #include <linux/backlight.h>
25  #include <asm/uaccess.h>
27  #include <linux/dmi.h>
28  #include <linux/jiffies.h>
29  #include <linux/workqueue.h>
30 @@ -121,28 +123,6 @@ static acpi_handle root_handle = NULL;
31         static char        *object##_path;                      \
32         static char        *object##_paths[] = { paths }
34 -/*
35 - * The following models are supported to various degrees:
36 - *
37 - * 570, 600e, 600x, 770e, 770x
38 - * A20m, A21e, A21m, A21p, A22p, A30, A30p, A31, A31p
39 - * G40, G41
40 - * R30, R31, R32, R40, R40e, R50, R50e, R50p, R51
41 - * T20, T21, T22, T23, T30, T40, T40p, T41, T41p, T42, T42p, T43
42 - * X20, X21, X22, X23, X24, X30, X31, X40
43 - *
44 - * The following models have no supported features:
45 - *
46 - * 240, 240x, i1400
47 - *
48 - * Still missing DSDTs for the following models:
49 - *
50 - * A20p, A22e, A22m
51 - * R52
52 - * S31
53 - * T43p
54 - */
56  IBM_HANDLE(ec, root, "\\_SB.PCI0.ISA.EC0",     /* 240, 240x */
57            "\\_SB.PCI.ISA.EC",  /* 570 */
58            "\\_SB.PCI0.ISA0.EC0",       /* 600e/x, 770e, 770x */
59 @@ -785,12 +765,15 @@ static int wan_write(char *buf)
60         return 0;
61  }
63 -static int video_supported;
64 -static int video_orig_autosw;
65 +enum video_access_mode {
66 +       IBMACPI_VIDEO_NONE = 0,
67 +       IBMACPI_VIDEO_570,      /* 570 */
68 +       IBMACPI_VIDEO_770,      /* 600e/x, 770e, 770x */
69 +       IBMACPI_VIDEO_NEW,      /* all others */
70 +};
72 -#define VIDEO_570 1
73 -#define VIDEO_770 2
74 -#define VIDEO_NEW 3
75 +static enum video_access_mode video_supported;
76 +static int video_orig_autosw;
78  static int video_init(void)
79  {
80 @@ -802,16 +785,16 @@ static int video_init(void)
82         if (!vid_handle)
83                 /* video switching not supported on R30, R31 */
84 -               video_supported = 0;
85 +               video_supported = IBMACPI_VIDEO_NONE;
86         else if (acpi_evalf(vid_handle, &video_orig_autosw, "SWIT", "qd"))
87                 /* 570 */
88 -               video_supported = VIDEO_570;
89 +               video_supported = IBMACPI_VIDEO_570;
90         else if (acpi_evalf(vid_handle, &video_orig_autosw, "^VADL", "qd"))
91                 /* 600e/x, 770e, 770x */
92 -               video_supported = VIDEO_770;
93 +               video_supported = IBMACPI_VIDEO_770;
94         else
95                 /* all others */
96 -               video_supported = VIDEO_NEW;
97 +               video_supported = IBMACPI_VIDEO_NEW;
99         return 0;
101 @@ -821,15 +804,15 @@ static int video_status(void)
102         int status = 0;
103         int i;
105 -       if (video_supported == VIDEO_570) {
106 +       if (video_supported == IBMACPI_VIDEO_570) {
107                 if (acpi_evalf(NULL, &i, "\\_SB.PHS", "dd", 0x87))
108                         status = i & 3;
109 -       } else if (video_supported == VIDEO_770) {
110 +       } else if (video_supported == IBMACPI_VIDEO_770) {
111                 if (acpi_evalf(NULL, &i, "\\VCDL", "d"))
112                         status |= 0x01 * i;
113                 if (acpi_evalf(NULL, &i, "\\VCDC", "d"))
114                         status |= 0x02 * i;
115 -       } else if (video_supported == VIDEO_NEW) {
116 +       } else if (video_supported == IBMACPI_VIDEO_NEW) {
117                 acpi_evalf(NULL, NULL, "\\VUPS", "vd", 1);
118                 if (acpi_evalf(NULL, &i, "\\VCDC", "d"))
119                         status |= 0x02 * i;
120 @@ -848,9 +831,10 @@ static int video_autosw(void)
122         int autosw = 0;
124 -       if (video_supported == VIDEO_570)
125 +       if (video_supported == IBMACPI_VIDEO_570)
126                 acpi_evalf(vid_handle, &autosw, "SWIT", "d");
127 -       else if (video_supported == VIDEO_770 || video_supported == VIDEO_NEW)
128 +       else if (video_supported == IBMACPI_VIDEO_770 ||
129 +                video_supported == IBMACPI_VIDEO_NEW)
130                 acpi_evalf(vid_handle, &autosw, "^VDEE", "d");
132         return autosw & 1;
133 @@ -870,12 +854,12 @@ static int video_read(char *p)
134         len += sprintf(p + len, "status:\t\tsupported\n");
135         len += sprintf(p + len, "lcd:\t\t%s\n", enabled(status, 0));
136         len += sprintf(p + len, "crt:\t\t%s\n", enabled(status, 1));
137 -       if (video_supported == VIDEO_NEW)
138 +       if (video_supported == IBMACPI_VIDEO_NEW)
139                 len += sprintf(p + len, "dvi:\t\t%s\n", enabled(status, 3));
140         len += sprintf(p + len, "auto:\t\t%s\n", enabled(autosw, 0));
141         len += sprintf(p + len, "commands:\tlcd_enable, lcd_disable\n");
142         len += sprintf(p + len, "commands:\tcrt_enable, crt_disable\n");
143 -       if (video_supported == VIDEO_NEW)
144 +       if (video_supported == IBMACPI_VIDEO_NEW)
145                 len += sprintf(p + len, "commands:\tdvi_enable, dvi_disable\n");
146         len += sprintf(p + len, "commands:\tauto_enable, auto_disable\n");
147         len += sprintf(p + len, "commands:\tvideo_switch, expand_toggle\n");
148 @@ -890,7 +874,7 @@ static int video_switch(void)
150         if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1))
151                 return -EIO;
152 -       ret = video_supported == VIDEO_570 ?
153 +       ret = video_supported == IBMACPI_VIDEO_570 ?
154             acpi_evalf(ec_handle, NULL, "_Q16", "v") :
155             acpi_evalf(vid_handle, NULL, "VSWT", "v");
156         acpi_evalf(vid_handle, NULL, "_DOS", "vd", autosw);
157 @@ -900,9 +884,9 @@ static int video_switch(void)
159  static int video_expand(void)
161 -       if (video_supported == VIDEO_570)
162 +       if (video_supported == IBMACPI_VIDEO_570)
163                 return acpi_evalf(ec_handle, NULL, "_Q17", "v");
164 -       else if (video_supported == VIDEO_770)
165 +       else if (video_supported == IBMACPI_VIDEO_770)
166                 return acpi_evalf(vid_handle, NULL, "VEXP", "v");
167         else
168                 return acpi_evalf(NULL, NULL, "\\VEXP", "v");
169 @@ -912,10 +896,10 @@ static int video_switch2(int status)
171         int ret;
173 -       if (video_supported == VIDEO_570) {
174 +       if (video_supported == IBMACPI_VIDEO_570) {
175                 ret = acpi_evalf(NULL, NULL,
176                                  "\\_SB.PHS2", "vdd", 0x8b, status | 0x80);
177 -       } else if (video_supported == VIDEO_770) {
178 +       } else if (video_supported == IBMACPI_VIDEO_770) {
179                 int autosw = video_autosw();
180                 if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", 1))
181                         return -EIO;
182 @@ -951,10 +935,10 @@ static int video_write(char *buf)
183                         enable |= 0x02;
184                 } else if (strlencmp(cmd, "crt_disable") == 0) {
185                         disable |= 0x02;
186 -               } else if (video_supported == VIDEO_NEW &&
187 +               } else if (video_supported == IBMACPI_VIDEO_NEW &&
188                            strlencmp(cmd, "dvi_enable") == 0) {
189                         enable |= 0x08;
190 -               } else if (video_supported == VIDEO_NEW &&
191 +               } else if (video_supported == IBMACPI_VIDEO_NEW &&
192                            strlencmp(cmd, "dvi_disable") == 0) {
193                         disable |= 0x08;
194                 } else if (strlencmp(cmd, "auto_enable") == 0) {
195 @@ -1253,26 +1237,28 @@ static int cmos_write(char *buf)
196         return 0;
199 -static int led_supported;
201 -#define LED_570 1
202 -#define LED_OLD 2
203 -#define LED_NEW 3
204 +enum led_access_mode {
205 +       IBMACPI_LED_NONE = 0,
206 +       IBMACPI_LED_570,        /* 570 */
207 +       IBMACPI_LED_OLD,        /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
208 +       IBMACPI_LED_NEW,        /* all others */
210 +static enum led_access_mode led_supported;
212  static int led_init(void)
214         if (!led_handle)
215                 /* led not supported on R30, R31 */
216 -               led_supported = 0;
217 +               led_supported = IBMACPI_LED_NONE;
218         else if (strlencmp(led_path, "SLED") == 0)
219                 /* 570 */
220 -               led_supported = LED_570;
221 +               led_supported = IBMACPI_LED_570;
222         else if (strlencmp(led_path, "SYSL") == 0)
223                 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
224 -               led_supported = LED_OLD;
225 +               led_supported = IBMACPI_LED_OLD;
226         else
227                 /* all others */
228 -               led_supported = LED_NEW;
229 +               led_supported = IBMACPI_LED_NEW;
231         return 0;
233 @@ -1289,7 +1275,7 @@ static int led_read(char *p)
234         }
235         len += sprintf(p + len, "status:\t\tsupported\n");
237 -       if (led_supported == LED_570) {
238 +       if (led_supported == IBMACPI_LED_570) {
239                 /* 570 */
240                 int i, status;
241                 for (i = 0; i < 8; i++) {
242 @@ -1338,13 +1324,13 @@ static int led_write(char *buf)
243                 } else
244                         return -EINVAL;
246 -               if (led_supported == LED_570) {
247 +               if (led_supported == IBMACPI_LED_570) {
248                         /* 570 */
249                         led = 1 << led;
250                         if (!acpi_evalf(led_handle, NULL, NULL, "vdd",
251                                         led, led_sled_arg1[ind]))
252                                 return -EIO;
253 -               } else if (led_supported == LED_OLD) {
254 +               } else if (led_supported == IBMACPI_LED_OLD) {
255                         /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20 */
256                         led = 1 << led;
257                         ret = ec_write(EC_HLMS, led);
258 -- 
259 1.4.4.2