public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PnP BIOS: bugfixes
@ 2001-07-17  9:32 pazke
  0 siblings, 0 replies; only message in thread
From: pazke @ 2001-07-17  9:32 UTC (permalink / raw)
  To: linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 654 bytes --]


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.

-- 
Andrey Panin            | Embedded systems software engineer
pazke@orbita1.ru        | PGP key: http://www.orbita1.ru/~pazke/AndreyPanin.asc

[-- Attachment #1.2: patch-pnpBIOS --]
[-- Type: text/plain, Size: 1778 bytes --]

diff -urN -X /usr/dontdiff /linux.vanilla/drivers/pnp/pnp_bios.c /linux/drivers/pnp/pnp_bios.c
--- /linux.vanilla/drivers/pnp/pnp_bios.c	Tue Jul 17 23:11:14 2001
+++ /linux/drivers/pnp/pnp_bios.c	Tue Jul 17 23:40:26 2001
@@ -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");
 }
 
 

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-07-17  9:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-07-17  9:32 [PATCH] PnP BIOS: bugfixes pazke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox