aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/pnpbios
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2007-07-26 13:41:21 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-26 14:35:21 -0400
commit07d4e9af109221ab731c5aaf832e89776c64b013 (patch)
tree05d05620af7b1b009f48dbad5f38004b682db271 /drivers/pnp/pnpbios
parent9dd78466c956ac4b4f38e12032dc4249ccf57ad1 (diff)
PNP: fix up after Lindent
These are manual fixups after running Lindent. No functional change. 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.c161
-rw-r--r--drivers/pnp/pnpbios/core.c28
-rw-r--r--drivers/pnp/pnpbios/proc.c5
-rw-r--r--drivers/pnp/pnpbios/rsparser.c99
4 files changed, 103 insertions, 190 deletions
diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
index d546f79d4d3b..5dba68fe33f5 100644
--- a/drivers/pnp/pnpbios/bioscalls.c
+++ b/drivers/pnp/pnpbios/bioscalls.c
@@ -1,6 +1,5 @@
1/* 1/*
2 * bioscalls.c - the lowlevel layer of the PnPBIOS driver 2 * bioscalls.c - the lowlevel layer of the PnPBIOS driver
3 *
4 */ 3 */
5 4
6#include <linux/types.h> 5#include <linux/types.h>
@@ -52,7 +51,8 @@ __asm__(".text \n"
52 " pushl %eax \n" 51 " pushl %eax \n"
53 " lcallw *pnp_bios_callpoint\n" 52 " lcallw *pnp_bios_callpoint\n"
54 " addl $16, %esp \n" 53 " addl $16, %esp \n"
55 " lret \n" ".previous \n"); 54 " lret \n"
55 ".previous \n");
56 56
57#define Q2_SET_SEL(cpu, selname, address, size) \ 57#define Q2_SET_SEL(cpu, selname, address, size) \
58do { \ 58do { \
@@ -125,7 +125,8 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
125 "popl %%es\n\t" 125 "popl %%es\n\t"
126 "popl %%ds\n\t" 126 "popl %%ds\n\t"
127 "popl %%esi\n\t" 127 "popl %%esi\n\t"
128 "popl %%edi\n\t" "popl %%ebp\n\t":"=a"(status) 128 "popl %%edi\n\t"
129 "popl %%ebp\n\t":"=a"(status)
129 :"0"((func) | (((u32) arg1) << 16)), 130 :"0"((func) | (((u32) arg1) << 16)),
130 "b"((arg2) | (((u32) arg3) << 16)), 131 "b"((arg2) | (((u32) arg3) << 16)),
131 "c"((arg4) | (((u32) arg5) << 16)), 132 "c"((arg4) | (((u32) arg5) << 16)),
@@ -253,12 +254,12 @@ void pnpbios_print_status(const char *module, u16 status)
253static int __pnp_bios_dev_node_info(struct pnp_dev_node_info *data) 254static int __pnp_bios_dev_node_info(struct pnp_dev_node_info *data)
254{ 255{
255 u16 status; 256 u16 status;
257
256 if (!pnp_bios_present()) 258 if (!pnp_bios_present())
257 return PNP_FUNCTION_NOT_SUPPORTED; 259 return PNP_FUNCTION_NOT_SUPPORTED;
258 status = 260 status = call_pnp_bios(PNP_GET_NUM_SYS_DEV_NODES, 0, PNP_TS1, 2,
259 call_pnp_bios(PNP_GET_NUM_SYS_DEV_NODES, 0, PNP_TS1, 2, PNP_TS1, 261 PNP_TS1, PNP_DS, 0, 0, data,
260 PNP_DS, 0, 0, data, sizeof(struct pnp_dev_node_info), 262 sizeof(struct pnp_dev_node_info), NULL, 0);
261 NULL, 0);
262 data->no_nodes &= 0xff; 263 data->no_nodes &= 0xff;
263 return status; 264 return status;
264} 265}
@@ -266,6 +267,7 @@ static int __pnp_bios_dev_node_info(struct pnp_dev_node_info *data)
266int pnp_bios_dev_node_info(struct pnp_dev_node_info *data) 267int pnp_bios_dev_node_info(struct pnp_dev_node_info *data)
267{ 268{
268 int status = __pnp_bios_dev_node_info(data); 269 int status = __pnp_bios_dev_node_info(data);
270
269 if (status) 271 if (status)
270 pnpbios_print_status("dev_node_info", status); 272 pnpbios_print_status("dev_node_info", status);
271 return status; 273 return status;
@@ -285,27 +287,28 @@ int pnp_bios_dev_node_info(struct pnp_dev_node_info *data)
285 * or volatile current (0) config 287 * or volatile current (0) config
286 * Output: *nodenum=next node or 0xff if no more nodes 288 * Output: *nodenum=next node or 0xff if no more nodes
287 */ 289 */
288static int __pnp_bios_get_dev_node(u8 * nodenum, char boot, 290static int __pnp_bios_get_dev_node(u8 *nodenum, char boot,
289 struct pnp_bios_node *data) 291 struct pnp_bios_node *data)
290{ 292{
291 u16 status; 293 u16 status;
292 u16 tmp_nodenum; 294 u16 tmp_nodenum;
295
293 if (!pnp_bios_present()) 296 if (!pnp_bios_present())
294 return PNP_FUNCTION_NOT_SUPPORTED; 297 return PNP_FUNCTION_NOT_SUPPORTED;
295 if (!boot && pnpbios_dont_use_current_config) 298 if (!boot && pnpbios_dont_use_current_config)
296 return PNP_FUNCTION_NOT_SUPPORTED; 299 return PNP_FUNCTION_NOT_SUPPORTED;
297 tmp_nodenum = *nodenum; 300 tmp_nodenum = *nodenum;
298 status = 301 status = call_pnp_bios(PNP_GET_SYS_DEV_NODE, 0, PNP_TS1, 0, PNP_TS2,
299 call_pnp_bios(PNP_GET_SYS_DEV_NODE, 0, PNP_TS1, 0, PNP_TS2, 302 boot ? 2 : 1, PNP_DS, 0, &tmp_nodenum,
300 boot ? 2 : 1, PNP_DS, 0, &tmp_nodenum, 303 sizeof(tmp_nodenum), data, 65536);
301 sizeof(tmp_nodenum), data, 65536);
302 *nodenum = tmp_nodenum; 304 *nodenum = tmp_nodenum;
303 return status; 305 return status;
304} 306}
305 307
306int pnp_bios_get_dev_node(u8 * nodenum, char boot, struct pnp_bios_node *data) 308int pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node *data)
307{ 309{
308 int status; 310 int status;
311
309 status = __pnp_bios_get_dev_node(nodenum, boot, data); 312 status = __pnp_bios_get_dev_node(nodenum, boot, data);
310 if (status) 313 if (status)
311 pnpbios_print_status("get_dev_node", status); 314 pnpbios_print_status("get_dev_node", status);
@@ -322,19 +325,21 @@ static int __pnp_bios_set_dev_node(u8 nodenum, char boot,
322 struct pnp_bios_node *data) 325 struct pnp_bios_node *data)
323{ 326{
324 u16 status; 327 u16 status;
328
325 if (!pnp_bios_present()) 329 if (!pnp_bios_present())
326 return PNP_FUNCTION_NOT_SUPPORTED; 330 return PNP_FUNCTION_NOT_SUPPORTED;
327 if (!boot && pnpbios_dont_use_current_config) 331 if (!boot && pnpbios_dont_use_current_config)
328 return PNP_FUNCTION_NOT_SUPPORTED; 332 return PNP_FUNCTION_NOT_SUPPORTED;
329 status = 333 status = call_pnp_bios(PNP_SET_SYS_DEV_NODE, nodenum, 0, PNP_TS1,
330 call_pnp_bios(PNP_SET_SYS_DEV_NODE, nodenum, 0, PNP_TS1, 334 boot ? 2 : 1, PNP_DS, 0, 0, data, 65536, NULL,
331 boot ? 2 : 1, PNP_DS, 0, 0, data, 65536, NULL, 0); 335 0);
332 return status; 336 return status;
333} 337}
334 338
335int pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data) 339int pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data)
336{ 340{
337 int status; 341 int status;
342
338 status = __pnp_bios_set_dev_node(nodenum, boot, data); 343 status = __pnp_bios_set_dev_node(nodenum, boot, data);
339 if (status) { 344 if (status) {
340 pnpbios_print_status("set_dev_node", status); 345 pnpbios_print_status("set_dev_node", status);
@@ -348,68 +353,21 @@ int pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data)
348 return status; 353 return status;
349} 354}
350 355
351#if needed
352/*
353 * Call PnP BIOS with function 0x03, "get event"
354 */
355static int pnp_bios_get_event(u16 * event)
356{
357 u16 status;
358 if (!pnp_bios_present())
359 return PNP_FUNCTION_NOT_SUPPORTED;
360 status = call_pnp_bios(PNP_GET_EVENT, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0,
361 event, sizeof(u16), NULL, 0);
362 return status;
363}
364#endif
365
366#if needed
367/*
368 * Call PnP BIOS with function 0x04, "send message"
369 */
370static int pnp_bios_send_message(u16 message)
371{
372 u16 status;
373 if (!pnp_bios_present())
374 return PNP_FUNCTION_NOT_SUPPORTED;
375 status =
376 call_pnp_bios(PNP_SEND_MESSAGE, message, PNP_DS, 0, 0, 0, 0, 0, 0,
377 0, 0, 0);
378 return status;
379}
380#endif
381
382/* 356/*
383 * Call PnP BIOS with function 0x05, "get docking station information" 357 * Call PnP BIOS with function 0x05, "get docking station information"
384 */ 358 */
385int pnp_bios_dock_station_info(struct pnp_docking_station_info *data) 359int pnp_bios_dock_station_info(struct pnp_docking_station_info *data)
386{ 360{
387 u16 status; 361 u16 status;
388 if (!pnp_bios_present())
389 return PNP_FUNCTION_NOT_SUPPORTED;
390 status =
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);
394 return status;
395}
396 362
397#if needed
398/*
399 * Call PnP BIOS with function 0x09, "set statically allocated resource
400 * information"
401 */
402static int pnp_bios_set_stat_res(char *info)
403{
404 u16 status;
405 if (!pnp_bios_present()) 363 if (!pnp_bios_present())
406 return PNP_FUNCTION_NOT_SUPPORTED; 364 return PNP_FUNCTION_NOT_SUPPORTED;
407 status = 365 status = call_pnp_bios(PNP_GET_DOCKING_STATION_INFORMATION, 0, PNP_TS1,
408 call_pnp_bios(PNP_SET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1, PNP_DS, 366 PNP_DS, 0, 0, 0, 0, data,
409 0, 0, 0, 0, info, *((u16 *) info), 0, 0); 367 sizeof(struct pnp_docking_station_info), NULL,
368 0);
410 return status; 369 return status;
411} 370}
412#endif
413 371
414/* 372/*
415 * Call PnP BIOS with function 0x0a, "get statically allocated resource 373 * Call PnP BIOS with function 0x0a, "get statically allocated resource
@@ -418,57 +376,43 @@ static int pnp_bios_set_stat_res(char *info)
418static int __pnp_bios_get_stat_res(char *info) 376static int __pnp_bios_get_stat_res(char *info)
419{ 377{
420 u16 status; 378 u16 status;
379
421 if (!pnp_bios_present()) 380 if (!pnp_bios_present())
422 return PNP_FUNCTION_NOT_SUPPORTED; 381 return PNP_FUNCTION_NOT_SUPPORTED;
423 status = 382 status = call_pnp_bios(PNP_GET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1,
424 call_pnp_bios(PNP_GET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1, PNP_DS, 383 PNP_DS, 0, 0, 0, 0, info, 65536, NULL, 0);
425 0, 0, 0, 0, info, 65536, NULL, 0);
426 return status; 384 return status;
427} 385}
428 386
429int pnp_bios_get_stat_res(char *info) 387int pnp_bios_get_stat_res(char *info)
430{ 388{
431 int status; 389 int status;
390
432 status = __pnp_bios_get_stat_res(info); 391 status = __pnp_bios_get_stat_res(info);
433 if (status) 392 if (status)
434 pnpbios_print_status("get_stat_res", status); 393 pnpbios_print_status("get_stat_res", status);
435 return status; 394 return status;
436} 395}
437 396
438#if needed
439/*
440 * Call PnP BIOS with function 0x0b, "get APM id table"
441 */
442static int pnp_bios_apm_id_table(char *table, u16 * size)
443{
444 u16 status;
445 if (!pnp_bios_present())
446 return PNP_FUNCTION_NOT_SUPPORTED;
447 status =
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));
450 return status;
451}
452#endif
453
454/* 397/*
455 * Call PnP BIOS with function 0x40, "get isa pnp configuration structure" 398 * Call PnP BIOS with function 0x40, "get isa pnp configuration structure"
456 */ 399 */
457static int __pnp_bios_isapnp_config(struct pnp_isa_config_struc *data) 400static int __pnp_bios_isapnp_config(struct pnp_isa_config_struc *data)
458{ 401{
459 u16 status; 402 u16 status;
403
460 if (!pnp_bios_present()) 404 if (!pnp_bios_present())
461 return PNP_FUNCTION_NOT_SUPPORTED; 405 return PNP_FUNCTION_NOT_SUPPORTED;
462 status = 406 status = call_pnp_bios(PNP_GET_PNP_ISA_CONFIG_STRUC, 0, PNP_TS1, PNP_DS,
463 call_pnp_bios(PNP_GET_PNP_ISA_CONFIG_STRUC, 0, PNP_TS1, PNP_DS, 0, 407 0, 0, 0, 0, data,
464 0, 0, 0, data, sizeof(struct pnp_isa_config_struc), 408 sizeof(struct pnp_isa_config_struc), NULL, 0);
465 NULL, 0);
466 return status; 409 return status;
467} 410}
468 411
469int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data) 412int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data)
470{ 413{
471 int status; 414 int status;
415
472 status = __pnp_bios_isapnp_config(data); 416 status = __pnp_bios_isapnp_config(data);
473 if (status) 417 if (status)
474 pnpbios_print_status("isapnp_config", status); 418 pnpbios_print_status("isapnp_config", status);
@@ -481,18 +425,19 @@ int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data)
481static int __pnp_bios_escd_info(struct escd_info_struc *data) 425static int __pnp_bios_escd_info(struct escd_info_struc *data)
482{ 426{
483 u16 status; 427 u16 status;
428
484 if (!pnp_bios_present()) 429 if (!pnp_bios_present())
485 return ESCD_FUNCTION_NOT_SUPPORTED; 430 return ESCD_FUNCTION_NOT_SUPPORTED;
486 status = 431 status = call_pnp_bios(PNP_GET_ESCD_INFO, 0, PNP_TS1, 2, PNP_TS1, 4,
487 call_pnp_bios(PNP_GET_ESCD_INFO, 0, PNP_TS1, 2, PNP_TS1, 4, PNP_TS1, 432 PNP_TS1, PNP_DS, data,
488 PNP_DS, data, sizeof(struct escd_info_struc), NULL, 433 sizeof(struct escd_info_struc), NULL, 0);
489 0);
490 return status; 434 return status;
491} 435}
492 436
493int pnp_bios_escd_info(struct escd_info_struc *data) 437int pnp_bios_escd_info(struct escd_info_struc *data)
494{ 438{
495 int status; 439 int status;
440
496 status = __pnp_bios_escd_info(data); 441 status = __pnp_bios_escd_info(data);
497 if (status) 442 if (status)
498 pnpbios_print_status("escd_info", status); 443 pnpbios_print_status("escd_info", status);
@@ -506,46 +451,28 @@ int pnp_bios_escd_info(struct escd_info_struc *data)
506static int __pnp_bios_read_escd(char *data, u32 nvram_base) 451static int __pnp_bios_read_escd(char *data, u32 nvram_base)
507{ 452{
508 u16 status; 453 u16 status;
454
509 if (!pnp_bios_present()) 455 if (!pnp_bios_present())
510 return ESCD_FUNCTION_NOT_SUPPORTED; 456 return ESCD_FUNCTION_NOT_SUPPORTED;
511 status = 457 status = call_pnp_bios(PNP_READ_ESCD, 0, PNP_TS1, PNP_TS2, PNP_DS, 0, 0,
512 call_pnp_bios(PNP_READ_ESCD, 0, PNP_TS1, PNP_TS2, PNP_DS, 0, 0, 0, 458 0, data, 65536, __va(nvram_base), 65536);
513 data, 65536, __va(nvram_base), 65536);
514 return status; 459 return status;
515} 460}
516 461
517int pnp_bios_read_escd(char *data, u32 nvram_base) 462int pnp_bios_read_escd(char *data, u32 nvram_base)
518{ 463{
519 int status; 464 int status;
465
520 status = __pnp_bios_read_escd(data, nvram_base); 466 status = __pnp_bios_read_escd(data, nvram_base);
521 if (status) 467 if (status)
522 pnpbios_print_status("read_escd", status); 468 pnpbios_print_status("read_escd", status);
523 return status; 469 return status;
524} 470}
525 471
526#if needed
527/*
528 * Call PnP BIOS function 0x43, "write ESCD"
529 */
530static int pnp_bios_write_escd(char *data, u32 nvram_base)
531{
532 u16 status;
533 if (!pnp_bios_present())
534 return ESCD_FUNCTION_NOT_SUPPORTED;
535 status =
536 call_pnp_bios(PNP_WRITE_ESCD, 0, PNP_TS1, PNP_TS2, PNP_DS, 0, 0, 0,
537 data, 65536, __va(nvram_base), 65536);
538 return status;
539}
540#endif
541
542/*
543 * Initialization
544 */
545
546void pnpbios_calls_init(union pnp_bios_install_struct *header) 472void pnpbios_calls_init(union pnp_bios_install_struct *header)
547{ 473{
548 int i; 474 int i;
475
549 spin_lock_init(&pnp_bios_lock); 476 spin_lock_init(&pnp_bios_lock);
550 pnp_bios_callpoint.offset = header->fields.pm16offset; 477 pnp_bios_callpoint.offset = header->fields.pm16offset;
551 pnp_bios_callpoint.segment = PNP_CS16; 478 pnp_bios_callpoint.segment = PNP_CS16;
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
index 21289cb13a33..3692a099b45f 100644
--- a/drivers/pnp/pnpbios/core.c
+++ b/drivers/pnp/pnpbios/core.c
@@ -100,25 +100,24 @@ static struct completion unload_sem;
100/* 100/*
101 * (Much of this belongs in a shared routine somewhere) 101 * (Much of this belongs in a shared routine somewhere)
102 */ 102 */
103
104static int pnp_dock_event(int dock, struct pnp_docking_station_info *info) 103static int pnp_dock_event(int dock, struct pnp_docking_station_info *info)
105{ 104{
106 char *argv[3], **envp, *buf, *scratch; 105 char *argv[3], **envp, *buf, *scratch;
107 int i = 0, value; 106 int i = 0, value;
108 107
109 if (!current->fs->root) { 108 if (!current->fs->root)
110 return -EAGAIN; 109 return -EAGAIN;
111 } 110 if (!(envp = kcalloc(20, sizeof(char *), GFP_KERNEL)))
112 if (!(envp = kcalloc(20, sizeof(char *), GFP_KERNEL))) {
113 return -ENOMEM; 111 return -ENOMEM;
114 }
115 if (!(buf = kzalloc(256, GFP_KERNEL))) { 112 if (!(buf = kzalloc(256, GFP_KERNEL))) {
116 kfree(envp); 113 kfree(envp);
117 return -ENOMEM; 114 return -ENOMEM;
118 } 115 }
119 116
120 /* FIXME: if there are actual users of this, it should be integrated into 117 /* FIXME: if there are actual users of this, it should be
121 * the driver core and use the usual infrastructure like sysfs and uevents */ 118 * integrated into the driver core and use the usual infrastructure
119 * like sysfs and uevents
120 */
122 argv[0] = "/sbin/pnpbios"; 121 argv[0] = "/sbin/pnpbios";
123 argv[1] = "dock"; 122 argv[1] = "dock";
124 argv[2] = NULL; 123 argv[2] = NULL;
@@ -146,7 +145,7 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info)
146 info->location_id, info->serial, info->capabilities); 145 info->location_id, info->serial, info->capabilities);
147 envp[i] = NULL; 146 envp[i] = NULL;
148 147
149 value = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC); 148 value = call_usermodehelper(argv [0], argv, envp, UMH_WAIT_EXEC);
150 kfree(buf); 149 kfree(buf);
151 kfree(envp); 150 kfree(envp);
152 return 0; 151 return 0;
@@ -159,6 +158,7 @@ static int pnp_dock_thread(void *unused)
159{ 158{
160 static struct pnp_docking_station_info now; 159 static struct pnp_docking_station_info now;
161 int docked = -1, d = 0; 160 int docked = -1, d = 0;
161
162 set_freezable(); 162 set_freezable();
163 while (!unloading) { 163 while (!unloading) {
164 int status; 164 int status;
@@ -203,7 +203,7 @@ static int pnp_dock_thread(void *unused)
203 complete_and_exit(&unload_sem, 0); 203 complete_and_exit(&unload_sem, 0);
204} 204}
205 205
206#endif /* CONFIG_HOTPLUG */ 206#endif /* CONFIG_HOTPLUG */
207 207
208static int pnpbios_get_resources(struct pnp_dev *dev, 208static int pnpbios_get_resources(struct pnp_dev *dev,
209 struct pnp_resource_table *res) 209 struct pnp_resource_table *res)
@@ -211,7 +211,6 @@ static int pnpbios_get_resources(struct pnp_dev *dev,
211 u8 nodenum = dev->number; 211 u8 nodenum = dev->number;
212 struct pnp_bios_node *node; 212 struct pnp_bios_node *node;
213 213
214 /* just in case */
215 if (!pnpbios_is_dynamic(dev)) 214 if (!pnpbios_is_dynamic(dev))
216 return -EPERM; 215 return -EPERM;
217 216
@@ -235,7 +234,6 @@ static int pnpbios_set_resources(struct pnp_dev *dev,
235 struct pnp_bios_node *node; 234 struct pnp_bios_node *node;
236 int ret; 235 int ret;
237 236
238 /* just in case */
239 if (!pnpbios_is_dynamic(dev)) 237 if (!pnpbios_is_dynamic(dev))
240 return -EPERM; 238 return -EPERM;
241 239
@@ -263,6 +261,7 @@ static void pnpbios_zero_data_stream(struct pnp_bios_node *node)
263 unsigned char *end = (char *)(node->data + node->size); 261 unsigned char *end = (char *)(node->data + node->size);
264 unsigned int len; 262 unsigned int len;
265 int i; 263 int i;
264
266 while ((char *)p < (char *)end) { 265 while ((char *)p < (char *)end) {
267 if (p[0] & 0x80) { /* large tag */ 266 if (p[0] & 0x80) { /* large tag */
268 len = (p[2] << 8) | p[1]; 267 len = (p[2] << 8) | p[1];
@@ -287,7 +286,6 @@ static int pnpbios_disable_resources(struct pnp_dev *dev)
287 u8 nodenum = dev->number; 286 u8 nodenum = dev->number;
288 int ret; 287 int ret;
289 288
290 /* just in case */
291 if (dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev)) 289 if (dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev))
292 return -EPERM; 290 return -EPERM;
293 291
@@ -418,8 +416,8 @@ static void __init build_devlist(void)
418 * 416 *
419 */ 417 */
420 418
421static int pnpbios_disabled; /* = 0 */ 419static int pnpbios_disabled;
422int pnpbios_dont_use_current_config; /* = 0 */ 420int pnpbios_dont_use_current_config;
423 421
424#ifndef MODULE 422#ifndef MODULE
425static int __init pnpbios_setup(char *str) 423static int __init pnpbios_setup(char *str)
@@ -551,7 +549,7 @@ static int __init pnpbios_init(void)
551 printk(KERN_INFO "PnPBIOS: Disabled by ACPI PNP\n"); 549 printk(KERN_INFO "PnPBIOS: Disabled by ACPI PNP\n");
552 return -ENODEV; 550 return -ENODEV;
553 } 551 }
554#endif /* CONFIG_ACPI */ 552#endif /* CONFIG_ACPI */
555 553
556 /* scan the system for pnpbios support */ 554 /* scan the system for pnpbios support */
557 if (!pnpbios_probe_system()) 555 if (!pnpbios_probe_system())
diff --git a/drivers/pnp/pnpbios/proc.c b/drivers/pnp/pnpbios/proc.c
index b7e1d23e8a4e..9c8c07701b65 100644
--- a/drivers/pnp/pnpbios/proc.c
+++ b/drivers/pnp/pnpbios/proc.c
@@ -18,9 +18,6 @@
18 * The other files are human-readable. 18 * The other files are human-readable.
19 */ 19 */
20 20
21//#include <pcmcia/config.h>
22//#include <pcmcia/k_compat.h>
23
24#include <linux/module.h> 21#include <linux/module.h>
25#include <linux/kernel.h> 22#include <linux/kernel.h>
26#include <linux/slab.h> 23#include <linux/slab.h>
@@ -297,6 +294,4 @@ void __exit pnpbios_proc_exit(void)
297 remove_proc_entry("devices", proc_pnp); 294 remove_proc_entry("devices", proc_pnp);
298 remove_proc_entry("boot", proc_pnp); 295 remove_proc_entry("boot", proc_pnp);
299 remove_proc_entry("pnp", proc_bus); 296 remove_proc_entry("pnp", proc_bus);
300
301 return;
302} 297}
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index 54c34d4d4f44..04ecd7b67230 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -1,6 +1,5 @@
1/* 1/*
2 * rsparser.c - parses and encodes pnpbios resource data streams 2 * rsparser.c - parses and encodes pnpbios resource data streams
3 *
4 */ 3 */
5 4
6#include <linux/ctype.h> 5#include <linux/ctype.h>
@@ -15,7 +14,7 @@
15inline void pcibios_penalize_isa_irq(int irq, int active) 14inline void pcibios_penalize_isa_irq(int irq, int active)
16{ 15{
17} 16}
18#endif /* CONFIG_PCI */ 17#endif /* CONFIG_PCI */
19 18
20#include "pnpbios.h" 19#include "pnpbios.h"
21 20
@@ -54,10 +53,11 @@ inline void pcibios_penalize_isa_irq(int irq, int active)
54 * Allocated Resources 53 * Allocated Resources
55 */ 54 */
56 55
57static void 56static void pnpbios_parse_allocated_irqresource(struct pnp_resource_table *res,
58pnpbios_parse_allocated_irqresource(struct pnp_resource_table *res, int irq) 57 int irq)
59{ 58{
60 int i = 0; 59 int i = 0;
60
61 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) 61 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET)
62 && i < PNP_MAX_IRQ) 62 && i < PNP_MAX_IRQ)
63 i++; 63 i++;
@@ -73,10 +73,11 @@ pnpbios_parse_allocated_irqresource(struct pnp_resource_table *res, int irq)
73 } 73 }
74} 74}
75 75
76static void 76static void pnpbios_parse_allocated_dmaresource(struct pnp_resource_table *res,
77pnpbios_parse_allocated_dmaresource(struct pnp_resource_table *res, int dma) 77 int dma)
78{ 78{
79 int i = 0; 79 int i = 0;
80
80 while (i < PNP_MAX_DMA && 81 while (i < PNP_MAX_DMA &&
81 !(res->dma_resource[i].flags & IORESOURCE_UNSET)) 82 !(res->dma_resource[i].flags & IORESOURCE_UNSET))
82 i++; 83 i++;
@@ -91,11 +92,11 @@ pnpbios_parse_allocated_dmaresource(struct pnp_resource_table *res, int dma)
91 } 92 }
92} 93}
93 94
94static void 95static void pnpbios_parse_allocated_ioresource(struct pnp_resource_table *res,
95pnpbios_parse_allocated_ioresource(struct pnp_resource_table *res, int io, 96 int io, int len)
96 int len)
97{ 97{
98 int i = 0; 98 int i = 0;
99
99 while (!(res->port_resource[i].flags & IORESOURCE_UNSET) 100 while (!(res->port_resource[i].flags & IORESOURCE_UNSET)
100 && i < PNP_MAX_PORT) 101 && i < PNP_MAX_PORT)
101 i++; 102 i++;
@@ -110,11 +111,11 @@ pnpbios_parse_allocated_ioresource(struct pnp_resource_table *res, int io,
110 } 111 }
111} 112}
112 113
113static void 114static void pnpbios_parse_allocated_memresource(struct pnp_resource_table *res,
114pnpbios_parse_allocated_memresource(struct pnp_resource_table *res, int mem, 115 int mem, int len)
115 int len)
116{ 116{
117 int i = 0; 117 int i = 0;
118
118 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) 119 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET)
119 && i < PNP_MAX_MEM) 120 && i < PNP_MAX_MEM)
120 i++; 121 i++;
@@ -261,10 +262,11 @@ static unsigned char *pnpbios_parse_allocated_resource_data(unsigned char *p,
261 * Resource Configuration Options 262 * Resource Configuration Options
262 */ 263 */
263 264
264static void 265static void pnpbios_parse_mem_option(unsigned char *p, int size,
265pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option) 266 struct pnp_option *option)
266{ 267{
267 struct pnp_mem *mem; 268 struct pnp_mem *mem;
269
268 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 270 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
269 if (!mem) 271 if (!mem)
270 return; 272 return;
@@ -274,14 +276,13 @@ pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option)
274 mem->size = ((p[11] << 8) | p[10]) << 8; 276 mem->size = ((p[11] << 8) | p[10]) << 8;
275 mem->flags = p[3]; 277 mem->flags = p[3];
276 pnp_register_mem_resource(option, mem); 278 pnp_register_mem_resource(option, mem);
277 return;
278} 279}
279 280
280static void 281static void pnpbios_parse_mem32_option(unsigned char *p, int size,
281pnpbios_parse_mem32_option(unsigned char *p, int size, 282 struct pnp_option *option)
282 struct pnp_option *option)
283{ 283{
284 struct pnp_mem *mem; 284 struct pnp_mem *mem;
285
285 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 286 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
286 if (!mem) 287 if (!mem)
287 return; 288 return;
@@ -291,12 +292,10 @@ pnpbios_parse_mem32_option(unsigned char *p, int size,
291 mem->size = (p[19] << 24) | (p[18] << 16) | (p[17] << 8) | p[16]; 292 mem->size = (p[19] << 24) | (p[18] << 16) | (p[17] << 8) | p[16];
292 mem->flags = p[3]; 293 mem->flags = p[3];
293 pnp_register_mem_resource(option, mem); 294 pnp_register_mem_resource(option, mem);
294 return;
295} 295}
296 296
297static void 297static void pnpbios_parse_fixed_mem32_option(unsigned char *p, int size,
298pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, 298 struct pnp_option *option)
299 struct pnp_option *option)
300{ 299{
301 struct pnp_mem *mem; 300 struct pnp_mem *mem;
302 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 301 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
@@ -307,11 +306,10 @@ pnpbios_parse_fixed_mem32_option(unsigned char *p, int size,
307 mem->align = 0; 306 mem->align = 0;
308 mem->flags = p[3]; 307 mem->flags = p[3];
309 pnp_register_mem_resource(option, mem); 308 pnp_register_mem_resource(option, mem);
310 return;
311} 309}
312 310
313static void 311static void pnpbios_parse_irq_option(unsigned char *p, int size,
314pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option) 312 struct pnp_option *option)
315{ 313{
316 struct pnp_irq *irq; 314 struct pnp_irq *irq;
317 unsigned long bits; 315 unsigned long bits;
@@ -326,26 +324,26 @@ pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option)
326 else 324 else
327 irq->flags = IORESOURCE_IRQ_HIGHEDGE; 325 irq->flags = IORESOURCE_IRQ_HIGHEDGE;
328 pnp_register_irq_resource(option, irq); 326 pnp_register_irq_resource(option, irq);
329 return;
330} 327}
331 328
332static void 329static void pnpbios_parse_dma_option(unsigned char *p, int size,
333pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option) 330 struct pnp_option *option)
334{ 331{
335 struct pnp_dma *dma; 332 struct pnp_dma *dma;
333
336 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL); 334 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL);
337 if (!dma) 335 if (!dma)
338 return; 336 return;
339 dma->map = p[1]; 337 dma->map = p[1];
340 dma->flags = p[2]; 338 dma->flags = p[2];
341 pnp_register_dma_resource(option, dma); 339 pnp_register_dma_resource(option, dma);
342 return;
343} 340}
344 341
345static void 342static void pnpbios_parse_port_option(unsigned char *p, int size,
346pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option) 343 struct pnp_option *option)
347{ 344{
348 struct pnp_port *port; 345 struct pnp_port *port;
346
349 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 347 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
350 if (!port) 348 if (!port)
351 return; 349 return;
@@ -355,14 +353,13 @@ pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option)
355 port->size = p[7]; 353 port->size = p[7];
356 port->flags = p[1] ? PNP_PORT_FLAG_16BITADDR : 0; 354 port->flags = p[1] ? PNP_PORT_FLAG_16BITADDR : 0;
357 pnp_register_port_resource(option, port); 355 pnp_register_port_resource(option, port);
358 return;
359} 356}
360 357
361static void 358static void pnpbios_parse_fixed_port_option(unsigned char *p, int size,
362pnpbios_parse_fixed_port_option(unsigned char *p, int size, 359 struct pnp_option *option)
363 struct pnp_option *option)
364{ 360{
365 struct pnp_port *port; 361 struct pnp_port *port;
362
366 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 363 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
367 if (!port) 364 if (!port)
368 return; 365 return;
@@ -371,7 +368,6 @@ pnpbios_parse_fixed_port_option(unsigned char *p, int size,
371 port->align = 0; 368 port->align = 0;
372 port->flags = PNP_PORT_FLAG_FIXED; 369 port->flags = PNP_PORT_FLAG_FIXED;
373 pnp_register_port_resource(option, port); 370 pnp_register_port_resource(option, port);
374 return;
375} 371}
376 372
377static unsigned char *pnpbios_parse_resource_option_data(unsigned char *p, 373static unsigned char *pnpbios_parse_resource_option_data(unsigned char *p,
@@ -498,7 +494,6 @@ static unsigned char *pnpbios_parse_resource_option_data(unsigned char *p,
498 494
499#define HEX(id,a) hex[((id)>>a) & 15] 495#define HEX(id,a) hex[((id)>>a) & 15]
500#define CHAR(id,a) (0x40 + (((id)>>a) & 31)) 496#define CHAR(id,a) (0x40 + (((id)>>a) & 31))
501//
502 497
503void pnpid32_to_pnpid(u32 id, char *str) 498void pnpid32_to_pnpid(u32 id, char *str)
504{ 499{
@@ -513,11 +508,8 @@ void pnpid32_to_pnpid(u32 id, char *str)
513 str[5] = HEX(id, 4); 508 str[5] = HEX(id, 4);
514 str[6] = HEX(id, 0); 509 str[6] = HEX(id, 0);
515 str[7] = '\0'; 510 str[7] = '\0';
516
517 return;
518} 511}
519 512
520//
521#undef CHAR 513#undef CHAR
522#undef HEX 514#undef HEX
523 515
@@ -598,19 +590,20 @@ static void pnpbios_encode_mem(unsigned char *p, struct resource *res)
598{ 590{
599 unsigned long base = res->start; 591 unsigned long base = res->start;
600 unsigned long len = res->end - res->start + 1; 592 unsigned long len = res->end - res->start + 1;
593
601 p[4] = (base >> 8) & 0xff; 594 p[4] = (base >> 8) & 0xff;
602 p[5] = ((base >> 8) >> 8) & 0xff; 595 p[5] = ((base >> 8) >> 8) & 0xff;
603 p[6] = (base >> 8) & 0xff; 596 p[6] = (base >> 8) & 0xff;
604 p[7] = ((base >> 8) >> 8) & 0xff; 597 p[7] = ((base >> 8) >> 8) & 0xff;
605 p[10] = (len >> 8) & 0xff; 598 p[10] = (len >> 8) & 0xff;
606 p[11] = ((len >> 8) >> 8) & 0xff; 599 p[11] = ((len >> 8) >> 8) & 0xff;
607 return;
608} 600}
609 601
610static void pnpbios_encode_mem32(unsigned char *p, struct resource *res) 602static void pnpbios_encode_mem32(unsigned char *p, struct resource *res)
611{ 603{
612 unsigned long base = res->start; 604 unsigned long base = res->start;
613 unsigned long len = res->end - res->start + 1; 605 unsigned long len = res->end - res->start + 1;
606
614 p[4] = base & 0xff; 607 p[4] = base & 0xff;
615 p[5] = (base >> 8) & 0xff; 608 p[5] = (base >> 8) & 0xff;
616 p[6] = (base >> 16) & 0xff; 609 p[6] = (base >> 16) & 0xff;
@@ -623,13 +616,13 @@ static void pnpbios_encode_mem32(unsigned char *p, struct resource *res)
623 p[17] = (len >> 8) & 0xff; 616 p[17] = (len >> 8) & 0xff;
624 p[18] = (len >> 16) & 0xff; 617 p[18] = (len >> 16) & 0xff;
625 p[19] = (len >> 24) & 0xff; 618 p[19] = (len >> 24) & 0xff;
626 return;
627} 619}
628 620
629static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource *res) 621static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource *res)
630{ 622{
631 unsigned long base = res->start; 623 unsigned long base = res->start;
632 unsigned long len = res->end - res->start + 1; 624 unsigned long len = res->end - res->start + 1;
625
633 p[4] = base & 0xff; 626 p[4] = base & 0xff;
634 p[5] = (base >> 8) & 0xff; 627 p[5] = (base >> 8) & 0xff;
635 p[6] = (base >> 16) & 0xff; 628 p[6] = (base >> 16) & 0xff;
@@ -638,46 +631,45 @@ static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource *res)
638 p[9] = (len >> 8) & 0xff; 631 p[9] = (len >> 8) & 0xff;
639 p[10] = (len >> 16) & 0xff; 632 p[10] = (len >> 16) & 0xff;
640 p[11] = (len >> 24) & 0xff; 633 p[11] = (len >> 24) & 0xff;
641 return;
642} 634}
643 635
644static void pnpbios_encode_irq(unsigned char *p, struct resource *res) 636static void pnpbios_encode_irq(unsigned char *p, struct resource *res)
645{ 637{
646 unsigned long map = 0; 638 unsigned long map = 0;
639
647 map = 1 << res->start; 640 map = 1 << res->start;
648 p[1] = map & 0xff; 641 p[1] = map & 0xff;
649 p[2] = (map >> 8) & 0xff; 642 p[2] = (map >> 8) & 0xff;
650 return;
651} 643}
652 644
653static void pnpbios_encode_dma(unsigned char *p, struct resource *res) 645static void pnpbios_encode_dma(unsigned char *p, struct resource *res)
654{ 646{
655 unsigned long map = 0; 647 unsigned long map = 0;
648
656 map = 1 << res->start; 649 map = 1 << res->start;
657 p[1] = map & 0xff; 650 p[1] = map & 0xff;
658 return;
659} 651}
660 652
661static void pnpbios_encode_port(unsigned char *p, struct resource *res) 653static void pnpbios_encode_port(unsigned char *p, struct resource *res)
662{ 654{
663 unsigned long base = res->start; 655 unsigned long base = res->start;
664 unsigned long len = res->end - res->start + 1; 656 unsigned long len = res->end - res->start + 1;
657
665 p[2] = base & 0xff; 658 p[2] = base & 0xff;
666 p[3] = (base >> 8) & 0xff; 659 p[3] = (base >> 8) & 0xff;
667 p[4] = base & 0xff; 660 p[4] = base & 0xff;
668 p[5] = (base >> 8) & 0xff; 661 p[5] = (base >> 8) & 0xff;
669 p[7] = len & 0xff; 662 p[7] = len & 0xff;
670 return;
671} 663}
672 664
673static void pnpbios_encode_fixed_port(unsigned char *p, struct resource *res) 665static void pnpbios_encode_fixed_port(unsigned char *p, struct resource *res)
674{ 666{
675 unsigned long base = res->start; 667 unsigned long base = res->start;
676 unsigned long len = res->end - res->start + 1; 668 unsigned long len = res->end - res->start + 1;
669
677 p[1] = base & 0xff; 670 p[1] = base & 0xff;
678 p[2] = (base >> 8) & 0xff; 671 p[2] = (base >> 8) & 0xff;
679 p[3] = len & 0xff; 672 p[3] = len & 0xff;
680 return;
681} 673}
682 674
683static unsigned char *pnpbios_encode_allocated_resource_data(unsigned char *p, 675static unsigned char *pnpbios_encode_allocated_resource_data(unsigned char *p,
@@ -792,6 +784,7 @@ int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node *node)
792{ 784{
793 unsigned char *p = (char *)node->data; 785 unsigned char *p = (char *)node->data;
794 unsigned char *end = (char *)(node->data + node->size); 786 unsigned char *end = (char *)(node->data + node->size);
787
795 p = pnpbios_parse_allocated_resource_data(p, end, &dev->res); 788 p = pnpbios_parse_allocated_resource_data(p, end, &dev->res);
796 if (!p) 789 if (!p)
797 return -EIO; 790 return -EIO;
@@ -804,24 +797,24 @@ int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node *node)
804 return 0; 797 return 0;
805} 798}
806 799
807int 800int pnpbios_read_resources_from_node(struct pnp_resource_table *res,
808pnpbios_read_resources_from_node(struct pnp_resource_table *res, 801 struct pnp_bios_node *node)
809 struct pnp_bios_node *node)
810{ 802{
811 unsigned char *p = (char *)node->data; 803 unsigned char *p = (char *)node->data;
812 unsigned char *end = (char *)(node->data + node->size); 804 unsigned char *end = (char *)(node->data + node->size);
805
813 p = pnpbios_parse_allocated_resource_data(p, end, res); 806 p = pnpbios_parse_allocated_resource_data(p, end, res);
814 if (!p) 807 if (!p)
815 return -EIO; 808 return -EIO;
816 return 0; 809 return 0;
817} 810}
818 811
819int 812int pnpbios_write_resources_to_node(struct pnp_resource_table *res,
820pnpbios_write_resources_to_node(struct pnp_resource_table *res, 813 struct pnp_bios_node *node)
821 struct pnp_bios_node *node)
822{ 814{
823 unsigned char *p = (char *)node->data; 815 unsigned char *p = (char *)node->data;
824 unsigned char *end = (char *)(node->data + node->size); 816 unsigned char *end = (char *)(node->data + node->size);
817
825 p = pnpbios_encode_allocated_resource_data(p, end, res); 818 p = pnpbios_encode_allocated_resource_data(p, end, res);
826 if (!p) 819 if (!p)
827 return -EIO; 820 return -EIO;