patch-2.4.0-test12 linux/drivers/pnp/isapnp.c

Next file: linux/drivers/s390/net/ctc.c
Previous file: linux/drivers/pci/setup-res.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test11/linux/drivers/pnp/isapnp.c linux/drivers/pnp/isapnp.c
@@ -270,17 +270,16 @@
 {
 	int rdp = isapnp_rdp;
 	while (rdp <= 0x3ff) {
-		if (!check_region(rdp, 1)) {
-			isapnp_rdp = rdp;
-			return 0;
-		}
-		rdp += RDP_STEP;
 		/*
 		 *	We cannot use NE2000 probe spaces for ISAPnP or we
 		 *	will lock up machines.
 		 */
-		if(rdp >= 0x280 && rdp <= 0x380)
-			continue;
+		if ((rdp < 0x280 || rdp >  0x380) && !check_region(rdp, 1)) 
+		{
+			isapnp_rdp = rdp;
+			return 0;
+		}
+		rdp += RDP_STEP;
 	}
 	return -1;
 }
@@ -748,6 +747,25 @@
 }
 
 /*
+ *  Parse card name for ISA PnP device.
+ */ 
+ 
+static void __init 
+isapnp_parse_name(char *name, unsigned int name_max, unsigned short *size)
+{
+	if (name[0] == '\0') {
+		unsigned short size1 = *size >= name_max ? (name_max - 1) : *size;
+		isapnp_peek(name, size1);
+		name[size1] = '\0';
+		*size -= size1;
+		
+		/* clean whitespace from end of string */
+		while (size1 > 0  &&  name[--size1] == ' ') 
+			name[size1] = '\0';
+	}	
+}
+
+/*
  *  Parse resource map for logical device.
  */
 
@@ -844,12 +862,7 @@
 			size = 0;
 			break;
 		case _LTAG_ANSISTR:
-			if (dev->name[0] == '\0') {
-				unsigned short size1 = size > 47 ? 47 : size;
-				isapnp_peek(dev->name, size1);
-				dev->name[size1] = '\0';
-				size -= size1;
-			}
+			isapnp_parse_name(dev->name, sizeof(dev->name), &size);
 			break;
 		case _LTAG_UNICODESTR:
 			/* silently ignore */
@@ -915,12 +928,7 @@
 		case _STAG_VENDOR:
 			break;
 		case _LTAG_ANSISTR:
-			if (card->name[0] == '\0') {
-				unsigned short size1 = size > 47 ? 47 : size;
-				isapnp_peek(card->name, size1);
-				card->name[size1] = '\0';
-				size -= size1;
-			}
+			isapnp_parse_name(card->name, sizeof(card->name), &size);
 			break;
 		case _LTAG_UNICODESTR:
 			/* silently ignore */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)