Skip to contentSkip to conversation

Aditional PnP Changes for 2.5.62

PATCH In review Adam Belay 1 participant 2 messages Feb 23, 2003 Pnp support

lore
Share & tools
lore

Adam Belay

author
#0 lore raw

PATCH 1/1 Aditional PnP Changes for 2.5.62

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.1023 -> 1.1024
# drivers/pnp/interface.c 1.11 -> 1.12
# drivers/pnp/manager.c 1.2 -> 1.3
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/02/22 [email protected] 1.1024
# Large Stack Usage Fix
#
# Reduces the stack memory usage in the following PnP Functions:

# pnp_printf
# pnp_set_current_resources
# pnp_manual_config_dev
# pnp_activate_dev
# --------------------------------------------
#
diff -Nru a/drivers/pnp/interface.c b/drivers/pnp/interface.c
--- a/drivers/pnp/interface.c	Sat Feb 22 22:04:59 2003
+++ b/drivers/pnp/interface.c	Sat Feb 22 22:04:59 2003
@@ -32,18 +32,16 @@
 {
 	va_list args;
 	int res;
-	char sbuffer[512];

if (buffer->stop || buffer->error)
return 0;
va_start(args, fmt);
- res = vsprintf(sbuffer, fmt, args);
+ res = vsnprintf(buffer->curr, buffer->len - buffer->size, fmt, args);
va_end(args);
if (buffer->size + res >= buffer->len) {
buffer->stop = 1;
return 0;
}
- strcpy(buffer->curr, sbuffer);
buffer->curr += res;
buffer->size += res;
return res;
@@ -432,13 +430,13 @@
goto done;
}
if (!strnicmp(buf,"set",3)) {
- struct pnp_resource_table res;
int nport = 0, nmem = 0, nirq = 0, ndma = 0;
-
if (dev->active)
goto done;
buf += 3;
- pnp_init_resource_table(&res);
+ spin_lock(&pnp_lock);
+ dev->config_mode = PNP_CONFIG_MANUAL;
+ pnp_init_resource_table(&dev->res);
while (1) {
while (isspace(*buf))
++buf;
@@ -446,17 +444,17 @@
buf += 2;
while (isspace(*buf))
++buf;
- res.port_resource[nport].start = simple_strtoul(buf,&buf,0);
+ dev->res.port_resource[nport].start = simple_strtoul(buf,&buf,0);
while (isspace(*buf))
++buf;
if(*buf == '-') {
buf += 1; while (isspace(*buf))
++buf;
- res.port_resource[nport].end = simple_strtoul(buf,&buf,0);
+ dev->res.port_resource[nport].end = simple_strtoul(buf,&buf,0);
} else
- res.port_resource[nport].end = res.port_resource[nport].start;
- res.port_resource[nport].flags = IORESOURCE_IO;
+ dev->res.port_resource[nport].end = dev->res.port_resource[nport].start;
+ dev->res.port_resource[nport].flags = IORESOURCE_IO;
nport++;
if (nport >= PNP_MAX_PORT)
break;
@@ -466,17 +464,17 @@
buf += 3;
while (isspace(*buf))
++buf;
- res.mem_resource[nmem].start = simple_strtoul(buf,&buf,0);
+ dev->res.mem_resource[nmem].start = simple_strtoul(buf,&buf,0);
while (isspace(*buf))
++buf;
if(*buf == '-') {
buf += 1; while (isspace(*buf))
++buf;
- res.mem_resource[nmem].end = simple_strtoul(buf,&buf,0);
+ dev->res.mem_resource[nmem].end = simple_strtoul(buf,&buf,0);
} else
- res.mem_resource[nmem].end = res.mem_resource[nmem].start;
- res.mem_resource[nmem].flags = IORESOURCE_MEM;
+ dev->res.mem_resource[nmem].end = dev->res.mem_resource[nmem].start;
+ dev->res.mem_resource[nmem].flags = IORESOURCE_MEM;
nmem++;
if (nmem >= PNP_MAX_MEM)
break;
@@ -486,9 +484,9 @@
buf += 3;
while (isspace(*buf))
++buf;
- res.irq_resource[nirq].start =
- res.irq_resource[nirq].end = simple_strtoul(buf,&buf,0);
- res.irq_resource[nirq].flags = IORESOURCE_IRQ;
+ dev->res.irq_resource[nirq].start =
+ dev->res.irq_resource[nirq].end = simple_strtoul(buf,&buf,0);
+ dev->res.irq_resource[nirq].flags = IORESOURCE_IRQ;
nirq++;
if (nirq >= PNP_MAX_IRQ)
break;
@@ -498,9 +496,9 @@
buf += 3;
while (isspace(*buf))
++buf;
- res.dma_resource[ndma].start =
- res.dma_resource[ndma].end = simple_strtoul(buf,&buf,0);
- res.dma_resource[ndma].flags = IORESOURCE_DMA;
+ dev->res.dma_resource[ndma].start =
+ dev->res.dma_resource[ndma].end = simple_strtoul(buf,&buf,0);
+ dev->res.dma_resource[ndma].flags = IORESOURCE_DMA;
ndma++;
if (ndma >= PNP_MAX_DMA)
break;
@@ -508,9 +506,6 @@
}
break;
}
- spin_lock(&pnp_lock);
- dev->config_mode = PNP_CONFIG_MANUAL;
- dev->res = res;
spin_unlock(&pnp_lock);
goto done;
}

