PnP BIOS: bugfixes
PATCH 1/1 PnP BIOS: bugfixes
Hi all,
this patch (2.4.6-ac5) fixed two significant bugs in PnP BIOS enumeration code:
- pnpbios_build_devlist() doesn't check pnp_bios_get_dev_node() return code and always builds device list with approximately 250 bogus entries;
- pnpid32_to_pnpid() function generates bogus strings instead of PNPxxxx.
Patch tested on my machine using parport_pc module.
BTW why pnpid32_to_pnpid() builds device ID using lovercase chars like PNP0c01, may be PNP0C01 will be better ?
Best regards.
Signature · 2 lines
Andrey Panin | Embedded systems software engineer [email protected] | PGP key: http://www.orbita1.ru/~pazke/AndreyPanin.asc
linux/drivers/pnp/pnp_bios.c renamed from linux.vanilla/drivers/pnp/pnp_bios.c +19 -12
@@ -695,16 +695,16 @@const char *hex ="0123456789abcdef" ;static char str[8 ]; id =cpu_to_le32 (id); - str[0 ] =CHAR (id,26 ); - str[1 ] =CHAR (id,21 ); - str[2 ] =CHAR (id,16 ); - str[3 ] =HEX (id,12 ); - str[4 ] =HEX (id,8 ); - str[5 ] =HEX (id,4 ); - str[6 ] =HEX (id,0 ); + str[0 ] =CHAR (id,2 ); + str[1 ] =CHAR ((((id &3 ) <<3 ) | ((id >>13 ) &7 )),0 ); + str[2 ] =CHAR (id,8 ); + str[3 ] =HEX (id,20 ); + str[4 ] =HEX (id,16 ); + str[5 ] =HEX (id,28 ); + str[6 ] =HEX (id,24 ); str[7 ] ='\0' ;return str; -} +}#undef CHAR#undef HEX
@@ -728,7 +728,7 @@static void __init pnpbios_build_devlist (void ) { -int i; +int i, devs =0 ;struct pnp_bios_node *node;struct pnp_dev_node_info node_info;struct pci_dev *dev;
@@ -746,13 +746,15 @@if (!node)return ; -for (i=0 ;i<0xff ;i++) - { +for (i=0 ;i<0xff ;i++) { dev =kmalloc (sizeof (struct pci_dev ),GFP_KERNEL );if (!dev)break ; -pnp_bios_get_dev_node ((u8 *)&num, (char )0 , node); +if (pnp_bios_get_dev_node ((u8 *)&num, (char )0 , node)) +continue ; + + devs++;pnpbios_rawdata_2_pci_dev (node,dev); dev->devfn=num; pnpid =pnpid32_to_pnpid (node->eisa_id);
@@ -762,6 +764,11 @@kfree (dev); }kfree (node); + +if (devs) +printk (KERN_INFO "PnP: %i device%s detected total\n" , devs, devs >1 ?"s" :"" ); +else +printk (KERN_INFO "PnP: No devices found\n" ); }