aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/pnpbios
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2007-07-26 13:41:20 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-26 14:35:20 -0400
commit9dd78466c956ac4b4f38e12032dc4249ccf57ad1 (patch)
tree57ee3822b79049d38c1df952fe77e72a97c718f3 /drivers/pnp/pnpbios
parent8ec3cf7d29aef773eee5bc6cd9b0fa4d3fb42480 (diff)
PNP: Lindent all source files
Run Lindent on all PNP source files. Produced by: $ quilt new pnp-lindent $ find drivers/pnp -name \*.[ch] | xargs quilt add $ quilt add include/linux/{pnp.h,pnpbios.h} $ scripts/Lindent drivers/pnp/*.c drivers/pnp/*/*.c include/linux/pnp*.h $ quilt refresh --sort Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Cc: Len Brown <lenb@kernel.org> Cc: Adam Belay <ambx1@neo.rr.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/pnp/pnpbios')
-rw-r--r--drivers/pnp/pnpbios/bioscalls.c282
-rw-r--r--drivers/pnp/pnpbios/core.c241
-rw-r--r--drivers/pnp/pnpbios/proc.c102
-rw-r--r--drivers/pnp/pnpbios/rsparser.c278
4 files changed, 496 insertions, 407 deletions
diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
index a1f0b0ba2bfe..d546f79d4d3b 100644
--- a/drivers/pnp/pnpbios/bioscalls.c
+++ b/drivers/pnp/pnpbios/bioscalls.c
@@ -26,11 +26,10 @@
26#include "pnpbios.h" 26#include "pnpbios.h"
27 27
28static struct { 28static struct {
29 u16 offset; 29 u16 offset;
30 u16 segment; 30 u16 segment;
31} pnp_bios_callpoint; 31} pnp_bios_callpoint;
32 32
33
34/* 33/*
35 * These are some opcodes for a "static asmlinkage" 34 * These are some opcodes for a "static asmlinkage"
36 * As this code is *not* executed inside the linux kernel segment, but in a 35 * As this code is *not* executed inside the linux kernel segment, but in a
@@ -44,8 +43,7 @@ static struct {
44 43
45asmlinkage void pnp_bios_callfunc(void); 44asmlinkage void pnp_bios_callfunc(void);
46 45
47__asm__( 46__asm__(".text \n"
48 ".text \n"
49 __ALIGN_STR "\n" 47 __ALIGN_STR "\n"
50 "pnp_bios_callfunc:\n" 48 "pnp_bios_callfunc:\n"
51 " pushl %edx \n" 49 " pushl %edx \n"
@@ -54,9 +52,7 @@ __asm__(
54 " pushl %eax \n" 52 " pushl %eax \n"
55 " lcallw *pnp_bios_callpoint\n" 53 " lcallw *pnp_bios_callpoint\n"
56 " addl $16, %esp \n" 54 " addl $16, %esp \n"
57 " lret \n" 55 " lret \n" ".previous \n");
58 ".previous \n"
59);
60 56
61#define Q2_SET_SEL(cpu, selname, address, size) \ 57#define Q2_SET_SEL(cpu, selname, address, size) \
62do { \ 58do { \
@@ -78,7 +74,6 @@ u32 pnp_bios_is_utter_crap = 0;
78 74
79static spinlock_t pnp_bios_lock; 75static spinlock_t pnp_bios_lock;
80 76
81
82/* 77/*
83 * Support Functions 78 * Support Functions
84 */ 79 */
@@ -97,7 +92,7 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
97 * PnP BIOSes are generally not terribly re-entrant. 92 * PnP BIOSes are generally not terribly re-entrant.
98 * Also, don't rely on them to save everything correctly. 93 * Also, don't rely on them to save everything correctly.
99 */ 94 */
100 if(pnp_bios_is_utter_crap) 95 if (pnp_bios_is_utter_crap)
101 return PNP_FUNCTION_NOT_SUPPORTED; 96 return PNP_FUNCTION_NOT_SUPPORTED;
102 97
103 cpu = get_cpu(); 98 cpu = get_cpu();
@@ -113,112 +108,127 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
113 if (ts2_size) 108 if (ts2_size)
114 Q2_SET_SEL(smp_processor_id(), PNP_TS2, ts2_base, ts2_size); 109 Q2_SET_SEL(smp_processor_id(), PNP_TS2, ts2_base, ts2_size);
115 110
116 __asm__ __volatile__( 111 __asm__ __volatile__("pushl %%ebp\n\t"
117 "pushl %%ebp\n\t" 112 "pushl %%edi\n\t"
118 "pushl %%edi\n\t" 113 "pushl %%esi\n\t"
119 "pushl %%esi\n\t" 114 "pushl %%ds\n\t"
120 "pushl %%ds\n\t" 115 "pushl %%es\n\t"
121 "pushl %%es\n\t" 116 "pushl %%fs\n\t"
122 "pushl %%fs\n\t" 117 "pushl %%gs\n\t"
123 "pushl %%gs\n\t" 118 "pushfl\n\t"
124 "pushfl\n\t" 119 "movl %%esp, pnp_bios_fault_esp\n\t"
125 "movl %%esp, pnp_bios_fault_esp\n\t" 120 "movl $1f, pnp_bios_fault_eip\n\t"
126 "movl $1f, pnp_bios_fault_eip\n\t" 121 "lcall %5,%6\n\t"
127 "lcall %5,%6\n\t" 122 "1:popfl\n\t"
128 "1:popfl\n\t" 123 "popl %%gs\n\t"
129 "popl %%gs\n\t" 124 "popl %%fs\n\t"
130 "popl %%fs\n\t" 125 "popl %%es\n\t"
131 "popl %%es\n\t" 126 "popl %%ds\n\t"
132 "popl %%ds\n\t" 127 "popl %%esi\n\t"
133 "popl %%esi\n\t" 128 "popl %%edi\n\t" "popl %%ebp\n\t":"=a"(status)
134 "popl %%edi\n\t" 129 :"0"((func) | (((u32) arg1) << 16)),
135 "popl %%ebp\n\t" 130 "b"((arg2) | (((u32) arg3) << 16)),
136 : "=a" (status) 131 "c"((arg4) | (((u32) arg5) << 16)),
137 : "0" ((func) | (((u32)arg1) << 16)), 132 "d"((arg6) | (((u32) arg7) << 16)),
138 "b" ((arg2) | (((u32)arg3) << 16)), 133 "i"(PNP_CS32), "i"(0)
139 "c" ((arg4) | (((u32)arg5) << 16)), 134 :"memory");
140 "d" ((arg6) | (((u32)arg7) << 16)),
141 "i" (PNP_CS32),
142 "i" (0)
143 : "memory"
144 );
145 spin_unlock_irqrestore(&pnp_bios_lock, flags); 135 spin_unlock_irqrestore(&pnp_bios_lock, flags);
146 136
147 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40; 137 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
148 put_cpu(); 138 put_cpu();
149 139
150 /* If we get here and this is set then the PnP BIOS faulted on us. */ 140 /* If we get here and this is set then the PnP BIOS faulted on us. */
151 if(pnp_bios_is_utter_crap) 141 if (pnp_bios_is_utter_crap) {
152 { 142 printk(KERN_ERR
153 printk(KERN_ERR "PnPBIOS: Warning! Your PnP BIOS caused a fatal error. Attempting to continue\n"); 143 "PnPBIOS: Warning! Your PnP BIOS caused a fatal error. Attempting to continue\n");
154 printk(KERN_ERR "PnPBIOS: You may need to reboot with the \"pnpbios=off\" option to operate stably\n"); 144 printk(KERN_ERR
155 printk(KERN_ERR "PnPBIOS: Check with your vendor for an updated BIOS\n"); 145 "PnPBIOS: You may need to reboot with the \"pnpbios=off\" option to operate stably\n");
146 printk(KERN_ERR
147 "PnPBIOS: Check with your vendor for an updated BIOS\n");
156 } 148 }
157 149
158 return status; 150 return status;
159} 151}
160 152
161void pnpbios_print_status(const char * module, u16 status) 153void pnpbios_print_status(const char *module, u16 status)
162{ 154{
163 switch(status) { 155 switch (status) {
164 case PNP_SUCCESS: 156 case PNP_SUCCESS:
165 printk(KERN_ERR "PnPBIOS: %s: function successful\n", module); 157 printk(KERN_ERR "PnPBIOS: %s: function successful\n", module);
166 break; 158 break;
167 case PNP_NOT_SET_STATICALLY: 159 case PNP_NOT_SET_STATICALLY:
168 printk(KERN_ERR "PnPBIOS: %s: unable to set static resources\n", module); 160 printk(KERN_ERR "PnPBIOS: %s: unable to set static resources\n",
161 module);
169 break; 162 break;
170 case PNP_UNKNOWN_FUNCTION: 163 case PNP_UNKNOWN_FUNCTION:
171 printk(KERN_ERR "PnPBIOS: %s: invalid function number passed\n", module); 164 printk(KERN_ERR "PnPBIOS: %s: invalid function number passed\n",
165 module);
172 break; 166 break;
173 case PNP_FUNCTION_NOT_SUPPORTED: 167 case PNP_FUNCTION_NOT_SUPPORTED:
174 printk(KERN_ERR "PnPBIOS: %s: function not supported on this system\n", module); 168 printk(KERN_ERR
169 "PnPBIOS: %s: function not supported on this system\n",
170 module);
175 break; 171 break;
176 case PNP_INVALID_HANDLE: 172 case PNP_INVALID_HANDLE:
177 printk(KERN_ERR "PnPBIOS: %s: invalid handle\n", module); 173 printk(KERN_ERR "PnPBIOS: %s: invalid handle\n", module);
178 break; 174 break;
179 case PNP_BAD_PARAMETER: 175 case PNP_BAD_PARAMETER:
180 printk(KERN_ERR "PnPBIOS: %s: invalid parameters were passed\n", module); 176 printk(KERN_ERR "PnPBIOS: %s: invalid parameters were passed\n",
177 module);
181 break; 178 break;
182 case PNP_SET_FAILED: 179 case PNP_SET_FAILED:
183 printk(KERN_ERR "PnPBIOS: %s: unable to set resources\n", module); 180 printk(KERN_ERR "PnPBIOS: %s: unable to set resources\n",
181 module);
184 break; 182 break;
185 case PNP_EVENTS_NOT_PENDING: 183 case PNP_EVENTS_NOT_PENDING:
186 printk(KERN_ERR "PnPBIOS: %s: no events are pending\n", module); 184 printk(KERN_ERR "PnPBIOS: %s: no events are pending\n", module);
187 break; 185 break;
188 case PNP_SYSTEM_NOT_DOCKED: 186 case PNP_SYSTEM_NOT_DOCKED:
189 printk(KERN_ERR "PnPBIOS: %s: the system is not docked\n", module); 187 printk(KERN_ERR "PnPBIOS: %s: the system is not docked\n",
188 module);
190 break; 189 break;
191 case PNP_NO_ISA_PNP_CARDS: 190 case PNP_NO_ISA_PNP_CARDS:
192 printk(KERN_ERR "PnPBIOS: %s: no isapnp cards are installed on this system\n", module); 191 printk(KERN_ERR
192 "PnPBIOS: %s: no isapnp cards are installed on this system\n",
193 module);
193 break; 194 break;
194 case PNP_UNABLE_TO_DETERMINE_DOCK_CAPABILITIES: 195 case PNP_UNABLE_TO_DETERMINE_DOCK_CAPABILITIES:
195 printk(KERN_ERR "PnPBIOS: %s: cannot determine the capabilities of the docking station\n", module); 196 printk(KERN_ERR
197 "PnPBIOS: %s: cannot determine the capabilities of the docking station\n",
198 module);
196 break; 199 break;
197 case PNP_CONFIG_CHANGE_FAILED_NO_BATTERY: 200 case PNP_CONFIG_CHANGE_FAILED_NO_BATTERY:
198 printk(KERN_ERR "PnPBIOS: %s: unable to undock, the system does not have a battery\n", module); 201 printk(KERN_ERR
202 "PnPBIOS: %s: unable to undock, the system does not have a battery\n",
203 module);
199 break; 204 break;
200 case PNP_CONFIG_CHANGE_FAILED_RESOURCE_CONFLICT: 205 case PNP_CONFIG_CHANGE_FAILED_RESOURCE_CONFLICT:
201 printk(KERN_ERR "PnPBIOS: %s: could not dock due to resource conflicts\n", module); 206 printk(KERN_ERR
207 "PnPBIOS: %s: could not dock due to resource conflicts\n",
208 module);
202 break; 209 break;
203 case PNP_BUFFER_TOO_SMALL: 210 case PNP_BUFFER_TOO_SMALL:
204 printk(KERN_ERR "PnPBIOS: %s: the buffer passed is too small\n", module); 211 printk(KERN_ERR "PnPBIOS: %s: the buffer passed is too small\n",
212 module);
205 break; 213 break;
206 case PNP_USE_ESCD_SUPPORT: 214 case PNP_USE_ESCD_SUPPORT:
207 printk(KERN_ERR "PnPBIOS: %s: use ESCD instead\n", module); 215 printk(KERN_ERR "PnPBIOS: %s: use ESCD instead\n", module);
208 break; 216 break;
209 case PNP_MESSAGE_NOT_SUPPORTED: 217 case PNP_MESSAGE_NOT_SUPPORTED:
210 printk(KERN_ERR "PnPBIOS: %s: the message is unsupported\n", module); 218 printk(KERN_ERR "PnPBIOS: %s: the message is unsupported\n",
219 module);
211 break; 220 break;
212 case PNP_HARDWARE_ERROR: 221 case PNP_HARDWARE_ERROR:
213 printk(KERN_ERR "PnPBIOS: %s: a hardware failure has occured\n", module); 222 printk(KERN_ERR "PnPBIOS: %s: a hardware failure has occured\n",
223 module);
214 break; 224 break;
215 default: 225 default:
216 printk(KERN_ERR "PnPBIOS: %s: unexpected status 0x%x\n", module, status); 226 printk(KERN_ERR "PnPBIOS: %s: unexpected status 0x%x\n", module,
227 status);
217 break; 228 break;
218 } 229 }
219} 230}
220 231
221
222/* 232/*
223 * PnP BIOS Low Level Calls 233 * PnP BIOS Low Level Calls
224 */ 234 */
@@ -245,17 +255,19 @@ static int __pnp_bios_dev_node_info(struct pnp_dev_node_info *data)
245 u16 status; 255 u16 status;
246 if (!pnp_bios_present()) 256 if (!pnp_bios_present())
247 return PNP_FUNCTION_NOT_SUPPORTED; 257 return PNP_FUNCTION_NOT_SUPPORTED;
248 status = call_pnp_bios(PNP_GET_NUM_SYS_DEV_NODES, 0, PNP_TS1, 2, PNP_TS1, PNP_DS, 0, 0, 258 status =
249 data, sizeof(struct pnp_dev_node_info), NULL, 0); 259 call_pnp_bios(PNP_GET_NUM_SYS_DEV_NODES, 0, PNP_TS1, 2, PNP_TS1,
260 PNP_DS, 0, 0, data, sizeof(struct pnp_dev_node_info),
261 NULL, 0);
250 data->no_nodes &= 0xff; 262 data->no_nodes &= 0xff;
251 return status; 263 return status;
252} 264}
253 265
254int pnp_bios_dev_node_info(struct pnp_dev_node_info *data) 266int pnp_bios_dev_node_info(struct pnp_dev_node_info *data)
255{ 267{
256 int status = __pnp_bios_dev_node_info( data ); 268 int status = __pnp_bios_dev_node_info(data);
257 if ( status ) 269 if (status)
258 pnpbios_print_status( "dev_node_info", status ); 270 pnpbios_print_status("dev_node_info", status);
259 return status; 271 return status;
260} 272}
261 273
@@ -273,60 +285,64 @@ int pnp_bios_dev_node_info(struct pnp_dev_node_info *data)
273 * or volatile current (0) config 285 * or volatile current (0) config
274 * Output: *nodenum=next node or 0xff if no more nodes 286 * Output: *nodenum=next node or 0xff if no more nodes
275 */ 287 */
276static int __pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node *data) 288static int __pnp_bios_get_dev_node(u8 * nodenum, char boot,
289 struct pnp_bios_node *data)
277{ 290{
278 u16 status; 291 u16 status;
279 u16 tmp_nodenum; 292 u16 tmp_nodenum;
280 if (!pnp_bios_present()) 293 if (!pnp_bios_present())
281 return PNP_FUNCTION_NOT_SUPPORTED; 294 return PNP_FUNCTION_NOT_SUPPORTED;
282 if ( !boot && pnpbios_dont_use_current_config ) 295 if (!boot && pnpbios_dont_use_current_config)
283 return PNP_FUNCTION_NOT_SUPPORTED; 296 return PNP_FUNCTION_NOT_SUPPORTED;
284 tmp_nodenum = *nodenum; 297 tmp_nodenum = *nodenum;
285 status = call_pnp_bios(PNP_GET_SYS_DEV_NODE, 0, PNP_TS1, 0, PNP_TS2, boot ? 2 : 1, PNP_DS, 0, 298 status =
286 &tmp_nodenum, sizeof(tmp_nodenum), data, 65536); 299 call_pnp_bios(PNP_GET_SYS_DEV_NODE, 0, PNP_TS1, 0, PNP_TS2,
300 boot ? 2 : 1, PNP_DS, 0, &tmp_nodenum,
301 sizeof(tmp_nodenum), data, 65536);
287 *nodenum = tmp_nodenum; 302 *nodenum = tmp_nodenum;
288 return status; 303 return status;
289} 304}
290 305
291int pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node *data) 306int pnp_bios_get_dev_node(u8 * nodenum, char boot, struct pnp_bios_node *data)
292{ 307{
293 int status; 308 int status;
294 status = __pnp_bios_get_dev_node( nodenum, boot, data ); 309 status = __pnp_bios_get_dev_node(nodenum, boot, data);
295 if ( status ) 310 if (status)
296 pnpbios_print_status( "get_dev_node", status ); 311 pnpbios_print_status("get_dev_node", status);
297 return status; 312 return status;
298} 313}
299 314
300
301/* 315/*
302 * Call PnP BIOS with function 0x02, "set system device node" 316 * Call PnP BIOS with function 0x02, "set system device node"
303 * Input: *nodenum = desired node, 317 * Input: *nodenum = desired node,
304 * boot = whether to set nonvolatile boot (!=0) 318 * boot = whether to set nonvolatile boot (!=0)
305 * or volatile current (0) config 319 * or volatile current (0) config
306 */ 320 */
307static int __pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data) 321static int __pnp_bios_set_dev_node(u8 nodenum, char boot,
322 struct pnp_bios_node *data)
308{ 323{
309 u16 status; 324 u16 status;
310 if (!pnp_bios_present()) 325 if (!pnp_bios_present())
311 return PNP_FUNCTION_NOT_SUPPORTED; 326 return PNP_FUNCTION_NOT_SUPPORTED;
312 if ( !boot && pnpbios_dont_use_current_config ) 327 if (!boot && pnpbios_dont_use_current_config)
313 return PNP_FUNCTION_NOT_SUPPORTED; 328 return PNP_FUNCTION_NOT_SUPPORTED;
314 status = call_pnp_bios(PNP_SET_SYS_DEV_NODE, nodenum, 0, PNP_TS1, boot ? 2 : 1, PNP_DS, 0, 0, 329 status =
315 data, 65536, NULL, 0); 330 call_pnp_bios(PNP_SET_SYS_DEV_NODE, nodenum, 0, PNP_TS1,
331 boot ? 2 : 1, PNP_DS, 0, 0, data, 65536, NULL, 0);
316 return status; 332 return status;
317} 333}
318 334
319int pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data) 335int pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data)
320{ 336{
321 int status; 337 int status;
322 status = __pnp_bios_set_dev_node( nodenum, boot, data ); 338 status = __pnp_bios_set_dev_node(nodenum, boot, data);
323 if ( status ) { 339 if (status) {
324 pnpbios_print_status( "set_dev_node", status ); 340 pnpbios_print_status("set_dev_node", status);
325 return status; 341 return status;
326 } 342 }
327 if ( !boot ) { /* Update devlist */ 343 if (!boot) { /* Update devlist */
328 status = pnp_bios_get_dev_node( &nodenum, boot, data ); 344 status = pnp_bios_get_dev_node(&nodenum, boot, data);
329 if ( status ) 345 if (status)
330 return status; 346 return status;
331 } 347 }
332 return status; 348 return status;
@@ -336,12 +352,12 @@ int pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data)
336/* 352/*
337 * Call PnP BIOS with function 0x03, "get event" 353 * Call PnP BIOS with function 0x03, "get event"
338 */ 354 */
339static int pnp_bios_get_event(u16 *event) 355static int pnp_bios_get_event(u16 * event)
340{ 356{
341 u16 status; 357 u16 status;
342 if (!pnp_bios_present()) 358 if (!pnp_bios_present())
343 return PNP_FUNCTION_NOT_SUPPORTED; 359 return PNP_FUNCTION_NOT_SUPPORTED;
344 status = call_pnp_bios(PNP_GET_EVENT, 0, PNP_TS1, PNP_DS, 0, 0 ,0 ,0, 360 status = call_pnp_bios(PNP_GET_EVENT, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0,
345 event, sizeof(u16), NULL, 0); 361 event, sizeof(u16), NULL, 0);
346 return status; 362 return status;
347} 363}
@@ -356,7 +372,9 @@ static int pnp_bios_send_message(u16 message)
356 u16 status; 372 u16 status;
357 if (!pnp_bios_present()) 373 if (!pnp_bios_present())
358 return PNP_FUNCTION_NOT_SUPPORTED; 374 return PNP_FUNCTION_NOT_SUPPORTED;
359 status = call_pnp_bios(PNP_SEND_MESSAGE, message, PNP_DS, 0, 0, 0, 0, 0, 0, 0, 0, 0); 375 status =
376 call_pnp_bios(PNP_SEND_MESSAGE, message, PNP_DS, 0, 0, 0, 0, 0, 0,
377 0, 0, 0);
360 return status; 378 return status;
361} 379}
362#endif 380#endif
@@ -369,8 +387,10 @@ int pnp_bios_dock_station_info(struct pnp_docking_station_info *data)
369 u16 status; 387 u16 status;
370 if (!pnp_bios_present()) 388 if (!pnp_bios_present())
371 return PNP_FUNCTION_NOT_SUPPORTED; 389 return PNP_FUNCTION_NOT_SUPPORTED;
372 status = call_pnp_bios(PNP_GET_DOCKING_STATION_INFORMATION, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0, 390 status =
373 data, sizeof(struct pnp_docking_station_info), NULL, 0); 391 call_pnp_bios(PNP_GET_DOCKING_STATION_INFORMATION, 0, PNP_TS1,
392 PNP_DS, 0, 0, 0, 0, data,
393 sizeof(struct pnp_docking_station_info), NULL, 0);
374 return status; 394 return status;
375} 395}
376 396
@@ -384,8 +404,9 @@ static int pnp_bios_set_stat_res(char *info)
384 u16 status; 404 u16 status;
385 if (!pnp_bios_present()) 405 if (!pnp_bios_present())
386 return PNP_FUNCTION_NOT_SUPPORTED; 406 return PNP_FUNCTION_NOT_SUPPORTED;
387 status = call_pnp_bios(PNP_SET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0, 407 status =
388 info, *((u16 *) info), 0, 0); 408 call_pnp_bios(PNP_SET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1, PNP_DS,
409 0, 0, 0, 0, info, *((u16 *) info), 0, 0);
389 return status; 410 return status;
390} 411}
391#endif 412#endif
@@ -399,17 +420,18 @@ static int __pnp_bios_get_stat_res(char *info)
399 u16 status; 420 u16 status;
400 if (!pnp_bios_present()) 421 if (!pnp_bios_present())
401 return PNP_FUNCTION_NOT_SUPPORTED; 422 return PNP_FUNCTION_NOT_SUPPORTED;
402 status = call_pnp_bios(PNP_GET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0, 423 status =
403 info, 65536, NULL, 0); 424 call_pnp_bios(PNP_GET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1, PNP_DS,
425 0, 0, 0, 0, info, 65536, NULL, 0);
404 return status; 426 return status;
405} 427}
406 428
407int pnp_bios_get_stat_res(char *info) 429int pnp_bios_get_stat_res(char *info)
408{ 430{
409 int status; 431 int status;
410 status = __pnp_bios_get_stat_res( info ); 432 status = __pnp_bios_get_stat_res(info);
411 if ( status ) 433 if (status)
412 pnpbios_print_status( "get_stat_res", status ); 434 pnpbios_print_status("get_stat_res", status);
413 return status; 435 return status;
414} 436}
415 437
@@ -417,13 +439,14 @@ int pnp_bios_get_stat_res(char *info)
417/* 439/*
418 * Call PnP BIOS with function 0x0b, "get APM id table" 440 * Call PnP BIOS with function 0x0b, "get APM id table"
419 */ 441 */
420static int pnp_bios_apm_id_table(char *table, u16 *size) 442static int pnp_bios_apm_id_table(char *table, u16 * size)
421{ 443{
422 u16 status; 444 u16 status;
423 if (!pnp_bios_present()) 445 if (!pnp_bios_present())
424 return PNP_FUNCTION_NOT_SUPPORTED; 446 return PNP_FUNCTION_NOT_SUPPORTED;
425 status = call_pnp_bios(PNP_GET_APM_ID_TABLE, 0, PNP_TS2, 0, PNP_TS1, PNP_DS, 0, 0, 447 status =
426 table, *size, size, sizeof(u16)); 448 call_pnp_bios(PNP_GET_APM_ID_TABLE, 0, PNP_TS2, 0, PNP_TS1, PNP_DS,
449 0, 0, table, *size, size, sizeof(u16));
427 return status; 450 return status;
428} 451}
429#endif 452#endif
@@ -436,17 +459,19 @@ static int __pnp_bios_isapnp_config(struct pnp_isa_config_struc *data)
436 u16 status; 459 u16 status;
437 if (!pnp_bios_present()) 460 if (!pnp_bios_present())
438 return PNP_FUNCTION_NOT_SUPPORTED; 461 return PNP_FUNCTION_NOT_SUPPORTED;
439 status = call_pnp_bios(PNP_GET_PNP_ISA_CONFIG_STRUC, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0, 462 status =
440 data, sizeof(struct pnp_isa_config_struc), NULL, 0); 463 call_pnp_bios(PNP_GET_PNP_ISA_CONFIG_STRUC, 0, PNP_TS1, PNP_DS, 0,
464 0, 0, 0, data, sizeof(struct pnp_isa_config_struc),
465 NULL, 0);
441 return status; 466 return status;
442} 467}
443 468
444int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data) 469int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data)
445{ 470{
446 int status; 471 int status;
447 status = __pnp_bios_isapnp_config( data ); 472 status = __pnp_bios_isapnp_config(data);
448 if ( status ) 473 if (status)
449 pnpbios_print_status( "isapnp_config", status ); 474 pnpbios_print_status("isapnp_config", status);
450 return status; 475 return status;
451} 476}
452 477
@@ -458,17 +483,19 @@ static int __pnp_bios_escd_info(struct escd_info_struc *data)
458 u16 status; 483 u16 status;
459 if (!pnp_bios_present()) 484 if (!pnp_bios_present())
460 return ESCD_FUNCTION_NOT_SUPPORTED; 485 return ESCD_FUNCTION_NOT_SUPPORTED;
461 status = call_pnp_bios(PNP_GET_ESCD_INFO, 0, PNP_TS1, 2, PNP_TS1, 4, PNP_TS1, PNP_DS, 486 status =
462 data, sizeof(struct escd_info_struc), NULL, 0); 487 call_pnp_bios(PNP_GET_ESCD_INFO, 0, PNP_TS1, 2, PNP_TS1, 4, PNP_TS1,
488 PNP_DS, data, sizeof(struct escd_info_struc), NULL,
489 0);
463 return status; 490 return status;
464} 491}
465 492
466int pnp_bios_escd_info(struct escd_info_struc *data) 493int pnp_bios_escd_info(struct escd_info_struc *data)
467{ 494{
468 int status; 495 int status;
469 status = __pnp_bios_escd_info( data ); 496 status = __pnp_bios_escd_info(data);
470 if ( status ) 497 if (status)
471 pnpbios_print_status( "escd_info", status ); 498 pnpbios_print_status("escd_info", status);
472 return status; 499 return status;
473} 500}
474 501
@@ -481,17 +508,18 @@ static int __pnp_bios_read_escd(char *data, u32 nvram_base)
481 u16 status; 508 u16 status;
482 if (!pnp_bios_present()) 509 if (!pnp_bios_present())
483 return ESCD_FUNCTION_NOT_SUPPORTED; 510 return ESCD_FUNCTION_NOT_SUPPORTED;
484 status = call_pnp_bios(PNP_READ_ESCD, 0, PNP_TS1, PNP_TS2, PNP_DS, 0, 0, 0, 511 status =
485 data, 65536, __va(nvram_base), 65536); 512 call_pnp_bios(PNP_READ_ESCD, 0, PNP_TS1, PNP_TS2, PNP_DS, 0, 0, 0,
513 data, 65536, __va(nvram_base), 65536);
486 return status; 514 return status;
487} 515}
488 516
489int pnp_bios_read_escd(char *data, u32 nvram_base) 517int pnp_bios_read_escd(char *data, u32 nvram_base)
490{ 518{
491 int status; 519 int status;
492 status = __pnp_bios_read_escd( data, nvram_base ); 520 status = __pnp_bios_read_escd(data, nvram_base);
493 if ( status ) 521 if (status)
494 pnpbios_print_status( "read_escd", status ); 522 pnpbios_print_status("read_escd", status);
495 return status; 523 return status;
496} 524}
497 525
@@ -504,13 +532,13 @@ static int pnp_bios_write_escd(char *data, u32 nvram_base)
504 u16 status; 532 u16 status;
505 if (!pnp_bios_present()) 533 if (!pnp_bios_present())
506 return ESCD_FUNCTION_NOT_SUPPORTED; 534 return ESCD_FUNCTION_NOT_SUPPORTED;
507 status = call_pnp_bios(PNP_WRITE_ESCD, 0, PNP_TS1, PNP_TS2, PNP_DS, 0, 0, 0, 535 status =
508 data, 65536, __va(nvram_base), 65536); 536 call_pnp_bios(PNP_WRITE_ESCD, 0, PNP_TS1, PNP_TS2, PNP_DS, 0, 0, 0,
537 data, 65536, __va(nvram_base), 65536);
509 return status; 538 return status;
510} 539}
511#endif 540#endif
512 541
513
514/* 542/*
515 * Initialization 543 * Initialization
516 */ 544 */
@@ -524,12 +552,14 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
524 552
525 set_base(bad_bios_desc, __va((unsigned long)0x40 << 4)); 553 set_base(bad_bios_desc, __va((unsigned long)0x40 << 4));
526 _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4)); 554 _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4));
527 for (i = 0; i < NR_CPUS; i++) { 555 for (i = 0; i < NR_CPUS; i++) {
528 struct desc_struct *gdt = get_cpu_gdt_table(i); 556 struct desc_struct *gdt = get_cpu_gdt_table(i);
529 if (!gdt) 557 if (!gdt)
530 continue; 558 continue;
531 set_base(gdt[GDT_ENTRY_PNPBIOS_CS32], &pnp_bios_callfunc); 559 set_base(gdt[GDT_ENTRY_PNPBIOS_CS32], &pnp_bios_callfunc);
532 set_base(gdt[GDT_ENTRY_PNPBIOS_CS16], __va(header->fields.pm16cseg)); 560 set_base(gdt[GDT_ENTRY_PNPBIOS_CS16],
533 set_base(gdt[GDT_ENTRY_PNPBIOS_DS], __va(header->fields.pm16dseg)); 561 __va(header->fields.pm16cseg));
534 } 562 set_base(gdt[GDT_ENTRY_PNPBIOS_DS],
563 __va(header->fields.pm16dseg));
564 }
535} 565}
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
index ed112ee16012..21289cb13a33 100644
--- a/drivers/pnp/pnpbios/core.c
+++ b/drivers/pnp/pnpbios/core.c
@@ -32,7 +32,7 @@
32 * along with this program; if not, write to the Free Software 32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 */ 34 */
35 35
36/* Change Log 36/* Change Log
37 * 37 *
38 * Adam Belay - <ambx1@neo.rr.com> - March 16, 2003 38 * Adam Belay - <ambx1@neo.rr.com> - March 16, 2003
@@ -71,14 +71,13 @@
71 71
72#include "pnpbios.h" 72#include "pnpbios.h"
73 73
74
75/* 74/*
76 * 75 *
77 * PnP BIOS INTERFACE 76 * PnP BIOS INTERFACE
78 * 77 *
79 */ 78 */
80 79
81static union pnp_bios_install_struct * pnp_bios_install = NULL; 80static union pnp_bios_install_struct *pnp_bios_install = NULL;
82 81
83int pnp_bios_present(void) 82int pnp_bios_present(void)
84{ 83{
@@ -101,36 +100,36 @@ static struct completion unload_sem;
101/* 100/*
102 * (Much of this belongs in a shared routine somewhere) 101 * (Much of this belongs in a shared routine somewhere)
103 */ 102 */
104 103
105static int pnp_dock_event(int dock, struct pnp_docking_station_info *info) 104static int pnp_dock_event(int dock, struct pnp_docking_station_info *info)
106{ 105{
107 char *argv [3], **envp, *buf, *scratch; 106 char *argv[3], **envp, *buf, *scratch;
108 int i = 0, value; 107 int i = 0, value;
109 108
110 if (!current->fs->root) { 109 if (!current->fs->root) {
111 return -EAGAIN; 110 return -EAGAIN;
112 } 111 }
113 if (!(envp = kcalloc(20, sizeof (char *), GFP_KERNEL))) { 112 if (!(envp = kcalloc(20, sizeof(char *), GFP_KERNEL))) {
114 return -ENOMEM; 113 return -ENOMEM;
115 } 114 }
116 if (!(buf = kzalloc(256, GFP_KERNEL))) { 115 if (!(buf = kzalloc(256, GFP_KERNEL))) {
117 kfree (envp); 116 kfree(envp);
118 return -ENOMEM; 117 return -ENOMEM;
119 } 118 }
120 119
121 /* FIXME: if there are actual users of this, it should be integrated into 120 /* FIXME: if there are actual users of this, it should be integrated into
122 * the driver core and use the usual infrastructure like sysfs and uevents */ 121 * the driver core and use the usual infrastructure like sysfs and uevents */
123 argv [0] = "/sbin/pnpbios"; 122 argv[0] = "/sbin/pnpbios";
124 argv [1] = "dock"; 123 argv[1] = "dock";
125 argv [2] = NULL; 124 argv[2] = NULL;
126 125
127 /* minimal command environment */ 126 /* minimal command environment */
128 envp [i++] = "HOME=/"; 127 envp[i++] = "HOME=/";
129 envp [i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; 128 envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
130 129
131#ifdef DEBUG 130#ifdef DEBUG
132 /* hint that policy agent should enter no-stdout debug mode */ 131 /* hint that policy agent should enter no-stdout debug mode */
133 envp [i++] = "DEBUG=kernel"; 132 envp[i++] = "DEBUG=kernel";
134#endif 133#endif
135 /* extensible set of named bus-specific parameters, 134 /* extensible set of named bus-specific parameters,
136 * supporting multiple driver selection algorithms. 135 * supporting multiple driver selection algorithms.
@@ -138,33 +137,32 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info)
138 scratch = buf; 137 scratch = buf;
139 138
140 /* action: add, remove */ 139 /* action: add, remove */
141 envp [i++] = scratch; 140 envp[i++] = scratch;
142 scratch += sprintf (scratch, "ACTION=%s", dock?"add":"remove") + 1; 141 scratch += sprintf(scratch, "ACTION=%s", dock ? "add" : "remove") + 1;
143 142
144 /* Report the ident for the dock */ 143 /* Report the ident for the dock */
145 envp [i++] = scratch; 144 envp[i++] = scratch;
146 scratch += sprintf (scratch, "DOCK=%x/%x/%x", 145 scratch += sprintf(scratch, "DOCK=%x/%x/%x",
147 info->location_id, info->serial, info->capabilities); 146 info->location_id, info->serial, info->capabilities);
148 envp[i] = NULL; 147 envp[i] = NULL;
149 148
150 value = call_usermodehelper (argv [0], argv, envp, UMH_WAIT_EXEC); 149 value = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC);
151 kfree (buf); 150 kfree(buf);
152 kfree (envp); 151 kfree(envp);
153 return 0; 152 return 0;
154} 153}
155 154
156/* 155/*
157 * Poll the PnP docking at regular intervals 156 * Poll the PnP docking at regular intervals
158 */ 157 */
159static int pnp_dock_thread(void * unused) 158static int pnp_dock_thread(void *unused)
160{ 159{
161 static struct pnp_docking_station_info now; 160 static struct pnp_docking_station_info now;
162 int docked = -1, d = 0; 161 int docked = -1, d = 0;
163 set_freezable(); 162 set_freezable();
164 while (!unloading) 163 while (!unloading) {
165 {
166 int status; 164 int status;
167 165
168 /* 166 /*
169 * Poll every 2 seconds 167 * Poll every 2 seconds
170 */ 168 */
@@ -175,30 +173,29 @@ static int pnp_dock_thread(void * unused)
175 173
176 status = pnp_bios_dock_station_info(&now); 174 status = pnp_bios_dock_station_info(&now);
177 175
178 switch(status) 176 switch (status) {
179 {
180 /* 177 /*
181 * No dock to manage 178 * No dock to manage
182 */ 179 */
183 case PNP_FUNCTION_NOT_SUPPORTED: 180 case PNP_FUNCTION_NOT_SUPPORTED:
184 complete_and_exit(&unload_sem, 0); 181 complete_and_exit(&unload_sem, 0);
185 case PNP_SYSTEM_NOT_DOCKED: 182 case PNP_SYSTEM_NOT_DOCKED:
186 d = 0; 183 d = 0;
187 break; 184 break;
188 case PNP_SUCCESS: 185 case PNP_SUCCESS:
189 d = 1; 186 d = 1;
190 break; 187 break;
191 default: 188 default:
192 pnpbios_print_status( "pnp_dock_thread", status ); 189 pnpbios_print_status("pnp_dock_thread", status);
193 continue; 190 continue;
194 } 191 }
195 if(d != docked) 192 if (d != docked) {
196 { 193 if (pnp_dock_event(d, &now) == 0) {
197 if(pnp_dock_event(d, &now)==0)
198 {
199 docked = d; 194 docked = d;
200#if 0 195#if 0
201 printk(KERN_INFO "PnPBIOS: Docking station %stached\n", docked?"at":"de"); 196 printk(KERN_INFO
197 "PnPBIOS: Docking station %stached\n",
198 docked ? "at" : "de");
202#endif 199#endif
203 } 200 }
204 } 201 }
@@ -206,21 +203,22 @@ static int pnp_dock_thread(void * unused)
206 complete_and_exit(&unload_sem, 0); 203 complete_and_exit(&unload_sem, 0);
207} 204}
208 205
209#endif /* CONFIG_HOTPLUG */ 206#endif /* CONFIG_HOTPLUG */
210 207
211static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table * res) 208static int pnpbios_get_resources(struct pnp_dev *dev,
209 struct pnp_resource_table *res)
212{ 210{
213 u8 nodenum = dev->number; 211 u8 nodenum = dev->number;
214 struct pnp_bios_node * node; 212 struct pnp_bios_node *node;
215 213
216 /* just in case */ 214 /* just in case */
217 if(!pnpbios_is_dynamic(dev)) 215 if (!pnpbios_is_dynamic(dev))
218 return -EPERM; 216 return -EPERM;
219 217
220 node = kzalloc(node_info.max_node_size, GFP_KERNEL); 218 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
221 if (!node) 219 if (!node)
222 return -1; 220 return -1;
223 if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { 221 if (pnp_bios_get_dev_node(&nodenum, (char)PNPMODE_DYNAMIC, node)) {
224 kfree(node); 222 kfree(node);
225 return -ENODEV; 223 return -ENODEV;
226 } 224 }
@@ -230,10 +228,11 @@ static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table
230 return 0; 228 return 0;
231} 229}
232 230
233static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table * res) 231static int pnpbios_set_resources(struct pnp_dev *dev,
232 struct pnp_resource_table *res)
234{ 233{
235 u8 nodenum = dev->number; 234 u8 nodenum = dev->number;
236 struct pnp_bios_node * node; 235 struct pnp_bios_node *node;
237 int ret; 236 int ret;
238 237
239 /* just in case */ 238 /* just in case */
@@ -243,11 +242,11 @@ static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table
243 node = kzalloc(node_info.max_node_size, GFP_KERNEL); 242 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
244 if (!node) 243 if (!node)
245 return -1; 244 return -1;
246 if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { 245 if (pnp_bios_get_dev_node(&nodenum, (char)PNPMODE_DYNAMIC, node)) {
247 kfree(node); 246 kfree(node);
248 return -ENODEV; 247 return -ENODEV;
249 } 248 }
250 if(pnpbios_write_resources_to_node(res, node)<0) { 249 if (pnpbios_write_resources_to_node(res, node) < 0) {
251 kfree(node); 250 kfree(node);
252 return -1; 251 return -1;
253 } 252 }
@@ -258,18 +257,18 @@ static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table
258 return ret; 257 return ret;
259} 258}
260 259
261static void pnpbios_zero_data_stream(struct pnp_bios_node * node) 260static void pnpbios_zero_data_stream(struct pnp_bios_node *node)
262{ 261{
263 unsigned char * p = (char *)node->data; 262 unsigned char *p = (char *)node->data;
264 unsigned char * end = (char *)(node->data + node->size); 263 unsigned char *end = (char *)(node->data + node->size);
265 unsigned int len; 264 unsigned int len;
266 int i; 265 int i;
267 while ((char *)p < (char *)end) { 266 while ((char *)p < (char *)end) {
268 if(p[0] & 0x80) { /* large tag */ 267 if (p[0] & 0x80) { /* large tag */
269 len = (p[2] << 8) | p[1]; 268 len = (p[2] << 8) | p[1];
270 p += 3; 269 p += 3;
271 } else { 270 } else {
272 if (((p[0]>>3) & 0x0f) == 0x0f) 271 if (((p[0] >> 3) & 0x0f) == 0x0f)
273 return; 272 return;
274 len = p[0] & 0x07; 273 len = p[0] & 0x07;
275 p += 1; 274 p += 1;
@@ -278,24 +277,25 @@ static void pnpbios_zero_data_stream(struct pnp_bios_node * node)
278 p[i] = 0; 277 p[i] = 0;
279 p += len; 278 p += len;
280 } 279 }
281 printk(KERN_ERR "PnPBIOS: Resource structure did not contain an end tag.\n"); 280 printk(KERN_ERR
281 "PnPBIOS: Resource structure did not contain an end tag.\n");
282} 282}
283 283
284static int pnpbios_disable_resources(struct pnp_dev *dev) 284static int pnpbios_disable_resources(struct pnp_dev *dev)
285{ 285{
286 struct pnp_bios_node * node; 286 struct pnp_bios_node *node;
287 u8 nodenum = dev->number; 287 u8 nodenum = dev->number;
288 int ret; 288 int ret;
289 289
290 /* just in case */ 290 /* just in case */
291 if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev)) 291 if (dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev))
292 return -EPERM; 292 return -EPERM;
293 293
294 node = kzalloc(node_info.max_node_size, GFP_KERNEL); 294 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
295 if (!node) 295 if (!node)
296 return -ENOMEM; 296 return -ENOMEM;
297 297
298 if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { 298 if (pnp_bios_get_dev_node(&nodenum, (char)PNPMODE_DYNAMIC, node)) {
299 kfree(node); 299 kfree(node);
300 return -ENODEV; 300 return -ENODEV;
301 } 301 }
@@ -311,22 +311,22 @@ static int pnpbios_disable_resources(struct pnp_dev *dev)
311/* PnP Layer support */ 311/* PnP Layer support */
312 312
313struct pnp_protocol pnpbios_protocol = { 313struct pnp_protocol pnpbios_protocol = {
314 .name = "Plug and Play BIOS", 314 .name = "Plug and Play BIOS",
315 .get = pnpbios_get_resources, 315 .get = pnpbios_get_resources,
316 .set = pnpbios_set_resources, 316 .set = pnpbios_set_resources,
317 .disable = pnpbios_disable_resources, 317 .disable = pnpbios_disable_resources,
318}; 318};
319 319
320static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node) 320static int insert_device(struct pnp_dev *dev, struct pnp_bios_node *node)
321{ 321{
322 struct list_head * pos; 322 struct list_head *pos;
323 struct pnp_dev * pnp_dev; 323 struct pnp_dev *pnp_dev;
324 struct pnp_id *dev_id; 324 struct pnp_id *dev_id;
325 char id[8]; 325 char id[8];
326 326
327 /* check if the device is already added */ 327 /* check if the device is already added */
328 dev->number = node->handle; 328 dev->number = node->handle;
329 list_for_each (pos, &pnpbios_protocol.devices){ 329 list_for_each(pos, &pnpbios_protocol.devices) {
330 pnp_dev = list_entry(pos, struct pnp_dev, protocol_list); 330 pnp_dev = list_entry(pos, struct pnp_dev, protocol_list);
331 if (dev->number == pnp_dev->number) 331 if (dev->number == pnp_dev->number)
332 return -1; 332 return -1;
@@ -336,8 +336,8 @@ static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node)
336 dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); 336 dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
337 if (!dev_id) 337 if (!dev_id)
338 return -1; 338 return -1;
339 pnpid32_to_pnpid(node->eisa_id,id); 339 pnpid32_to_pnpid(node->eisa_id, id);
340 memcpy(dev_id->id,id,7); 340 memcpy(dev_id->id, id, 7);
341 pnp_add_id(dev_id, dev); 341 pnp_add_id(dev_id, dev);
342 pnpbios_parse_data_stream(dev, node); 342 pnpbios_parse_data_stream(dev, node);
343 dev->active = pnp_is_active(dev); 343 dev->active = pnp_is_active(dev);
@@ -375,35 +375,41 @@ static void __init build_devlist(void)
375 if (!node) 375 if (!node)
376 return; 376 return;
377 377
378 for(nodenum=0; nodenum<0xff; ) { 378 for (nodenum = 0; nodenum < 0xff;) {
379 u8 thisnodenum = nodenum; 379 u8 thisnodenum = nodenum;
380 /* eventually we will want to use PNPMODE_STATIC here but for now 380 /* eventually we will want to use PNPMODE_STATIC here but for now
381 * dynamic will help us catch buggy bioses to add to the blacklist. 381 * dynamic will help us catch buggy bioses to add to the blacklist.
382 */ 382 */
383 if (!pnpbios_dont_use_current_config) { 383 if (!pnpbios_dont_use_current_config) {
384 if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) 384 if (pnp_bios_get_dev_node
385 (&nodenum, (char)PNPMODE_DYNAMIC, node))
385 break; 386 break;
386 } else { 387 } else {
387 if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_STATIC, node)) 388 if (pnp_bios_get_dev_node
389 (&nodenum, (char)PNPMODE_STATIC, node))
388 break; 390 break;
389 } 391 }
390 nodes_got++; 392 nodes_got++;
391 dev = kzalloc(sizeof (struct pnp_dev), GFP_KERNEL); 393 dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL);
392 if (!dev) 394 if (!dev)
393 break; 395 break;
394 if(insert_device(dev,node)<0) 396 if (insert_device(dev, node) < 0)
395 kfree(dev); 397 kfree(dev);
396 else 398 else
397 devs++; 399 devs++;
398 if (nodenum <= thisnodenum) { 400 if (nodenum <= thisnodenum) {
399 printk(KERN_ERR "PnPBIOS: build_devlist: Node number 0x%x is out of sequence following node 0x%x. Aborting.\n", (unsigned int)nodenum, (unsigned int)thisnodenum); 401 printk(KERN_ERR
402 "PnPBIOS: build_devlist: Node number 0x%x is out of sequence following node 0x%x. Aborting.\n",
403 (unsigned int)nodenum,
404 (unsigned int)thisnodenum);
400 break; 405 break;
401 } 406 }
402 } 407 }
403 kfree(node); 408 kfree(node);
404 409
405 printk(KERN_INFO "PnPBIOS: %i node%s reported by PnP BIOS; %i recorded by driver\n", 410 printk(KERN_INFO
406 nodes_got, nodes_got != 1 ? "s" : "", devs); 411 "PnPBIOS: %i node%s reported by PnP BIOS; %i recorded by driver\n",
412 nodes_got, nodes_got != 1 ? "s" : "", devs);
407} 413}
408 414
409/* 415/*
@@ -412,8 +418,8 @@ static void __init build_devlist(void)
412 * 418 *
413 */ 419 */
414 420
415static int pnpbios_disabled; /* = 0 */ 421static int pnpbios_disabled; /* = 0 */
416int pnpbios_dont_use_current_config; /* = 0 */ 422int pnpbios_dont_use_current_config; /* = 0 */
417 423
418#ifndef MODULE 424#ifndef MODULE
419static int __init pnpbios_setup(char *str) 425static int __init pnpbios_setup(char *str)
@@ -422,9 +428,9 @@ static int __init pnpbios_setup(char *str)
422 428
423 while ((str != NULL) && (*str != '\0')) { 429 while ((str != NULL) && (*str != '\0')) {
424 if (strncmp(str, "off", 3) == 0) 430 if (strncmp(str, "off", 3) == 0)
425 pnpbios_disabled=1; 431 pnpbios_disabled = 1;
426 if (strncmp(str, "on", 2) == 0) 432 if (strncmp(str, "on", 2) == 0)
427 pnpbios_disabled=0; 433 pnpbios_disabled = 0;
428 invert = (strncmp(str, "no-", 3) == 0); 434 invert = (strncmp(str, "no-", 3) == 0);
429 if (invert) 435 if (invert)
430 str += 3; 436 str += 3;
@@ -453,35 +459,41 @@ static int __init pnpbios_probe_system(void)
453 printk(KERN_INFO "PnPBIOS: Scanning system for PnP BIOS support...\n"); 459 printk(KERN_INFO "PnPBIOS: Scanning system for PnP BIOS support...\n");
454 460
455 /* 461 /*
456 * Search the defined area (0xf0000-0xffff0) for a valid PnP BIOS 462 * Search the defined area (0xf0000-0xffff0) for a valid PnP BIOS
457 * structure and, if one is found, sets up the selectors and 463 * structure and, if one is found, sets up the selectors and
458 * entry points 464 * entry points
459 */ 465 */
460 for (check = (union pnp_bios_install_struct *) __va(0xf0000); 466 for (check = (union pnp_bios_install_struct *)__va(0xf0000);
461 check < (union pnp_bios_install_struct *) __va(0xffff0); 467 check < (union pnp_bios_install_struct *)__va(0xffff0);
462 check = (void *)check + 16) { 468 check = (void *)check + 16) {
463 if (check->fields.signature != PNP_SIGNATURE) 469 if (check->fields.signature != PNP_SIGNATURE)
464 continue; 470 continue;
465 printk(KERN_INFO "PnPBIOS: Found PnP BIOS installation structure at 0x%p\n", check); 471 printk(KERN_INFO
472 "PnPBIOS: Found PnP BIOS installation structure at 0x%p\n",
473 check);
466 length = check->fields.length; 474 length = check->fields.length;
467 if (!length) { 475 if (!length) {
468 printk(KERN_ERR "PnPBIOS: installation structure is invalid, skipping\n"); 476 printk(KERN_ERR
477 "PnPBIOS: installation structure is invalid, skipping\n");
469 continue; 478 continue;
470 } 479 }
471 for (sum = 0, i = 0; i < length; i++) 480 for (sum = 0, i = 0; i < length; i++)
472 sum += check->chars[i]; 481 sum += check->chars[i];
473 if (sum) { 482 if (sum) {
474 printk(KERN_ERR "PnPBIOS: installation structure is corrupted, skipping\n"); 483 printk(KERN_ERR
484 "PnPBIOS: installation structure is corrupted, skipping\n");
475 continue; 485 continue;
476 } 486 }
477 if (check->fields.version < 0x10) { 487 if (check->fields.version < 0x10) {
478 printk(KERN_WARNING "PnPBIOS: PnP BIOS version %d.%d is not supported\n", 488 printk(KERN_WARNING
489 "PnPBIOS: PnP BIOS version %d.%d is not supported\n",
479 check->fields.version >> 4, 490 check->fields.version >> 4,
480 check->fields.version & 15); 491 check->fields.version & 15);
481 continue; 492 continue;
482 } 493 }
483 printk(KERN_INFO "PnPBIOS: PnP BIOS version %d.%d, entry 0x%x:0x%x, dseg 0x%x\n", 494 printk(KERN_INFO
484 check->fields.version >> 4, check->fields.version & 15, 495 "PnPBIOS: PnP BIOS version %d.%d, entry 0x%x:0x%x, dseg 0x%x\n",
496 check->fields.version >> 4, check->fields.version & 15,
485 check->fields.pm16cseg, check->fields.pm16offset, 497 check->fields.pm16cseg, check->fields.pm16offset,
486 check->fields.pm16dseg); 498 check->fields.pm16dseg);
487 pnp_bios_install = check; 499 pnp_bios_install = check;
@@ -499,25 +511,25 @@ static int __init exploding_pnp_bios(struct dmi_system_id *d)
499} 511}
500 512
501static struct dmi_system_id pnpbios_dmi_table[] __initdata = { 513static struct dmi_system_id pnpbios_dmi_table[] __initdata = {
502 { /* PnPBIOS GPF on boot */ 514 { /* PnPBIOS GPF on boot */
503 .callback = exploding_pnp_bios, 515 .callback = exploding_pnp_bios,
504 .ident = "Higraded P14H", 516 .ident = "Higraded P14H",
505 .matches = { 517 .matches = {
506 DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."), 518 DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
507 DMI_MATCH(DMI_BIOS_VERSION, "07.00T"), 519 DMI_MATCH(DMI_BIOS_VERSION, "07.00T"),
508 DMI_MATCH(DMI_SYS_VENDOR, "Higraded"), 520 DMI_MATCH(DMI_SYS_VENDOR, "Higraded"),
509 DMI_MATCH(DMI_PRODUCT_NAME, "P14H"), 521 DMI_MATCH(DMI_PRODUCT_NAME, "P14H"),
510 }, 522 },
511 }, 523 },
512 { /* PnPBIOS GPF on boot */ 524 { /* PnPBIOS GPF on boot */
513 .callback = exploding_pnp_bios, 525 .callback = exploding_pnp_bios,
514 .ident = "ASUS P4P800", 526 .ident = "ASUS P4P800",
515 .matches = { 527 .matches = {
516 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc."), 528 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc."),
517 DMI_MATCH(DMI_BOARD_NAME, "P4P800"), 529 DMI_MATCH(DMI_BOARD_NAME, "P4P800"),
518 }, 530 },
519 }, 531 },
520 { } 532 {}
521}; 533};
522 534
523static int __init pnpbios_init(void) 535static int __init pnpbios_init(void)
@@ -533,7 +545,6 @@ static int __init pnpbios_init(void)
533 printk(KERN_INFO "PnPBIOS: Disabled\n"); 545 printk(KERN_INFO "PnPBIOS: Disabled\n");
534 return -ENODEV; 546 return -ENODEV;
535 } 547 }
536
537#ifdef CONFIG_PNPACPI 548#ifdef CONFIG_PNPACPI
538 if (!acpi_disabled && !pnpacpi_disabled) { 549 if (!acpi_disabled && !pnpacpi_disabled) {
539 pnpbios_disabled = 1; 550 pnpbios_disabled = 1;
@@ -552,14 +563,16 @@ static int __init pnpbios_init(void)
552 /* read the node info */ 563 /* read the node info */
553 ret = pnp_bios_dev_node_info(&node_info); 564 ret = pnp_bios_dev_node_info(&node_info);
554 if (ret) { 565 if (ret) {
555 printk(KERN_ERR "PnPBIOS: Unable to get node info. Aborting.\n"); 566 printk(KERN_ERR
567 "PnPBIOS: Unable to get node info. Aborting.\n");
556 return ret; 568 return ret;
557 } 569 }
558 570
559 /* register with the pnp layer */ 571 /* register with the pnp layer */
560 ret = pnp_register_protocol(&pnpbios_protocol); 572 ret = pnp_register_protocol(&pnpbios_protocol);
561 if (ret) { 573 if (ret) {
562 printk(KERN_ERR "PnPBIOS: Unable to register driver. Aborting.\n"); 574 printk(KERN_ERR
575 "PnPBIOS: Unable to register driver. Aborting.\n");
563 return ret; 576 return ret;
564 } 577 }
565 578
diff --git a/drivers/pnp/pnpbios/proc.c b/drivers/pnp/pnpbios/proc.c
index 8027073f7919..b7e1d23e8a4e 100644
--- a/drivers/pnp/pnpbios/proc.c
+++ b/drivers/pnp/pnpbios/proc.c
@@ -37,42 +37,37 @@ static struct proc_dir_entry *proc_pnp = NULL;
37static struct proc_dir_entry *proc_pnp_boot = NULL; 37static struct proc_dir_entry *proc_pnp_boot = NULL;
38 38
39static int proc_read_pnpconfig(char *buf, char **start, off_t pos, 39static int proc_read_pnpconfig(char *buf, char **start, off_t pos,
40 int count, int *eof, void *data) 40 int count, int *eof, void *data)
41{ 41{
42 struct pnp_isa_config_struc pnps; 42 struct pnp_isa_config_struc pnps;
43 43
44 if (pnp_bios_isapnp_config(&pnps)) 44 if (pnp_bios_isapnp_config(&pnps))
45 return -EIO; 45 return -EIO;
46 return snprintf(buf, count, 46 return snprintf(buf, count,
47 "structure_revision %d\n" 47 "structure_revision %d\n"
48 "number_of_CSNs %d\n" 48 "number_of_CSNs %d\n"
49 "ISA_read_data_port 0x%x\n", 49 "ISA_read_data_port 0x%x\n",
50 pnps.revision, 50 pnps.revision, pnps.no_csns, pnps.isa_rd_data_port);
51 pnps.no_csns,
52 pnps.isa_rd_data_port
53 );
54} 51}
55 52
56static int proc_read_escdinfo(char *buf, char **start, off_t pos, 53static int proc_read_escdinfo(char *buf, char **start, off_t pos,
57 int count, int *eof, void *data) 54 int count, int *eof, void *data)
58{ 55{
59 struct escd_info_struc escd; 56 struct escd_info_struc escd;
60 57
61 if (pnp_bios_escd_info(&escd)) 58 if (pnp_bios_escd_info(&escd))
62 return -EIO; 59 return -EIO;
63 return snprintf(buf, count, 60 return snprintf(buf, count,
64 "min_ESCD_write_size %d\n" 61 "min_ESCD_write_size %d\n"
65 "ESCD_size %d\n" 62 "ESCD_size %d\n"
66 "NVRAM_base 0x%x\n", 63 "NVRAM_base 0x%x\n",
67 escd.min_escd_write_size, 64 escd.min_escd_write_size,
68 escd.escd_size, 65 escd.escd_size, escd.nv_storage_base);
69 escd.nv_storage_base
70 );
71} 66}
72 67
73#define MAX_SANE_ESCD_SIZE (32*1024) 68#define MAX_SANE_ESCD_SIZE (32*1024)
74static int proc_read_escd(char *buf, char **start, off_t pos, 69static int proc_read_escd(char *buf, char **start, off_t pos,
75 int count, int *eof, void *data) 70 int count, int *eof, void *data)
76{ 71{
77 struct escd_info_struc escd; 72 struct escd_info_struc escd;
78 char *tmpbuf; 73 char *tmpbuf;
@@ -83,30 +78,36 @@ static int proc_read_escd(char *buf, char **start, off_t pos,
83 78
84 /* sanity check */ 79 /* sanity check */
85 if (escd.escd_size > MAX_SANE_ESCD_SIZE) { 80 if (escd.escd_size > MAX_SANE_ESCD_SIZE) {
86 printk(KERN_ERR "PnPBIOS: proc_read_escd: ESCD size reported by BIOS escd_info call is too great\n"); 81 printk(KERN_ERR
82 "PnPBIOS: proc_read_escd: ESCD size reported by BIOS escd_info call is too great\n");
87 return -EFBIG; 83 return -EFBIG;
88 } 84 }
89 85
90 tmpbuf = kzalloc(escd.escd_size, GFP_KERNEL); 86 tmpbuf = kzalloc(escd.escd_size, GFP_KERNEL);
91 if (!tmpbuf) return -ENOMEM; 87 if (!tmpbuf)
88 return -ENOMEM;
92 89
93 if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) { 90 if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) {
94 kfree(tmpbuf); 91 kfree(tmpbuf);
95 return -EIO; 92 return -EIO;
96 } 93 }
97 94
98 escd_size = (unsigned char)(tmpbuf[0]) + (unsigned char)(tmpbuf[1])*256; 95 escd_size =
96 (unsigned char)(tmpbuf[0]) + (unsigned char)(tmpbuf[1]) * 256;
99 97
100 /* sanity check */ 98 /* sanity check */
101 if (escd_size > MAX_SANE_ESCD_SIZE) { 99 if (escd_size > MAX_SANE_ESCD_SIZE) {
102 printk(KERN_ERR "PnPBIOS: proc_read_escd: ESCD size reported by BIOS read_escd call is too great\n"); 100 printk(KERN_ERR
101 "PnPBIOS: proc_read_escd: ESCD size reported by BIOS read_escd call is too great\n");
103 return -EFBIG; 102 return -EFBIG;
104 } 103 }
105 104
106 escd_left_to_read = escd_size - pos; 105 escd_left_to_read = escd_size - pos;
107 if (escd_left_to_read < 0) escd_left_to_read = 0; 106 if (escd_left_to_read < 0)
108 if (escd_left_to_read == 0) *eof = 1; 107 escd_left_to_read = 0;
109 n = min(count,escd_left_to_read); 108 if (escd_left_to_read == 0)
109 *eof = 1;
110 n = min(count, escd_left_to_read);
110 memcpy(buf, tmpbuf + pos, n); 111 memcpy(buf, tmpbuf + pos, n);
111 kfree(tmpbuf); 112 kfree(tmpbuf);
112 *start = buf; 113 *start = buf;
@@ -114,17 +115,17 @@ static int proc_read_escd(char *buf, char **start, off_t pos,
114} 115}
115 116
116static int proc_read_legacyres(char *buf, char **start, off_t pos, 117static int proc_read_legacyres(char *buf, char **start, off_t pos,
117 int count, int *eof, void *data) 118 int count, int *eof, void *data)
118{ 119{
119 /* Assume that the following won't overflow the buffer */ 120 /* Assume that the following won't overflow the buffer */
120 if (pnp_bios_get_stat_res(buf)) 121 if (pnp_bios_get_stat_res(buf))
121 return -EIO; 122 return -EIO;
122 123
123 return count; // FIXME: Return actual length 124 return count; // FIXME: Return actual length
124} 125}
125 126
126static int proc_read_devices(char *buf, char **start, off_t pos, 127static int proc_read_devices(char *buf, char **start, off_t pos,
127 int count, int *eof, void *data) 128 int count, int *eof, void *data)
128{ 129{
129 struct pnp_bios_node *node; 130 struct pnp_bios_node *node;
130 u8 nodenum; 131 u8 nodenum;
@@ -134,9 +135,10 @@ static int proc_read_devices(char *buf, char **start, off_t pos,
134 return 0; 135 return 0;
135 136
136 node = kzalloc(node_info.max_node_size, GFP_KERNEL); 137 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
137 if (!node) return -ENOMEM; 138 if (!node)
139 return -ENOMEM;
138 140
139 for (nodenum=pos; nodenum<0xff; ) { 141 for (nodenum = pos; nodenum < 0xff;) {
140 u8 thisnodenum = nodenum; 142 u8 thisnodenum = nodenum;
141 /* 26 = the number of characters per line sprintf'ed */ 143 /* 26 = the number of characters per line sprintf'ed */
142 if ((p - buf + 26) > count) 144 if ((p - buf + 26) > count)
@@ -148,7 +150,11 @@ static int proc_read_devices(char *buf, char **start, off_t pos,
148 node->type_code[0], node->type_code[1], 150 node->type_code[0], node->type_code[1],
149 node->type_code[2], node->flags); 151 node->type_code[2], node->flags);
150 if (nodenum <= thisnodenum) { 152 if (nodenum <= thisnodenum) {
151 printk(KERN_ERR "%s Node number 0x%x is out of sequence following node 0x%x. Aborting.\n", "PnPBIOS: proc_read_devices:", (unsigned int)nodenum, (unsigned int)thisnodenum); 153 printk(KERN_ERR
154 "%s Node number 0x%x is out of sequence following node 0x%x. Aborting.\n",
155 "PnPBIOS: proc_read_devices:",
156 (unsigned int)nodenum,
157 (unsigned int)thisnodenum);
152 *eof = 1; 158 *eof = 1;
153 break; 159 break;
154 } 160 }
@@ -156,12 +162,12 @@ static int proc_read_devices(char *buf, char **start, off_t pos,
156 kfree(node); 162 kfree(node);
157 if (nodenum == 0xff) 163 if (nodenum == 0xff)
158 *eof = 1; 164 *eof = 1;
159 *start = (char *)((off_t)nodenum - pos); 165 *start = (char *)((off_t) nodenum - pos);
160 return p - buf; 166 return p - buf;
161} 167}
162 168
163static int proc_read_node(char *buf, char **start, off_t pos, 169static int proc_read_node(char *buf, char **start, off_t pos,
164 int count, int *eof, void *data) 170 int count, int *eof, void *data)
165{ 171{
166 struct pnp_bios_node *node; 172 struct pnp_bios_node *node;
167 int boot = (long)data >> 8; 173 int boot = (long)data >> 8;
@@ -169,7 +175,8 @@ static int proc_read_node(char *buf, char **start, off_t pos,
169 int len; 175 int len;
170 176
171 node = kzalloc(node_info.max_node_size, GFP_KERNEL); 177 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
172 if (!node) return -ENOMEM; 178 if (!node)
179 return -ENOMEM;
173 if (pnp_bios_get_dev_node(&nodenum, boot, node)) { 180 if (pnp_bios_get_dev_node(&nodenum, boot, node)) {
174 kfree(node); 181 kfree(node);
175 return -EIO; 182 return -EIO;
@@ -180,8 +187,8 @@ static int proc_read_node(char *buf, char **start, off_t pos,
180 return len; 187 return len;
181} 188}
182 189
183static int proc_write_node(struct file *file, const char __user *buf, 190static int proc_write_node(struct file *file, const char __user * buf,
184 unsigned long count, void *data) 191 unsigned long count, void *data)
185{ 192{
186 struct pnp_bios_node *node; 193 struct pnp_bios_node *node;
187 int boot = (long)data >> 8; 194 int boot = (long)data >> 8;
@@ -208,12 +215,12 @@ static int proc_write_node(struct file *file, const char __user *buf,
208 goto out; 215 goto out;
209 } 216 }
210 ret = count; 217 ret = count;
211out: 218 out:
212 kfree(node); 219 kfree(node);
213 return ret; 220 return ret;
214} 221}
215 222
216int pnpbios_interface_attach_device(struct pnp_bios_node * node) 223int pnpbios_interface_attach_device(struct pnp_bios_node *node)
217{ 224{
218 char name[3]; 225 char name[3];
219 struct proc_dir_entry *ent; 226 struct proc_dir_entry *ent;
@@ -222,7 +229,7 @@ int pnpbios_interface_attach_device(struct pnp_bios_node * node)
222 229
223 if (!proc_pnp) 230 if (!proc_pnp)
224 return -EIO; 231 return -EIO;
225 if ( !pnpbios_dont_use_current_config ) { 232 if (!pnpbios_dont_use_current_config) {
226 ent = create_proc_entry(name, 0, proc_pnp); 233 ent = create_proc_entry(name, 0, proc_pnp);
227 if (ent) { 234 if (ent) {
228 ent->read_proc = proc_read_node; 235 ent->read_proc = proc_read_node;
@@ -237,7 +244,7 @@ int pnpbios_interface_attach_device(struct pnp_bios_node * node)
237 if (ent) { 244 if (ent) {
238 ent->read_proc = proc_read_node; 245 ent->read_proc = proc_read_node;
239 ent->write_proc = proc_write_node; 246 ent->write_proc = proc_write_node;
240 ent->data = (void *)(long)(node->handle+0x100); 247 ent->data = (void *)(long)(node->handle + 0x100);
241 return 0; 248 return 0;
242 } 249 }
243 250
@@ -249,7 +256,7 @@ int pnpbios_interface_attach_device(struct pnp_bios_node * node)
249 * work and the pnpbios_dont_use_current_config flag 256 * work and the pnpbios_dont_use_current_config flag
250 * should already have been set to the appropriate value 257 * should already have been set to the appropriate value
251 */ 258 */
252int __init pnpbios_proc_init( void ) 259int __init pnpbios_proc_init(void)
253{ 260{
254 proc_pnp = proc_mkdir("pnp", proc_bus); 261 proc_pnp = proc_mkdir("pnp", proc_bus);
255 if (!proc_pnp) 262 if (!proc_pnp)
@@ -258,10 +265,13 @@ int __init pnpbios_proc_init( void )
258 if (!proc_pnp_boot) 265 if (!proc_pnp_boot)
259 return -EIO; 266 return -EIO;
260 create_proc_read_entry("devices", 0, proc_pnp, proc_read_devices, NULL); 267 create_proc_read_entry("devices", 0, proc_pnp, proc_read_devices, NULL);
261 create_proc_read_entry("configuration_info", 0, proc_pnp, proc_read_pnpconfig, NULL); 268 create_proc_read_entry("configuration_info", 0, proc_pnp,
262 create_proc_read_entry("escd_info", 0, proc_pnp, proc_read_escdinfo, NULL); 269 proc_read_pnpconfig, NULL);
270 create_proc_read_entry("escd_info", 0, proc_pnp, proc_read_escdinfo,
271 NULL);
263 create_proc_read_entry("escd", S_IRUSR, proc_pnp, proc_read_escd, NULL); 272 create_proc_read_entry("escd", S_IRUSR, proc_pnp, proc_read_escd, NULL);
264 create_proc_read_entry("legacy_device_resources", 0, proc_pnp, proc_read_legacyres, NULL); 273 create_proc_read_entry("legacy_device_resources", 0, proc_pnp,
274 proc_read_legacyres, NULL);
265 275
266 return 0; 276 return 0;
267} 277}
@@ -274,9 +284,9 @@ void __exit pnpbios_proc_exit(void)
274 if (!proc_pnp) 284 if (!proc_pnp)
275 return; 285 return;
276 286
277 for (i=0; i<0xff; i++) { 287 for (i = 0; i < 0xff; i++) {
278 sprintf(name, "%02x", i); 288 sprintf(name, "%02x", i);
279 if ( !pnpbios_dont_use_current_config ) 289 if (!pnpbios_dont_use_current_config)
280 remove_proc_entry(name, proc_pnp); 290 remove_proc_entry(name, proc_pnp);
281 remove_proc_entry(name, proc_pnp_boot); 291 remove_proc_entry(name, proc_pnp_boot);
282 } 292 }
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index 3c2ab8394e3f..54c34d4d4f44 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -12,7 +12,9 @@
12#ifdef CONFIG_PCI 12#ifdef CONFIG_PCI
13#include <linux/pci.h> 13#include <linux/pci.h>
14#else 14#else
15inline void pcibios_penalize_isa_irq(int irq, int active) {} 15inline void pcibios_penalize_isa_irq(int irq, int active)
16{
17}
16#endif /* CONFIG_PCI */ 18#endif /* CONFIG_PCI */
17 19
18#include "pnpbios.h" 20#include "pnpbios.h"
@@ -53,74 +55,85 @@ inline void pcibios_penalize_isa_irq(int irq, int active) {}
53 */ 55 */
54 56
55static void 57static void
56pnpbios_parse_allocated_irqresource(struct pnp_resource_table * res, int irq) 58pnpbios_parse_allocated_irqresource(struct pnp_resource_table *res, int irq)
57{ 59{
58 int i = 0; 60 int i = 0;
59 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_IRQ) i++; 61 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET)
62 && i < PNP_MAX_IRQ)
63 i++;
60 if (i < PNP_MAX_IRQ) { 64 if (i < PNP_MAX_IRQ) {
61 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag 65 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag
62 if (irq == -1) { 66 if (irq == -1) {
63 res->irq_resource[i].flags |= IORESOURCE_DISABLED; 67 res->irq_resource[i].flags |= IORESOURCE_DISABLED;
64 return; 68 return;
65 } 69 }
66 res->irq_resource[i].start = 70 res->irq_resource[i].start =
67 res->irq_resource[i].end = (unsigned long) irq; 71 res->irq_resource[i].end = (unsigned long)irq;
68 pcibios_penalize_isa_irq(irq, 1); 72 pcibios_penalize_isa_irq(irq, 1);
69 } 73 }
70} 74}
71 75
72static void 76static void
73pnpbios_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma) 77pnpbios_parse_allocated_dmaresource(struct pnp_resource_table *res, int dma)
74{ 78{
75 int i = 0; 79 int i = 0;
76 while (i < PNP_MAX_DMA && 80 while (i < PNP_MAX_DMA &&
77 !(res->dma_resource[i].flags & IORESOURCE_UNSET)) 81 !(res->dma_resource[i].flags & IORESOURCE_UNSET))
78 i++; 82 i++;
79 if (i < PNP_MAX_DMA) { 83 if (i < PNP_MAX_DMA) {
80 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag 84 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag
81 if (dma == -1) { 85 if (dma == -1) {
82 res->dma_resource[i].flags |= IORESOURCE_DISABLED; 86 res->dma_resource[i].flags |= IORESOURCE_DISABLED;
83 return; 87 return;
84 } 88 }
85 res->dma_resource[i].start = 89 res->dma_resource[i].start =
86 res->dma_resource[i].end = (unsigned long) dma; 90 res->dma_resource[i].end = (unsigned long)dma;
87 } 91 }
88} 92}
89 93
90static void 94static void
91pnpbios_parse_allocated_ioresource(struct pnp_resource_table * res, int io, int len) 95pnpbios_parse_allocated_ioresource(struct pnp_resource_table *res, int io,
96 int len)
92{ 97{
93 int i = 0; 98 int i = 0;
94 while (!(res->port_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_PORT) i++; 99 while (!(res->port_resource[i].flags & IORESOURCE_UNSET)
100 && i < PNP_MAX_PORT)
101 i++;
95 if (i < PNP_MAX_PORT) { 102 if (i < PNP_MAX_PORT) {
96 res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag 103 res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag
97 if (len <= 0 || (io + len -1) >= 0x10003) { 104 if (len <= 0 || (io + len - 1) >= 0x10003) {
98 res->port_resource[i].flags |= IORESOURCE_DISABLED; 105 res->port_resource[i].flags |= IORESOURCE_DISABLED;
99 return; 106 return;
100 } 107 }
101 res->port_resource[i].start = (unsigned long) io; 108 res->port_resource[i].start = (unsigned long)io;
102 res->port_resource[i].end = (unsigned long)(io + len - 1); 109 res->port_resource[i].end = (unsigned long)(io + len - 1);
103 } 110 }
104} 111}
105 112
106static void 113static void
107pnpbios_parse_allocated_memresource(struct pnp_resource_table * res, int mem, int len) 114pnpbios_parse_allocated_memresource(struct pnp_resource_table *res, int mem,
115 int len)
108{ 116{
109 int i = 0; 117 int i = 0;
110 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_MEM) i++; 118 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET)
119 && i < PNP_MAX_MEM)
120 i++;
111 if (i < PNP_MAX_MEM) { 121 if (i < PNP_MAX_MEM) {
112 res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag 122 res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag
113 if (len <= 0) { 123 if (len <= 0) {
114 res->mem_resource[i].flags |= IORESOURCE_DISABLED; 124 res->mem_resource[i].flags |= IORESOURCE_DISABLED;
115 return; 125 return;
116 } 126 }
117 res->mem_resource[i].start = (unsigned long) mem; 127 res->mem_resource[i].start = (unsigned long)mem;
118 res->mem_resource[i].end = (unsigned long)(mem + len - 1); 128 res->mem_resource[i].end = (unsigned long)(mem + len - 1);
119 } 129 }
120} 130}
121 131
122static unsigned char * 132static unsigned char *pnpbios_parse_allocated_resource_data(unsigned char *p,
123pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, struct pnp_resource_table * res) 133 unsigned char *end,
134 struct
135 pnp_resource_table
136 *res)
124{ 137{
125 unsigned int len, tag; 138 unsigned int len, tag;
126 int io, size, mask, i; 139 int io, size, mask, i;
@@ -134,12 +147,12 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
134 while ((char *)p < (char *)end) { 147 while ((char *)p < (char *)end) {
135 148
136 /* determine the type of tag */ 149 /* determine the type of tag */
137 if (p[0] & LARGE_TAG) { /* large tag */ 150 if (p[0] & LARGE_TAG) { /* large tag */
138 len = (p[2] << 8) | p[1]; 151 len = (p[2] << 8) | p[1];
139 tag = p[0]; 152 tag = p[0];
140 } else { /* small tag */ 153 } else { /* small tag */
141 len = p[0] & 0x07; 154 len = p[0] & 0x07;
142 tag = ((p[0]>>3) & 0x0f); 155 tag = ((p[0] >> 3) & 0x0f);
143 } 156 }
144 157
145 switch (tag) { 158 switch (tag) {
@@ -147,8 +160,8 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
147 case LARGE_TAG_MEM: 160 case LARGE_TAG_MEM:
148 if (len != 9) 161 if (len != 9)
149 goto len_err; 162 goto len_err;
150 io = *(short *) &p[4]; 163 io = *(short *)&p[4];
151 size = *(short *) &p[10]; 164 size = *(short *)&p[10];
152 pnpbios_parse_allocated_memresource(res, io, size); 165 pnpbios_parse_allocated_memresource(res, io, size);
153 break; 166 break;
154 167
@@ -163,16 +176,16 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
163 case LARGE_TAG_MEM32: 176 case LARGE_TAG_MEM32:
164 if (len != 17) 177 if (len != 17)
165 goto len_err; 178 goto len_err;
166 io = *(int *) &p[4]; 179 io = *(int *)&p[4];
167 size = *(int *) &p[16]; 180 size = *(int *)&p[16];
168 pnpbios_parse_allocated_memresource(res, io, size); 181 pnpbios_parse_allocated_memresource(res, io, size);
169 break; 182 break;
170 183
171 case LARGE_TAG_FIXEDMEM32: 184 case LARGE_TAG_FIXEDMEM32:
172 if (len != 9) 185 if (len != 9)
173 goto len_err; 186 goto len_err;
174 io = *(int *) &p[4]; 187 io = *(int *)&p[4];
175 size = *(int *) &p[8]; 188 size = *(int *)&p[8];
176 pnpbios_parse_allocated_memresource(res, io, size); 189 pnpbios_parse_allocated_memresource(res, io, size);
177 break; 190 break;
178 191
@@ -180,9 +193,10 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
180 if (len < 2 || len > 3) 193 if (len < 2 || len > 3)
181 goto len_err; 194 goto len_err;
182 io = -1; 195 io = -1;
183 mask= p[1] + p[2]*256; 196 mask = p[1] + p[2] * 256;
184 for (i=0;i<16;i++, mask=mask>>1) 197 for (i = 0; i < 16; i++, mask = mask >> 1)
185 if(mask & 0x01) io=i; 198 if (mask & 0x01)
199 io = i;
186 pnpbios_parse_allocated_irqresource(res, io); 200 pnpbios_parse_allocated_irqresource(res, io);
187 break; 201 break;
188 202
@@ -191,15 +205,16 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
191 goto len_err; 205 goto len_err;
192 io = -1; 206 io = -1;
193 mask = p[1]; 207 mask = p[1];
194 for (i=0;i<8;i++, mask = mask>>1) 208 for (i = 0; i < 8; i++, mask = mask >> 1)
195 if(mask & 0x01) io=i; 209 if (mask & 0x01)
210 io = i;
196 pnpbios_parse_allocated_dmaresource(res, io); 211 pnpbios_parse_allocated_dmaresource(res, io);
197 break; 212 break;
198 213
199 case SMALL_TAG_PORT: 214 case SMALL_TAG_PORT:
200 if (len != 7) 215 if (len != 7)
201 goto len_err; 216 goto len_err;
202 io = p[2] + p[3] *256; 217 io = p[2] + p[3] * 256;
203 size = p[7]; 218 size = p[7];
204 pnpbios_parse_allocated_ioresource(res, io, size); 219 pnpbios_parse_allocated_ioresource(res, io, size);
205 break; 220 break;
@@ -218,12 +233,14 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
218 233
219 case SMALL_TAG_END: 234 case SMALL_TAG_END:
220 p = p + 2; 235 p = p + 2;
221 return (unsigned char *)p; 236 return (unsigned char *)p;
222 break; 237 break;
223 238
224 default: /* an unkown tag */ 239 default: /* an unkown tag */
225 len_err: 240 len_err:
226 printk(KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", tag, len); 241 printk(KERN_ERR
242 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
243 tag, len);
227 break; 244 break;
228 } 245 }
229 246
@@ -234,12 +251,12 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
234 p += len + 1; 251 p += len + 1;
235 } 252 }
236 253
237 printk(KERN_ERR "PnPBIOS: Resource structure does not contain an end tag.\n"); 254 printk(KERN_ERR
255 "PnPBIOS: Resource structure does not contain an end tag.\n");
238 256
239 return NULL; 257 return NULL;
240} 258}
241 259
242
243/* 260/*
244 * Resource Configuration Options 261 * Resource Configuration Options
245 */ 262 */
@@ -247,7 +264,7 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
247static void 264static void
248pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option) 265pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option)
249{ 266{
250 struct pnp_mem * mem; 267 struct pnp_mem *mem;
251 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 268 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
252 if (!mem) 269 if (!mem)
253 return; 270 return;
@@ -256,14 +273,15 @@ pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option)
256 mem->align = (p[9] << 8) | p[8]; 273 mem->align = (p[9] << 8) | p[8];
257 mem->size = ((p[11] << 8) | p[10]) << 8; 274 mem->size = ((p[11] << 8) | p[10]) << 8;
258 mem->flags = p[3]; 275 mem->flags = p[3];
259 pnp_register_mem_resource(option,mem); 276 pnp_register_mem_resource(option, mem);
260 return; 277 return;
261} 278}
262 279
263static void 280static void
264pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option) 281pnpbios_parse_mem32_option(unsigned char *p, int size,
282 struct pnp_option *option)
265{ 283{
266 struct pnp_mem * mem; 284 struct pnp_mem *mem;
267 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 285 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
268 if (!mem) 286 if (!mem)
269 return; 287 return;
@@ -272,14 +290,15 @@ pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option
272 mem->align = (p[15] << 24) | (p[14] << 16) | (p[13] << 8) | p[12]; 290 mem->align = (p[15] << 24) | (p[14] << 16) | (p[13] << 8) | p[12];
273 mem->size = (p[19] << 24) | (p[18] << 16) | (p[17] << 8) | p[16]; 291 mem->size = (p[19] << 24) | (p[18] << 16) | (p[17] << 8) | p[16];
274 mem->flags = p[3]; 292 mem->flags = p[3];
275 pnp_register_mem_resource(option,mem); 293 pnp_register_mem_resource(option, mem);
276 return; 294 return;
277} 295}
278 296
279static void 297static void
280pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option *option) 298pnpbios_parse_fixed_mem32_option(unsigned char *p, int size,
299 struct pnp_option *option)
281{ 300{
282 struct pnp_mem * mem; 301 struct pnp_mem *mem;
283 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 302 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
284 if (!mem) 303 if (!mem)
285 return; 304 return;
@@ -287,14 +306,14 @@ pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option *
287 mem->size = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8]; 306 mem->size = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8];
288 mem->align = 0; 307 mem->align = 0;
289 mem->flags = p[3]; 308 mem->flags = p[3];
290 pnp_register_mem_resource(option,mem); 309 pnp_register_mem_resource(option, mem);
291 return; 310 return;
292} 311}
293 312
294static void 313static void
295pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option) 314pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option)
296{ 315{
297 struct pnp_irq * irq; 316 struct pnp_irq *irq;
298 unsigned long bits; 317 unsigned long bits;
299 318
300 irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL); 319 irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
@@ -306,27 +325,27 @@ pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option)
306 irq->flags = p[3]; 325 irq->flags = p[3];
307 else 326 else
308 irq->flags = IORESOURCE_IRQ_HIGHEDGE; 327 irq->flags = IORESOURCE_IRQ_HIGHEDGE;
309 pnp_register_irq_resource(option,irq); 328 pnp_register_irq_resource(option, irq);
310 return; 329 return;
311} 330}
312 331
313static void 332static void
314pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option) 333pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option)
315{ 334{
316 struct pnp_dma * dma; 335 struct pnp_dma *dma;
317 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL); 336 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL);
318 if (!dma) 337 if (!dma)
319 return; 338 return;
320 dma->map = p[1]; 339 dma->map = p[1];
321 dma->flags = p[2]; 340 dma->flags = p[2];
322 pnp_register_dma_resource(option,dma); 341 pnp_register_dma_resource(option, dma);
323 return; 342 return;
324} 343}
325 344
326static void 345static void
327pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option) 346pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option)
328{ 347{
329 struct pnp_port * port; 348 struct pnp_port *port;
330 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 349 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
331 if (!port) 350 if (!port)
332 return; 351 return;
@@ -335,14 +354,15 @@ pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option)
335 port->align = p[6]; 354 port->align = p[6];
336 port->size = p[7]; 355 port->size = p[7];
337 port->flags = p[1] ? PNP_PORT_FLAG_16BITADDR : 0; 356 port->flags = p[1] ? PNP_PORT_FLAG_16BITADDR : 0;
338 pnp_register_port_resource(option,port); 357 pnp_register_port_resource(option, port);
339 return; 358 return;
340} 359}
341 360
342static void 361static void
343pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *option) 362pnpbios_parse_fixed_port_option(unsigned char *p, int size,
363 struct pnp_option *option)
344{ 364{
345 struct pnp_port * port; 365 struct pnp_port *port;
346 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 366 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
347 if (!port) 367 if (!port)
348 return; 368 return;
@@ -350,12 +370,13 @@ pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *o
350 port->size = p[3]; 370 port->size = p[3];
351 port->align = 0; 371 port->align = 0;
352 port->flags = PNP_PORT_FLAG_FIXED; 372 port->flags = PNP_PORT_FLAG_FIXED;
353 pnp_register_port_resource(option,port); 373 pnp_register_port_resource(option, port);
354 return; 374 return;
355} 375}
356 376
357static unsigned char * 377static unsigned char *pnpbios_parse_resource_option_data(unsigned char *p,
358pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struct pnp_dev *dev) 378 unsigned char *end,
379 struct pnp_dev *dev)
359{ 380{
360 unsigned int len, tag; 381 unsigned int len, tag;
361 int priority = 0; 382 int priority = 0;
@@ -371,12 +392,12 @@ pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struc
371 while ((char *)p < (char *)end) { 392 while ((char *)p < (char *)end) {
372 393
373 /* determine the type of tag */ 394 /* determine the type of tag */
374 if (p[0] & LARGE_TAG) { /* large tag */ 395 if (p[0] & LARGE_TAG) { /* large tag */
375 len = (p[2] << 8) | p[1]; 396 len = (p[2] << 8) | p[1];
376 tag = p[0]; 397 tag = p[0];
377 } else { /* small tag */ 398 } else { /* small tag */
378 len = p[0] & 0x07; 399 len = p[0] & 0x07;
379 tag = ((p[0]>>3) & 0x0f); 400 tag = ((p[0] >> 3) & 0x0f);
380 } 401 }
381 402
382 switch (tag) { 403 switch (tag) {
@@ -442,16 +463,19 @@ pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struc
442 if (len != 0) 463 if (len != 0)
443 goto len_err; 464 goto len_err;
444 if (option_independent == option) 465 if (option_independent == option)
445 printk(KERN_WARNING "PnPBIOS: Missing SMALL_TAG_STARTDEP tag\n"); 466 printk(KERN_WARNING
467 "PnPBIOS: Missing SMALL_TAG_STARTDEP tag\n");
446 option = option_independent; 468 option = option_independent;
447 break; 469 break;
448 470
449 case SMALL_TAG_END: 471 case SMALL_TAG_END:
450 return p + 2; 472 return p + 2;
451 473
452 default: /* an unkown tag */ 474 default: /* an unkown tag */
453 len_err: 475 len_err:
454 printk(KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", tag, len); 476 printk(KERN_ERR
477 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
478 tag, len);
455 break; 479 break;
456 } 480 }
457 481
@@ -462,12 +486,12 @@ pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struc
462 p += len + 1; 486 p += len + 1;
463 } 487 }
464 488
465 printk(KERN_ERR "PnPBIOS: Resource structure does not contain an end tag.\n"); 489 printk(KERN_ERR
490 "PnPBIOS: Resource structure does not contain an end tag.\n");
466 491
467 return NULL; 492 return NULL;
468} 493}
469 494
470
471/* 495/*
472 * Compatible Device IDs 496 * Compatible Device IDs
473 */ 497 */
@@ -483,7 +507,7 @@ void pnpid32_to_pnpid(u32 id, char *str)
483 id = be32_to_cpu(id); 507 id = be32_to_cpu(id);
484 str[0] = CHAR(id, 26); 508 str[0] = CHAR(id, 26);
485 str[1] = CHAR(id, 21); 509 str[1] = CHAR(id, 21);
486 str[2] = CHAR(id,16); 510 str[2] = CHAR(id, 16);
487 str[3] = HEX(id, 12); 511 str[3] = HEX(id, 12);
488 str[4] = HEX(id, 8); 512 str[4] = HEX(id, 8);
489 str[5] = HEX(id, 4); 513 str[5] = HEX(id, 4);
@@ -492,12 +516,14 @@ void pnpid32_to_pnpid(u32 id, char *str)
492 516
493 return; 517 return;
494} 518}
519
495// 520//
496#undef CHAR 521#undef CHAR
497#undef HEX 522#undef HEX
498 523
499static unsigned char * 524static unsigned char *pnpbios_parse_compatible_ids(unsigned char *p,
500pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_dev *dev) 525 unsigned char *end,
526 struct pnp_dev *dev)
501{ 527{
502 int len, tag; 528 int len, tag;
503 char id[8]; 529 char id[8];
@@ -509,40 +535,45 @@ pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_de
509 while ((char *)p < (char *)end) { 535 while ((char *)p < (char *)end) {
510 536
511 /* determine the type of tag */ 537 /* determine the type of tag */
512 if (p[0] & LARGE_TAG) { /* large tag */ 538 if (p[0] & LARGE_TAG) { /* large tag */
513 len = (p[2] << 8) | p[1]; 539 len = (p[2] << 8) | p[1];
514 tag = p[0]; 540 tag = p[0];
515 } else { /* small tag */ 541 } else { /* small tag */
516 len = p[0] & 0x07; 542 len = p[0] & 0x07;
517 tag = ((p[0]>>3) & 0x0f); 543 tag = ((p[0] >> 3) & 0x0f);
518 } 544 }
519 545
520 switch (tag) { 546 switch (tag) {
521 547
522 case LARGE_TAG_ANSISTR: 548 case LARGE_TAG_ANSISTR:
523 strncpy(dev->name, p + 3, len >= PNP_NAME_LEN ? PNP_NAME_LEN - 2 : len); 549 strncpy(dev->name, p + 3,
524 dev->name[len >= PNP_NAME_LEN ? PNP_NAME_LEN - 1 : len] = '\0'; 550 len >= PNP_NAME_LEN ? PNP_NAME_LEN - 2 : len);
551 dev->name[len >=
552 PNP_NAME_LEN ? PNP_NAME_LEN - 1 : len] = '\0';
525 break; 553 break;
526 554
527 case SMALL_TAG_COMPATDEVID: /* compatible ID */ 555 case SMALL_TAG_COMPATDEVID: /* compatible ID */
528 if (len != 4) 556 if (len != 4)
529 goto len_err; 557 goto len_err;
530 dev_id = kzalloc(sizeof (struct pnp_id), GFP_KERNEL); 558 dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
531 if (!dev_id) 559 if (!dev_id)
532 return NULL; 560 return NULL;
533 pnpid32_to_pnpid(p[1] | p[2] << 8 | p[3] << 16 | p[4] << 24,id); 561 pnpid32_to_pnpid(p[1] | p[2] << 8 | p[3] << 16 | p[4] <<
562 24, id);
534 memcpy(&dev_id->id, id, 7); 563 memcpy(&dev_id->id, id, 7);
535 pnp_add_id(dev_id, dev); 564 pnp_add_id(dev_id, dev);
536 break; 565 break;
537 566
538 case SMALL_TAG_END: 567 case SMALL_TAG_END:
539 p = p + 2; 568 p = p + 2;
540 return (unsigned char *)p; 569 return (unsigned char *)p;
541 break; 570 break;
542 571
543 default: /* an unkown tag */ 572 default: /* an unkown tag */
544 len_err: 573 len_err:
545 printk(KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", tag, len); 574 printk(KERN_ERR
575 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
576 tag, len);
546 break; 577 break;
547 } 578 }
548 579
@@ -553,17 +584,17 @@ pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_de
553 p += len + 1; 584 p += len + 1;
554 } 585 }
555 586
556 printk(KERN_ERR "PnPBIOS: Resource structure does not contain an end tag.\n"); 587 printk(KERN_ERR
588 "PnPBIOS: Resource structure does not contain an end tag.\n");
557 589
558 return NULL; 590 return NULL;
559} 591}
560 592
561
562/* 593/*
563 * Allocated Resource Encoding 594 * Allocated Resource Encoding
564 */ 595 */
565 596
566static void pnpbios_encode_mem(unsigned char *p, struct resource * res) 597static void pnpbios_encode_mem(unsigned char *p, struct resource *res)
567{ 598{
568 unsigned long base = res->start; 599 unsigned long base = res->start;
569 unsigned long len = res->end - res->start + 1; 600 unsigned long len = res->end - res->start + 1;
@@ -576,7 +607,7 @@ static void pnpbios_encode_mem(unsigned char *p, struct resource * res)
576 return; 607 return;
577} 608}
578 609
579static void pnpbios_encode_mem32(unsigned char *p, struct resource * res) 610static void pnpbios_encode_mem32(unsigned char *p, struct resource *res)
580{ 611{
581 unsigned long base = res->start; 612 unsigned long base = res->start;
582 unsigned long len = res->end - res->start + 1; 613 unsigned long len = res->end - res->start + 1;
@@ -595,8 +626,9 @@ static void pnpbios_encode_mem32(unsigned char *p, struct resource * res)
595 return; 626 return;
596} 627}
597 628
598static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource * res) 629static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource *res)
599{ unsigned long base = res->start; 630{
631 unsigned long base = res->start;
600 unsigned long len = res->end - res->start + 1; 632 unsigned long len = res->end - res->start + 1;
601 p[4] = base & 0xff; 633 p[4] = base & 0xff;
602 p[5] = (base >> 8) & 0xff; 634 p[5] = (base >> 8) & 0xff;
@@ -609,7 +641,7 @@ static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource * res)
609 return; 641 return;
610} 642}
611 643
612static void pnpbios_encode_irq(unsigned char *p, struct resource * res) 644static void pnpbios_encode_irq(unsigned char *p, struct resource *res)
613{ 645{
614 unsigned long map = 0; 646 unsigned long map = 0;
615 map = 1 << res->start; 647 map = 1 << res->start;
@@ -618,7 +650,7 @@ static void pnpbios_encode_irq(unsigned char *p, struct resource * res)
618 return; 650 return;
619} 651}
620 652
621static void pnpbios_encode_dma(unsigned char *p, struct resource * res) 653static void pnpbios_encode_dma(unsigned char *p, struct resource *res)
622{ 654{
623 unsigned long map = 0; 655 unsigned long map = 0;
624 map = 1 << res->start; 656 map = 1 << res->start;
@@ -626,7 +658,7 @@ static void pnpbios_encode_dma(unsigned char *p, struct resource * res)
626 return; 658 return;
627} 659}
628 660
629static void pnpbios_encode_port(unsigned char *p, struct resource * res) 661static void pnpbios_encode_port(unsigned char *p, struct resource *res)
630{ 662{
631 unsigned long base = res->start; 663 unsigned long base = res->start;
632 unsigned long len = res->end - res->start + 1; 664 unsigned long len = res->end - res->start + 1;
@@ -638,7 +670,7 @@ static void pnpbios_encode_port(unsigned char *p, struct resource * res)
638 return; 670 return;
639} 671}
640 672
641static void pnpbios_encode_fixed_port(unsigned char *p, struct resource * res) 673static void pnpbios_encode_fixed_port(unsigned char *p, struct resource *res)
642{ 674{
643 unsigned long base = res->start; 675 unsigned long base = res->start;
644 unsigned long len = res->end - res->start + 1; 676 unsigned long len = res->end - res->start + 1;
@@ -648,8 +680,11 @@ static void pnpbios_encode_fixed_port(unsigned char *p, struct resource * res)
648 return; 680 return;
649} 681}
650 682
651static unsigned char * 683static unsigned char *pnpbios_encode_allocated_resource_data(unsigned char *p,
652pnpbios_encode_allocated_resource_data(unsigned char * p, unsigned char * end, struct pnp_resource_table * res) 684 unsigned char *end,
685 struct
686 pnp_resource_table
687 *res)
653{ 688{
654 unsigned int len, tag; 689 unsigned int len, tag;
655 int port = 0, irq = 0, dma = 0, mem = 0; 690 int port = 0, irq = 0, dma = 0, mem = 0;
@@ -660,12 +695,12 @@ pnpbios_encode_allocated_resource_data(unsigned char * p, unsigned char * end, s
660 while ((char *)p < (char *)end) { 695 while ((char *)p < (char *)end) {
661 696
662 /* determine the type of tag */ 697 /* determine the type of tag */
663 if (p[0] & LARGE_TAG) { /* large tag */ 698 if (p[0] & LARGE_TAG) { /* large tag */
664 len = (p[2] << 8) | p[1]; 699 len = (p[2] << 8) | p[1];
665 tag = p[0]; 700 tag = p[0];
666 } else { /* small tag */ 701 } else { /* small tag */
667 len = p[0] & 0x07; 702 len = p[0] & 0x07;
668 tag = ((p[0]>>3) & 0x0f); 703 tag = ((p[0] >> 3) & 0x0f);
669 } 704 }
670 705
671 switch (tag) { 706 switch (tag) {
@@ -725,12 +760,14 @@ pnpbios_encode_allocated_resource_data(unsigned char * p, unsigned char * end, s
725 760
726 case SMALL_TAG_END: 761 case SMALL_TAG_END:
727 p = p + 2; 762 p = p + 2;
728 return (unsigned char *)p; 763 return (unsigned char *)p;
729 break; 764 break;
730 765
731 default: /* an unkown tag */ 766 default: /* an unkown tag */
732 len_err: 767 len_err:
733 printk(KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", tag, len); 768 printk(KERN_ERR
769 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
770 tag, len);
734 break; 771 break;
735 } 772 }
736 773
@@ -741,28 +778,27 @@ pnpbios_encode_allocated_resource_data(unsigned char * p, unsigned char * end, s
741 p += len + 1; 778 p += len + 1;
742 } 779 }
743 780
744 printk(KERN_ERR "PnPBIOS: Resource structure does not contain an end tag.\n"); 781 printk(KERN_ERR
782 "PnPBIOS: Resource structure does not contain an end tag.\n");
745 783
746 return NULL; 784 return NULL;
747} 785}
748 786
749
750/* 787/*
751 * Core Parsing Functions 788 * Core Parsing Functions
752 */ 789 */
753 790
754int 791int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node *node)
755pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node)
756{ 792{
757 unsigned char * p = (char *)node->data; 793 unsigned char *p = (char *)node->data;
758 unsigned char * end = (char *)(node->data + node->size); 794 unsigned char *end = (char *)(node->data + node->size);
759 p = pnpbios_parse_allocated_resource_data(p,end,&dev->res); 795 p = pnpbios_parse_allocated_resource_data(p, end, &dev->res);
760 if (!p) 796 if (!p)
761 return -EIO; 797 return -EIO;
762 p = pnpbios_parse_resource_option_data(p,end,dev); 798 p = pnpbios_parse_resource_option_data(p, end, dev);
763 if (!p) 799 if (!p)
764 return -EIO; 800 return -EIO;
765 p = pnpbios_parse_compatible_ids(p,end,dev); 801 p = pnpbios_parse_compatible_ids(p, end, dev);
766 if (!p) 802 if (!p)
767 return -EIO; 803 return -EIO;
768 return 0; 804 return 0;
@@ -770,11 +806,11 @@ pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node)
770 806
771int 807int
772pnpbios_read_resources_from_node(struct pnp_resource_table *res, 808pnpbios_read_resources_from_node(struct pnp_resource_table *res,
773 struct pnp_bios_node * node) 809 struct pnp_bios_node *node)
774{ 810{
775 unsigned char * p = (char *)node->data; 811 unsigned char *p = (char *)node->data;
776 unsigned char * end = (char *)(node->data + node->size); 812 unsigned char *end = (char *)(node->data + node->size);
777 p = pnpbios_parse_allocated_resource_data(p,end,res); 813 p = pnpbios_parse_allocated_resource_data(p, end, res);
778 if (!p) 814 if (!p)
779 return -EIO; 815 return -EIO;
780 return 0; 816 return 0;
@@ -782,11 +818,11 @@ pnpbios_read_resources_from_node(struct pnp_resource_table *res,
782 818
783int 819int
784pnpbios_write_resources_to_node(struct pnp_resource_table *res, 820pnpbios_write_resources_to_node(struct pnp_resource_table *res,
785 struct pnp_bios_node * node) 821 struct pnp_bios_node *node)
786{ 822{
787 unsigned char * p = (char *)node->data; 823 unsigned char *p = (char *)node->data;
788 unsigned char * end = (char *)(node->data + node->size); 824 unsigned char *end = (char *)(node->data + node->size);
789 p = pnpbios_encode_allocated_resource_data(p,end,res); 825 p = pnpbios_encode_allocated_resource_data(p, end, res);
790 if (!p) 826 if (!p)
791 return -EIO; 827 return -EIO;
792 return 0; 828 return 0;