drivers/pnp/manager.c +16 -7
diff -Nru a/drivers/pnp/manager.c b/drivers/pnp/manager.c
@@ -543,14 +543,18 @@
 int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table * res, int mode)
 {
 	int i;
-	struct pnp_resource_table bak = dev->res;
+	struct pnp_resource_table * bak;
 	if (!dev || !res)
 		return -EINVAL;
 	if (dev->active)
 		return -EBUSY;
+	bak = pnp_alloc(sizeof(struct pnp_resource_table));
+	if (!bak)
+		return -ENOMEM;
+	*bak = dev->res;
+
 	spin_lock(&pnp_lock);
 	dev->res = *res;
-
 	if (!(mode & PNP_CONFIG_FORCE)) {
 		for (i = 0; i < PNP_MAX_PORT; i++) {
 			if(pnp_check_port(dev,i))
@@ -569,15 +573,17 @@
 				goto fail;
 		}
 	}
+	dev->config_mode = PNP_CONFIG_MANUAL;
 	spin_unlock(&pnp_lock);
 
 	pnp_resolve_conflicts(dev);
-	dev->config_mode = PNP_CONFIG_MANUAL;
+	kfree(bak);
 	return 0;
 
 fail:
-	dev->res = bak;
+	dev->res = *bak;
 	spin_unlock(&pnp_lock);
+	kfree(bak);
 	return -EINVAL;
 }
 
@@ -625,10 +631,13 @@
 		goto fail;
 	}
 	if (pnp_can_read(dev)) {
-		struct pnp_resource_table res;
-		dev->protocol->get(dev, &res);
-		if (pnp_compare_resources(&dev->res, &res)) /* if this happens we may be in big trouble but it's best just to continue */
+		struct pnp_resource_table * res = pnp_alloc(sizeof(struct pnp_resource_table));
+		if (!res)
+			goto fail;
+		dev->protocol->get(dev, res);
+		if (pnp_compare_resources(&dev->res, res)) /* if this happens we may be in big trouble but it's best just to continue */
 			pnp_err("res: The resources requested do not match those set for the PnP device '%s'.", dev->dev.bus_id);
+		kfree(res);
 	} else
 		dev->active = pnp_is_active(dev);
 	pnp_dbg("res: the device '%s' has been activated.", dev->dev.bus_id);
author
#1 lore raw

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.1024 -> 1.1025
# drivers/pnp/resource.c 1.8 -> 1.9
# drivers/pnp/manager.c 1.3 -> 1.4
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/02/22 [email protected] 1.1025
# Resource Management Performance Fix
#
# Fixes a typo in pnp_check_*_conflicts functions. Without this fix the

# resource algorithm will work but will take longer to assign resources.
# 
# Also contains some minor reordering in pnp_activate_dev.
# --------------------------------------------
#
diff -Nru a/drivers/pnp/manager.c b/drivers/pnp/manager.c
--- a/drivers/pnp/manager.c	Sat Feb 22 22:04:48 2003
+++ b/drivers/pnp/manager.c	Sat Feb 22 22:04:48 2003
@@ -602,10 +602,6 @@
 		pnp_info("res: The PnP device '%s' is already active.", dev->dev.bus_id);
 		return -EBUSY;
 	}
-	spin_lock(&pnp_lock);	/* we lock just in case the device is being configured during this call */
-	dev->active = 1;
-	spin_unlock(&pnp_lock); /* once the device is claimed active we know it won't be configured so we can unlock */
-
 	/* If this condition is true, advanced configuration failed, we need to get this device up and running
 	 * so we use the simple config engine which ignores cold conflicts, this of course may lead to new failures */
 	if (!pnp_is_active(dev)) {
@@ -614,6 +610,11 @@
 			goto fail;
 		}
 	}
+
+	spin_lock(&pnp_lock);	/* we lock just in case the device is being configured during this call */
+	dev->active = 1;
+	spin_unlock(&pnp_lock); /* once the device is claimed active we know it won't be configured so we can unlock */
+
 	if (dev->config_mode & PNP_CONFIG_INVALID) {
 		pnp_info("res: Unable to activate the PnP device '%s' because its resource configuration is invalid.", dev->dev.bus_id);
 		goto fail;
diff -Nru a/drivers/pnp/resource.c b/drivers/pnp/resource.c
--- a/drivers/pnp/resource.c	Sat Feb 22 22:04:48 2003
+++ b/drivers/pnp/resource.c	Sat Feb 22 22:04:48 2003
@@ -268,7 +268,7 @@
 	/* check for cold conflicts */
 	pnp_for_each_dev(tdev) {
 		/* Is the device configurable? */
-		if (tdev == dev || (mode ? !dev->active : dev->active))
+		if (tdev == dev || (mode ? !tdev->active : tdev->active))
 			continue;
 		for (tmp = 0; tmp < PNP_MAX_PORT; tmp++) {
 			if (tdev->res.port_resource[tmp].flags & IORESOURCE_IO) {
@@ -339,7 +339,7 @@
 	/* check for cold conflicts */
 	pnp_for_each_dev(tdev) {
 		/* Is the device configurable? */
-		if (tdev == dev || (mode ? !dev->active : dev->active))
+		if (tdev == dev || (mode ? !tdev->active : tdev->active))
 			continue;
 		for (tmp = 0; tmp < PNP_MAX_MEM; tmp++) {
 			if (tdev->res.mem_resource[tmp].flags & IORESOURCE_MEM) {
@@ -408,7 +408,7 @@
 	/* check for cold conflicts */
 	pnp_for_each_dev(tdev) {
 		/* Is the device configurable? */
-		if (tdev == dev || (mode ? !dev->active : dev->active))
+		if (tdev == dev || (mode ? !tdev->active : tdev->active))
 			continue;
 		for (tmp = 0; tmp < PNP_MAX_IRQ; tmp++) {
 			if (tdev->res.irq_resource[tmp].flags & IORESOURCE_IRQ) {
@@ -490,7 +490,7 @@
 	/* check for cold conflicts */
 	pnp_for_each_dev(tdev) {
 		/* Is the device configurable? */
-		if (tdev == dev || (mode ? !dev->active : dev->active))
+		if (tdev == dev || (mode ? !tdev->active : tdev->active))
 			continue;
 		for (tmp = 0; tmp < PNP_MAX_DMA; tmp++) {
 			if (tdev->res.dma_resource[tmp].flags & IORESOURCE_DMA) {