linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 00/37] PNP resource_table cleanups
@ 2008-03-26 17:10 Bjorn Helgaas
  2008-03-26 17:10 ` [patch 01/37] ISAPNP: move config register addresses out of isapnp.h Bjorn Helgaas
                   ` (37 more replies)
  0 siblings, 38 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:10 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

This series of patches does some PNP housecleaning and
consolidation.

PNP currently uses a fixed-size table (pnp_resource_table)
to track the IO, MMIO, IRQ, and DMA resources used by a
device.  Some motherboard devices have many resources, so
we've been plagued by table overflows and we've had to
drastically increase the table size, which wastes a lot
of memory.

The end goal is to replace that fixed-size table with something
more dynamic.  These patches don't go that far, but they do make
pnp_resource_table private to the PNP core and centralize all
references to it in a small set of shared functions.

In addition, this series contains a number of related
cleanups, like centralized allocation of struct pnp_dev,
conversion to dev_printk when possible, removing many
PNP core internal functions from the public interface,
and alignment of the ISAPNP, PNPBIOS, and PNPACPI backends.

Bjorn
-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 01/37] ISAPNP: move config register addresses out of isapnp.h
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
@ 2008-03-26 17:10 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 02/37] PNPACPI: continue after _CRS and _PRS errors Bjorn Helgaas
                   ` (36 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:10 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: isapnp-remove-register-addrs-from-header --]
[-- Type: text/plain, Size: 1503 bytes --]

These are used only in drivers/pnp/isapnp/core.c, so no need to
expose them to the world.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/pnp/isapnp/core.c
===================================================================
--- work7.orig/drivers/pnp/isapnp/core.c	2008-03-21 11:52:12.000000000 -0600
+++ work7/drivers/pnp/isapnp/core.c	2008-03-21 11:53:24.000000000 -0600
@@ -88,6 +88,14 @@
 #define _LTAG_MEM32RANGE	0x85
 #define _LTAG_FIXEDMEM32RANGE	0x86
 
+/* Logical device control and configuration registers */
+
+#define ISAPNP_CFG_ACTIVATE	0x30	/* byte */
+#define ISAPNP_CFG_MEM		0x40	/* 4 * dword */
+#define ISAPNP_CFG_PORT		0x60	/* 8 * word */
+#define ISAPNP_CFG_IRQ		0x70	/* 2 * word */
+#define ISAPNP_CFG_DMA		0x74	/* 2 * byte */
+
 /*
  * Sizes of ISAPNP logical device configuration register sets.
  * See PNP-ISA-v1.0a.pdf, Appendix A.
Index: work7/include/linux/isapnp.h
===================================================================
--- work7.orig/include/linux/isapnp.h	2008-03-21 11:45:41.000000000 -0600
+++ work7/include/linux/isapnp.h	2008-03-21 11:52:39.000000000 -0600
@@ -26,16 +26,6 @@
 #include <linux/pnp.h>
 
 /*
- *  Configuration registers (TODO: change by specification)
- */ 
-
-#define ISAPNP_CFG_ACTIVATE		0x30	/* byte */
-#define ISAPNP_CFG_MEM			0x40	/* 4 * dword */
-#define ISAPNP_CFG_PORT			0x60	/* 8 * word */
-#define ISAPNP_CFG_IRQ			0x70	/* 2 * word */
-#define ISAPNP_CFG_DMA			0x74	/* 2 * byte */
-
-/*
  *
  */
 

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 02/37] PNPACPI: continue after _CRS and _PRS errors
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
  2008-03-26 17:10 ` [patch 01/37] ISAPNP: move config register addresses out of isapnp.h Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 03/37] PNP: make pnp_add_id() internal to PNP core Bjorn Helgaas
                   ` (35 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnpacpi-ignore-errors --]
[-- Type: text/plain, Size: 1230 bytes --]

Keep going and register the device even if we have trouble parsing
_CRS or _PRS.  A parsing problem might mean we ignore some resources
the device is using, or we might not be able to change its resources.
But we should still take note of anything we *could* parse correctly.

Also remove reference to dev_id because I plan to remove it soon.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/pnp/pnpacpi/core.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/core.c	2008-03-21 15:12:19.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/core.c	2008-03-21 15:12:20.000000000 -0600
@@ -213,8 +213,7 @@
 							  &dev->res);
 		if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
 			pnp_err("PnPACPI: METHOD_NAME__CRS failure for %s",
-				dev_id->id);
-			goto err1;
+				acpi_device_hid(device));
 		}
 	}
 
@@ -223,8 +222,7 @@
 							    dev);
 		if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
 			pnp_err("PnPACPI: METHOD_NAME__PRS failure for %s",
-				dev_id->id);
-			goto err1;
+				acpi_device_hid(device));
 		}
 	}
 
@@ -252,8 +250,6 @@
 	num++;
 
 	return AE_OK;
-err1:
-	kfree(dev_id);
 err:
 	kfree(dev);
 	return -EINVAL;

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 03/37] PNP: make pnp_add_id() internal to PNP core
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
  2008-03-26 17:10 ` [patch 01/37] ISAPNP: move config register addresses out of isapnp.h Bjorn Helgaas
  2008-03-26 17:11 ` [patch 02/37] PNPACPI: continue after _CRS and _PRS errors Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 04/37] PNP: change pnp_add_id() to allocate its own pnp_id structures Bjorn Helgaas
                   ` (34 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-make-pnp_add_id-internal-to-core --]
[-- Type: text/plain, Size: 2461 bytes --]

pnp_add_id() doesn't need to be exposed outside the PNP core, so
move the declaration to an internal header file.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/include/linux/pnp.h
===================================================================
--- work7.orig/include/linux/pnp.h	2008-03-21 13:31:06.000000000 -0600
+++ work7/include/linux/pnp.h	2008-03-21 13:31:08.000000000 -0600
@@ -403,7 +403,6 @@
 /* protocol helpers */
 int pnp_is_active(struct pnp_dev *dev);
 int compare_pnp_id(struct pnp_id *pos, const char *id);
-int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev);
 int pnp_register_driver(struct pnp_driver *drv);
 void pnp_unregister_driver(struct pnp_driver *drv);
 
@@ -450,7 +449,6 @@
 /* protocol helpers */
 static inline int pnp_is_active(struct pnp_dev *dev) { return 0; }
 static inline int compare_pnp_id(struct pnp_id *pos, const char *id) { return -ENODEV; }
-static inline int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev) { return -ENODEV; }
 static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; }
 static inline void pnp_unregister_driver(struct pnp_driver *drv) { }
 
Index: work7/drivers/pnp/base.h
===================================================================
--- work7.orig/drivers/pnp/base.h	2008-03-21 13:31:06.000000000 -0600
+++ work7/drivers/pnp/base.h	2008-03-21 13:31:39.000000000 -0600
@@ -1,5 +1,6 @@
 extern spinlock_t pnp_lock;
 void *pnp_alloc(long size);
+int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev);
 int pnp_interface_attach_device(struct pnp_dev *dev);
 void pnp_fixup_device(struct pnp_dev *dev);
 void pnp_free_option(struct pnp_option *option);
Index: work7/drivers/pnp/pnpacpi/core.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/core.c	2008-03-21 13:31:06.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/core.c	2008-03-21 13:31:08.000000000 -0600
@@ -25,6 +25,7 @@
 #include <acpi/acpi_bus.h>
 #include <acpi/actypes.h>
 
+#include "../base.h"
 #include "pnpacpi.h"
 
 static int num = 0;
Index: work7/drivers/pnp/pnpbios/core.c
===================================================================
--- work7.orig/drivers/pnp/pnpbios/core.c	2008-03-21 13:31:06.000000000 -0600
+++ work7/drivers/pnp/pnpbios/core.c	2008-03-21 13:31:08.000000000 -0600
@@ -69,6 +69,7 @@
 #include <asm/system.h>
 #include <asm/byteorder.h>
 
+#include "../base.h"
 #include "pnpbios.h"
 
 /*

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 04/37] PNP: change pnp_add_id() to allocate its own pnp_id structures
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (2 preceding siblings ...)
  2008-03-26 17:11 ` [patch 03/37] PNP: make pnp_add_id() internal to PNP core Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 05/37] ISAPNP: pull pnp_add_id() out of isapnp_parse_id() Bjorn Helgaas
                   ` (33 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-move-allocation-into-pnp_add_id --]
[-- Type: text/plain, Size: 6730 bytes --]

This moves some of the pnp_id knowledge out of the backends and into
the PNP core.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

---
 drivers/pnp/base.h             |    2 +-
 drivers/pnp/driver.c           |   28 +++++++++++++++++++++-------
 drivers/pnp/isapnp/core.c      |   24 +++++++++++-------------
 drivers/pnp/pnpacpi/core.c     |   27 +++------------------------
 drivers/pnp/pnpbios/core.c     |   10 +---------
 drivers/pnp/pnpbios/rsparser.c |    7 +------
 6 files changed, 38 insertions(+), 60 deletions(-)

Index: work7/drivers/pnp/base.h
===================================================================
--- work7.orig/drivers/pnp/base.h	2008-03-26 10:46:36.000000000 -0600
+++ work7/drivers/pnp/base.h	2008-03-26 10:46:37.000000000 -0600
@@ -1,6 +1,6 @@
 extern spinlock_t pnp_lock;
 void *pnp_alloc(long size);
-int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev);
+struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id);
 int pnp_interface_attach_device(struct pnp_dev *dev);
 void pnp_fixup_device(struct pnp_dev *dev);
 void pnp_free_option(struct pnp_option *option);
Index: work7/drivers/pnp/driver.c
===================================================================
--- work7.orig/drivers/pnp/driver.c	2008-03-26 10:46:05.000000000 -0600
+++ work7/drivers/pnp/driver.c	2008-03-26 10:46:37.000000000 -0600
@@ -226,22 +226,36 @@
 
 /**
  * pnp_add_id - adds an EISA id to the specified device
- * @id: pointer to a pnp_id structure
  * @dev: pointer to the desired device
+ * @id: pointer to an EISA id string
  */
-int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev)
+struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id)
 {
-	struct pnp_id *ptr;
+	struct pnp_id *dev_id, *ptr;
 
-	id->next = NULL;
+	dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
+	if (!dev_id)
+		return NULL;
+
+	dev_id->id[0] = id[0];
+	dev_id->id[1] = id[1];
+	dev_id->id[2] = id[2];
+	dev_id->id[3] = tolower(id[3]);
+	dev_id->id[4] = tolower(id[4]);
+	dev_id->id[5] = tolower(id[5]);
+	dev_id->id[6] = tolower(id[6]);
+	dev_id->id[7] = '\0';
+
+	dev_id->next = NULL;
 	ptr = dev->id;
 	while (ptr && ptr->next)
 		ptr = ptr->next;
 	if (ptr)
-		ptr->next = id;
+		ptr->next = dev_id;
 	else
-		dev->id = id;
-	return 0;
+		dev->id = dev_id;
+
+	return dev_id;
 }
 
 EXPORT_SYMBOL(pnp_register_driver);
Index: work7/drivers/pnp/isapnp/core.c
===================================================================
--- work7.orig/drivers/pnp/isapnp/core.c	2008-03-26 10:46:32.000000000 -0600
+++ work7/drivers/pnp/isapnp/core.c	2008-03-26 10:46:37.000000000 -0600
@@ -44,6 +44,8 @@
 #include <linux/mutex.h>
 #include <asm/io.h>
 
+#include "../base.h"
+
 #if 0
 #define ISAPNP_REGION_OK
 #endif
@@ -401,20 +403,18 @@
 static void isapnp_parse_id(struct pnp_dev *dev, unsigned short vendor,
 			    unsigned short device)
 {
-	struct pnp_id *id;
+	char id[8];
 
-	if (!dev)
-		return;
-	id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
-	if (!id)
-		return;
-	sprintf(id->id, "%c%c%c%x%x%x%x",
-		'A' + ((vendor >> 2) & 0x3f) - 1,
-		'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1,
-		'A' + ((vendor >> 8) & 0x1f) - 1,
-		(device >> 4) & 0x0f,
-		device & 0x0f, (device >> 12) & 0x0f, (device >> 8) & 0x0f);
-	pnp_add_id(id, dev);
+	id[0] = 'A' + ((vendor >> 2) & 0x3f) - 1;
+	id[1] = 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1;
+	id[2] = 'A' + ((vendor >> 8) & 0x1f) - 1;
+	id[3] = '0' + ((device >> 4) & 0x0f);
+	id[4] = '0' + (device & 0x0f);
+	id[5] = '0' + ((device >> 12) & 0x0f);
+	id[6] = '0' + ((device >> 8) & 0x0f);
+	id[7] = '\0';
+
+	pnp_add_id(dev, id);
 }
 
 /*
Index: work7/drivers/pnp/pnpacpi/core.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/core.c	2008-03-26 10:46:36.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/core.c	2008-03-26 10:46:37.000000000 -0600
@@ -73,18 +73,6 @@
 	return 1;
 }
 
-static void __init pnpidacpi_to_pnpid(char *id, char *str)
-{
-	str[0] = id[0];
-	str[1] = id[1];
-	str[2] = id[2];
-	str[3] = tolower(id[3]);
-	str[4] = tolower(id[4]);
-	str[5] = tolower(id[5]);
-	str[6] = tolower(id[6]);
-	str[7] = '\0';
-}
-
 static int pnpacpi_get_resources(struct pnp_dev *dev,
 				 struct pnp_resource_table *res)
 {
@@ -201,12 +189,9 @@
 
 	dev->number = num;
 
-	/* set the initial values for the PnP device */
-	dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
+	dev_id = pnp_add_id(dev, acpi_device_hid(device));
 	if (!dev_id)
 		goto err;
-	pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id);
-	pnp_add_id(dev_id, dev);
 
 	if (dev->active) {
 		/* parse allocated resource */
@@ -227,7 +212,6 @@
 		}
 	}
 
-	/* parse compatible ids */
 	if (device->flags.compatible_ids) {
 		struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
 		int i;
@@ -235,12 +219,7 @@
 		for (i = 0; i < cid_list->count; i++) {
 			if (!ispnpidacpi(cid_list->id[i].value))
 				continue;
-			dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
-			if (!dev_id)
-				continue;
-
-			pnpidacpi_to_pnpid(cid_list->id[i].value, dev_id->id);
-			pnp_add_id(dev_id, dev);
+			pnp_add_id(dev, cid_list->id[i].value);
 		}
 	}
 
Index: work7/drivers/pnp/pnpbios/core.c
===================================================================
--- work7.orig/drivers/pnp/pnpbios/core.c	2008-03-26 10:46:36.000000000 -0600
+++ work7/drivers/pnp/pnpbios/core.c	2008-03-26 10:46:37.000000000 -0600
@@ -332,16 +332,14 @@
 	if (!dev)
 		return -1;
 
-	dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
+	pnpid32_to_pnpid(node->eisa_id, id);
+	dev_id = pnp_add_id(dev, id);
 	if (!dev_id) {
 		kfree(dev);
 		return -1;
 	}
 
 	dev->number = node->handle;
-	pnpid32_to_pnpid(node->eisa_id, id);
-	memcpy(dev_id->id, id, 7);
-	pnp_add_id(dev_id, dev);
 	pnpbios_parse_data_stream(dev, node);
 	dev->active = pnp_is_active(dev);
 	dev->flags = node->flags;
Index: work7/drivers/pnp/pnpbios/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpbios/rsparser.c	2008-03-26 10:46:05.000000000 -0600
+++ work7/drivers/pnp/pnpbios/rsparser.c	2008-03-26 10:46:37.000000000 -0600
@@ -16,6 +16,7 @@
 }
 #endif				/* CONFIG_PCI */
 
+#include "../base.h"
 #include "pnpbios.h"
 
 /* standard resource tags */
@@ -548,13 +549,11 @@
 		case SMALL_TAG_COMPATDEVID:	/* compatible ID */
 			if (len != 4)
 				goto len_err;
-			dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
-			if (!dev_id)
-				return NULL;
 			pnpid32_to_pnpid(p[1] | p[2] << 8 | p[3] << 16 | p[4] <<
 					 24, id);
-			memcpy(&dev_id->id, id, 7);
-			pnp_add_id(dev_id, dev);
+			dev_id = pnp_add_id(dev, id);
+			if (!dev_id)
+				return NULL;
 			break;
 
 		case SMALL_TAG_END:

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 05/37] ISAPNP: pull pnp_add_id() out of isapnp_parse_id()
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (3 preceding siblings ...)
  2008-03-26 17:11 ` [patch 04/37] PNP: change pnp_add_id() to allocate its own pnp_id structures Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 06/37] PNP: add pnp_alloc_dev() Bjorn Helgaas
                   ` (32 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: isapnp-restructure-parse-id --]
[-- Type: text/plain, Size: 2001 bytes --]

Split the pnp_add_id() part from the PNPID conversion part so we
can move the initial add_id() into the pnp_dev allocation.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/pnp/isapnp/core.c
===================================================================
--- work7.orig/drivers/pnp/isapnp/core.c	2008-03-21 15:31:25.000000000 -0600
+++ work7/drivers/pnp/isapnp/core.c	2008-03-21 15:32:15.000000000 -0600
@@ -400,11 +400,9 @@
 /*
  *  Parse EISA id.
  */
-static void isapnp_parse_id(struct pnp_dev *dev, unsigned short vendor,
-			    unsigned short device)
+static void isapnp_to_pnpid(unsigned short vendor, unsigned short device,
+			    char *id)
 {
-	char id[8];
-
 	id[0] = 'A' + ((vendor >> 2) & 0x3f) - 1;
 	id[1] = 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1;
 	id[2] = 'A' + ((vendor >> 8) & 0x1f) - 1;
@@ -413,8 +411,6 @@
 	id[5] = '0' + ((device >> 12) & 0x0f);
 	id[6] = '0' + ((device >> 8) & 0x0f);
 	id[7] = '\0';
-
-	pnp_add_id(dev, id);
 }
 
 /*
@@ -424,6 +420,7 @@
 						  int size, int number)
 {
 	unsigned char tmp[6];
+	char id[8];
 	struct pnp_dev *dev;
 
 	isapnp_peek(tmp, size);
@@ -431,7 +428,8 @@
 	if (!dev)
 		return NULL;
 	dev->number = number;
-	isapnp_parse_id(dev, (tmp[1] << 8) | tmp[0], (tmp[3] << 8) | tmp[2]);
+	isapnp_to_pnpid((tmp[1] << 8) | tmp[0], (tmp[3] << 8) | tmp[2], id);
+	pnp_add_id(dev, id);
 	dev->regs = tmp[4];
 	dev->card = card;
 	if (size > 5)
@@ -621,6 +619,7 @@
 	unsigned char type, tmp[17];
 	struct pnp_option *option;
 	struct pnp_dev *dev;
+	char id[8];
 
 	if ((dev = isapnp_parse_device(card, size, number++)) == NULL)
 		return 1;
@@ -660,8 +659,9 @@
 		case _STAG_COMPATDEVID:
 			if (size == 4 && compat < DEVICE_COUNT_COMPATIBLE) {
 				isapnp_peek(tmp, 4);
-				isapnp_parse_id(dev, (tmp[1] << 8) | tmp[0],
-						(tmp[3] << 8) | tmp[2]);
+				isapnp_to_pnpid((tmp[1] << 8) | tmp[0],
+						(tmp[3] << 8) | tmp[2], id);
+				pnp_add_id(dev, id);
 				compat++;
 				size = 0;
 			}

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 06/37] PNP: add pnp_alloc_dev()
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (4 preceding siblings ...)
  2008-03-26 17:11 ` [patch 05/37] ISAPNP: pull pnp_add_id() out of isapnp_parse_id() Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 07/37] PNP: make pnp_add_card_id() internal to PNP core Bjorn Helgaas
                   ` (31 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-alloc-dev --]
[-- Type: text/plain, Size: 5709 bytes --]

Add pnp_alloc_dev() to allocate a struct pnp_dev and fill in the
protocol, instance number, and initial PNP ID.  Now it is always
valid to use dev_printk() on any pnp_dev pointer.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

---
 drivers/pnp/base.h         |    1 +
 drivers/pnp/core.c         |   28 +++++++++++++++++++++++++---
 drivers/pnp/isapnp/core.c  |    9 ++++-----
 drivers/pnp/pnpacpi/core.c |   19 +++----------------
 drivers/pnp/pnpbios/core.c |   16 ++++------------
 5 files changed, 37 insertions(+), 36 deletions(-)

Index: work7/drivers/pnp/base.h
===================================================================
--- work7.orig/drivers/pnp/base.h	2008-03-26 10:50:28.000000000 -0600
+++ work7/drivers/pnp/base.h	2008-03-26 10:50:36.000000000 -0600
@@ -1,5 +1,6 @@
 extern spinlock_t pnp_lock;
 void *pnp_alloc(long size);
+struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *, int id, char *pnpid);
 struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id);
 int pnp_interface_attach_device(struct pnp_dev *dev);
 void pnp_fixup_device(struct pnp_dev *dev);
Index: work7/drivers/pnp/core.c
===================================================================
--- work7.orig/drivers/pnp/core.c	2008-03-26 10:50:24.000000000 -0600
+++ work7/drivers/pnp/core.c	2008-03-26 10:51:40.000000000 -0600
@@ -109,6 +109,31 @@
 	kfree(dev);
 }
 
+struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid)
+{
+	struct pnp_dev *dev;
+	struct pnp_id *dev_id;
+
+	dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL);
+	if (!dev)
+		return NULL;
+
+	dev->protocol = protocol;
+	dev->number = id;
+
+	dev->dev.parent = &dev->protocol->dev;
+	sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number,
+		dev->number);
+
+	dev_id = pnp_add_id(dev, pnpid);
+	if (!dev_id) {
+		kfree(dev);
+		return NULL;
+	}
+
+	return dev;
+}
+
 int __pnp_add_device(struct pnp_dev *dev)
 {
 	int ret;
@@ -145,9 +170,6 @@
 	if (dev->card)
 		return -EINVAL;
 
-	dev->dev.parent = &dev->protocol->dev;
-	sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number,
-		dev->number);
 	ret = __pnp_add_device(dev);
 	if (ret)
 		return ret;
Index: work7/drivers/pnp/isapnp/core.c
===================================================================
--- work7.orig/drivers/pnp/isapnp/core.c	2008-03-26 10:50:30.000000000 -0600
+++ work7/drivers/pnp/isapnp/core.c	2008-03-26 10:50:36.000000000 -0600
@@ -424,17 +424,16 @@
 	struct pnp_dev *dev;
 
 	isapnp_peek(tmp, size);
-	dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL);
+	isapnp_to_pnpid((tmp[1] << 8) | tmp[0], (tmp[3] << 8) | tmp[2], id);
+
+	dev = pnp_alloc_dev(&isapnp_protocol, number, id);
 	if (!dev)
 		return NULL;
-	dev->number = number;
-	isapnp_to_pnpid((tmp[1] << 8) | tmp[0], (tmp[3] << 8) | tmp[2], id);
-	pnp_add_id(dev, id);
+
 	dev->regs = tmp[4];
 	dev->card = card;
 	if (size > 5)
 		dev->regs |= tmp[5] << 8;
-	dev->protocol = &isapnp_protocol;
 	dev->capabilities |= PNP_CONFIGURABLE;
 	dev->capabilities |= PNP_READ;
 	dev->capabilities |= PNP_WRITE;
Index: work7/drivers/pnp/pnpacpi/core.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/core.c	2008-03-26 10:50:28.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/core.c	2008-03-26 10:50:36.000000000 -0600
@@ -152,7 +152,6 @@
 {
 	acpi_handle temp = NULL;
 	acpi_status status;
-	struct pnp_id *dev_id;
 	struct pnp_dev *dev;
 
 	status = acpi_get_handle(device->handle, "_CRS", &temp);
@@ -160,11 +159,10 @@
 	    is_exclusive_device(device))
 		return 0;
 
-	dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL);
-	if (!dev) {
-		pnp_err("Out of memory");
+	dev = pnp_alloc_dev(&pnpacpi_protocol, num, acpi_device_hid(device));
+	if (!dev)
 		return -ENOMEM;
-	}
+
 	dev->data = device->handle;
 	/* .enabled means the device can decode the resources */
 	dev->active = device->status.enabled;
@@ -180,19 +178,11 @@
 	if (ACPI_SUCCESS(status))
 		dev->capabilities |= PNP_DISABLE;
 
-	dev->protocol = &pnpacpi_protocol;
-
 	if (strlen(acpi_device_name(device)))
 		strncpy(dev->name, acpi_device_name(device), sizeof(dev->name));
 	else
 		strncpy(dev->name, acpi_device_bid(device), sizeof(dev->name));
 
-	dev->number = num;
-
-	dev_id = pnp_add_id(dev, acpi_device_hid(device));
-	if (!dev_id)
-		goto err;
-
 	if (dev->active) {
 		/* parse allocated resource */
 		status = pnpacpi_parse_allocated_resource(device->handle,
@@ -230,9 +220,6 @@
 	num++;
 
 	return AE_OK;
-err:
-	kfree(dev);
-	return -EINVAL;
 }
 
 static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
Index: work7/drivers/pnp/pnpbios/core.c
===================================================================
--- work7.orig/drivers/pnp/pnpbios/core.c	2008-03-26 10:50:28.000000000 -0600
+++ work7/drivers/pnp/pnpbios/core.c	2008-03-26 10:50:36.000000000 -0600
@@ -318,7 +318,6 @@
 {
 	struct list_head *pos;
 	struct pnp_dev *dev;
-	struct pnp_id *dev_id;
 	char id[8];
 
 	/* check if the device is already added */
@@ -328,18 +327,12 @@
 			return -1;
 	}
 
-	dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL);
-	if (!dev)
-		return -1;
-
 	pnpid32_to_pnpid(node->eisa_id, id);
-	dev_id = pnp_add_id(dev, id);
-	if (!dev_id) {
-		kfree(dev);
-		return -1;
-	}
 
-	dev->number = node->handle;
+	dev = pnp_alloc_dev(&pnpbios_protocol, node->handle, id);
+	if (!dev)
+		return -ENOMEM;
+
 	pnpbios_parse_data_stream(dev, node);
 	dev->active = pnp_is_active(dev);
 	dev->flags = node->flags;
@@ -352,7 +345,6 @@
 		dev->capabilities |= PNP_WRITE;
 	if (dev->flags & PNPBIOS_REMOVABLE)
 		dev->capabilities |= PNP_REMOVABLE;
-	dev->protocol = &pnpbios_protocol;
 
 	/* clear out the damaged flags */
 	if (!dev->active)

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 07/37] PNP: make pnp_add_card_id() internal to PNP core
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (5 preceding siblings ...)
  2008-03-26 17:11 ` [patch 06/37] PNP: add pnp_alloc_dev() Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 08/37] PNP: change pnp_add_card_id() to allocate its own pnp_id structures Bjorn Helgaas
                   ` (30 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-make-pnp_add_card_id-internal-to-core --]
[-- Type: text/plain, Size: 2115 bytes --]

pnp_add_card_id() doesn't need to be exposed outside the PNP core, so
move the declaration to an internal header file.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/pnp/base.h
===================================================================
--- work7.orig/drivers/pnp/base.h	2008-03-25 14:16:35.000000000 -0600
+++ work7/drivers/pnp/base.h	2008-03-25 14:18:52.000000000 -0600
@@ -2,6 +2,7 @@
 void *pnp_alloc(long size);
 struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *, int id, char *pnpid);
 struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id);
+int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card);
 int pnp_interface_attach_device(struct pnp_dev *dev);
 void pnp_fixup_device(struct pnp_dev *dev);
 void pnp_free_option(struct pnp_option *option);
Index: work7/include/linux/pnp.h
===================================================================
--- work7.orig/include/linux/pnp.h	2008-03-25 14:15:54.000000000 -0600
+++ work7/include/linux/pnp.h	2008-03-25 14:16:31.000000000 -0600
@@ -371,7 +371,6 @@
 void pnp_remove_card(struct pnp_card *card);
 int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev);
 void pnp_remove_card_device(struct pnp_dev *dev);
-int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card);
 struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
 					const char *id, struct pnp_dev *from);
 void pnp_release_card_device(struct pnp_dev *dev);
@@ -423,7 +422,6 @@
 static inline void pnp_remove_card(struct pnp_card *card) { }
 static inline int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev) { return -ENODEV; }
 static inline void pnp_remove_card_device(struct pnp_dev *dev) { }
-static inline int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card) { return -ENODEV; }
 static inline struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, const char *id, struct pnp_dev *from) { return NULL; }
 static inline void pnp_release_card_device(struct pnp_dev *dev) { }
 static inline int pnp_register_card_driver(struct pnp_card_driver *drv) { return -ENODEV; }

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 08/37] PNP: change pnp_add_card_id() to allocate its own pnp_id structures
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (6 preceding siblings ...)
  2008-03-26 17:11 ` [patch 07/37] PNP: make pnp_add_card_id() internal to PNP core Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 09/37] ISAPNP: pull pnp_add_card_id() out of isapnp_parse_card_id() Bjorn Helgaas
                   ` (29 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-move-allocation-into-pnp_add_card_id --]
[-- Type: text/plain, Size: 3274 bytes --]

This moves some of the pnp_id knowledge out of the backends and into
the PNP core.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/pnp/base.h
===================================================================
--- work7.orig/drivers/pnp/base.h	2008-03-25 14:19:35.000000000 -0600
+++ work7/drivers/pnp/base.h	2008-03-25 14:19:51.000000000 -0600
@@ -2,7 +2,7 @@
 void *pnp_alloc(long size);
 struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *, int id, char *pnpid);
 struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id);
-int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card);
+struct pnp_id *pnp_add_card_id(struct pnp_card *card, char *id);
 int pnp_interface_attach_device(struct pnp_dev *dev);
 void pnp_fixup_device(struct pnp_dev *dev);
 void pnp_free_option(struct pnp_option *option);
Index: work7/drivers/pnp/card.c
===================================================================
--- work7.orig/drivers/pnp/card.c	2008-03-25 14:19:58.000000000 -0600
+++ work7/drivers/pnp/card.c	2008-03-25 14:31:06.000000000 -0600
@@ -5,6 +5,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/ctype.h>
 #include <linux/slab.h>
 #include <linux/pnp.h>
 #include "base.h"
@@ -100,19 +101,33 @@
  * @id: pointer to a pnp_id structure
  * @card: pointer to the desired card
  */
-int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card)
+struct pnp_id *pnp_add_card_id(struct pnp_card *card, char *id)
 {
-	struct pnp_id *ptr;
+	struct pnp_id *dev_id, *ptr;
 
-	id->next = NULL;
+	dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
+	if (!dev_id)
+		return NULL;
+
+	dev_id->id[0] = id[0];
+	dev_id->id[1] = id[1];
+	dev_id->id[2] = id[2];
+	dev_id->id[3] = tolower(id[3]);
+	dev_id->id[4] = tolower(id[4]);
+	dev_id->id[5] = tolower(id[5]);
+	dev_id->id[6] = tolower(id[6]);
+	dev_id->id[7] = '\0';
+
+	dev_id->next = NULL;
 	ptr = card->id;
 	while (ptr && ptr->next)
 		ptr = ptr->next;
 	if (ptr)
-		ptr->next = id;
+		ptr->next = dev_id;
 	else
-		card->id = id;
-	return 0;
+		card->id = dev_id;
+
+	return dev_id;
 }
 
 static void pnp_free_card_ids(struct pnp_card *card)
Index: work7/drivers/pnp/isapnp/core.c
===================================================================
--- work7.orig/drivers/pnp/isapnp/core.c	2008-03-25 14:22:46.000000000 -0600
+++ work7/drivers/pnp/isapnp/core.c	2008-03-25 14:31:46.000000000 -0600
@@ -834,17 +834,18 @@
 static void isapnp_parse_card_id(struct pnp_card *card, unsigned short vendor,
 				 unsigned short device)
 {
-	struct pnp_id *id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
+	char id[8];
 
-	if (!id)
-		return;
-	sprintf(id->id, "%c%c%c%x%x%x%x",
-		'A' + ((vendor >> 2) & 0x3f) - 1,
-		'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1,
-		'A' + ((vendor >> 8) & 0x1f) - 1,
-		(device >> 4) & 0x0f,
-		device & 0x0f, (device >> 12) & 0x0f, (device >> 8) & 0x0f);
-	pnp_add_card_id(id, card);
+	id[0] = 'A' + ((vendor >> 2) & 0x3f) - 1;
+	id[1] = 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1;
+	id[2] = 'A' + ((vendor >> 8) & 0x1f) - 1;
+	id[3] = '0' + ((device >> 4) & 0x0f);
+	id[4] = '0' + (device & 0x0f);
+	id[5] = '0' + ((device >> 12) & 0x0f);
+	id[6] = '0' + ((device >> 8) & 0x0f);
+	id[7] = '\0';
+
+	pnp_add_card_id(card, id);
 }
 
 /*

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 09/37] ISAPNP: pull pnp_add_card_id() out of isapnp_parse_card_id()
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (7 preceding siblings ...)
  2008-03-26 17:11 ` [patch 08/37] PNP: change pnp_add_card_id() to allocate its own pnp_id structures Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 10/37] PNP: add pnp_alloc_card() Bjorn Helgaas
                   ` (28 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: isapnp-restructure-parse-card-id --]
[-- Type: text/plain, Size: 1760 bytes --]

Split the pnp_add_card_id() part from the PNPID conversion part so we
can move the initial add_id() into the pnp_card allocation.

This makes the PNPID conversion generic so we can use the same
one for both devices and cards.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/pnp/isapnp/core.c
===================================================================
--- work7.orig/drivers/pnp/isapnp/core.c	2008-03-25 14:33:28.000000000 -0600
+++ work7/drivers/pnp/isapnp/core.c	2008-03-25 14:36:04.000000000 -0600
@@ -829,26 +829,6 @@
 }
 
 /*
- *  Parse EISA id for ISA PnP card.
- */
-static void isapnp_parse_card_id(struct pnp_card *card, unsigned short vendor,
-				 unsigned short device)
-{
-	char id[8];
-
-	id[0] = 'A' + ((vendor >> 2) & 0x3f) - 1;
-	id[1] = 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1;
-	id[2] = 'A' + ((vendor >> 8) & 0x1f) - 1;
-	id[3] = '0' + ((device >> 4) & 0x0f);
-	id[4] = '0' + (device & 0x0f);
-	id[5] = '0' + ((device >> 12) & 0x0f);
-	id[6] = '0' + ((device >> 8) & 0x0f);
-	id[7] = '\0';
-
-	pnp_add_card_id(card, id);
-}
-
-/*
  *  Build device list for all present ISA PnP devices.
  */
 static int __init isapnp_build_device_list(void)
@@ -856,6 +836,7 @@
 	int csn;
 	unsigned char header[9], checksum;
 	struct pnp_card *card;
+	char id[8];
 
 	isapnp_wait();
 	isapnp_key();
@@ -876,8 +857,9 @@
 
 		card->number = csn;
 		INIT_LIST_HEAD(&card->devices);
-		isapnp_parse_card_id(card, (header[1] << 8) | header[0],
-				     (header[3] << 8) | header[2]);
+		isapnp_to_pnpid((header[1] << 8) | header[0],
+				(header[3] << 8) | header[2], id);
+		pnp_add_card_id(card, id);
 		card->serial =
 		    (header[7] << 24) | (header[6] << 16) | (header[5] << 8) |
 		    header[4];

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 10/37] PNP: add pnp_alloc_card()
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (8 preceding siblings ...)
  2008-03-26 17:11 ` [patch 09/37] ISAPNP: pull pnp_add_card_id() out of isapnp_parse_card_id() Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 11/37] PNPACPI: pnpacpi_encode_ext_irq() wrongly set "irq" instead of "extended_irq" Bjorn Helgaas
                   ` (27 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-alloc-card --]
[-- Type: text/plain, Size: 3451 bytes --]

Add pnp_alloc_card() to allocate a struct pnp_card and fill in the
protocol, instance number, and initial PNP ID.  Now it is always
valid to use dev_printk() on any pnp_card pointer.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

---
 drivers/pnp/base.h        |    1 +
 drivers/pnp/card.c        |   28 +++++++++++++++++++++++++---
 drivers/pnp/isapnp/core.c |   11 ++++-------
 3 files changed, 30 insertions(+), 10 deletions(-)

Index: work7/drivers/pnp/base.h
===================================================================
--- work7.orig/drivers/pnp/base.h	2008-03-26 10:54:08.000000000 -0600
+++ work7/drivers/pnp/base.h	2008-03-26 10:54:11.000000000 -0600
@@ -1,6 +1,7 @@
 extern spinlock_t pnp_lock;
 void *pnp_alloc(long size);
 struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *, int id, char *pnpid);
+struct pnp_card *pnp_alloc_card(struct pnp_protocol *, int id, char *pnpid);
 struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id);
 struct pnp_id *pnp_add_card_id(struct pnp_card *card, char *id);
 int pnp_interface_attach_device(struct pnp_dev *dev);
Index: work7/drivers/pnp/card.c
===================================================================
--- work7.orig/drivers/pnp/card.c	2008-03-26 10:54:08.000000000 -0600
+++ work7/drivers/pnp/card.c	2008-03-26 10:54:59.000000000 -0600
@@ -151,6 +151,31 @@
 	kfree(card);
 }
 
+struct pnp_card *pnp_alloc_card(struct pnp_protocol *protocol, int id, char *pnpid)
+{
+	struct pnp_card *card;
+	struct pnp_id *dev_id;
+
+	card = kzalloc(sizeof(struct pnp_card), GFP_KERNEL);
+	if (!card)
+		return NULL;
+
+	card->protocol = protocol;
+	card->number = id;
+
+	card->dev.parent = &card->protocol->dev;
+	sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number,
+		card->number);
+
+	dev_id = pnp_add_card_id(card, pnpid);
+	if (!dev_id) {
+		kfree(card);
+		return NULL;
+	}
+
+	return card;
+}
+
 static ssize_t pnp_show_card_name(struct device *dmdev,
 				  struct device_attribute *attr, char *buf)
 {
@@ -206,9 +231,6 @@
 	int error;
 	struct list_head *pos, *temp;
 
-	sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number,
-		card->number);
-	card->dev.parent = &card->protocol->dev;
 	card->dev.bus = NULL;
 	card->dev.release = &pnp_release_card;
 	error = device_register(&card->dev);
Index: work7/drivers/pnp/isapnp/core.c
===================================================================
--- work7.orig/drivers/pnp/isapnp/core.c	2008-03-26 10:54:10.000000000 -0600
+++ work7/drivers/pnp/isapnp/core.c	2008-03-26 10:54:11.000000000 -0600
@@ -851,15 +851,13 @@
 		       header[5], header[6], header[7], header[8]);
 		printk(KERN_DEBUG "checksum = 0x%x\n", checksum);
 #endif
-		if ((card =
-		     kzalloc(sizeof(struct pnp_card), GFP_KERNEL)) == NULL)
+		isapnp_to_pnpid((header[1] << 8) | header[0],
+				(header[3] << 8) | header[2], id);
+		card = pnp_alloc_card(&isapnp_protocol, csn, id);
+		if (!card)
 			continue;
 
-		card->number = csn;
 		INIT_LIST_HEAD(&card->devices);
-		isapnp_to_pnpid((header[1] << 8) | header[0],
-				(header[3] << 8) | header[2], id);
-		pnp_add_card_id(card, id);
 		card->serial =
 		    (header[7] << 24) | (header[6] << 16) | (header[5] << 8) |
 		    header[4];
@@ -870,7 +868,6 @@
 			       "isapnp: checksum for device %i is not valid (0x%x)\n",
 			       csn, isapnp_checksum_value);
 		card->checksum = isapnp_checksum_value;
-		card->protocol = &isapnp_protocol;
 
 		pnp_add_card(card);
 	}

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 11/37] PNPACPI: pnpacpi_encode_ext_irq() wrongly set "irq" instead of "extended_irq"
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (9 preceding siblings ...)
  2008-03-26 17:11 ` [patch 10/37] PNP: add pnp_alloc_card() Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 12/37] PNPACPI: use temporaries to reduce repetition Bjorn Helgaas
                   ` (26 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnpacpi-fix-encode-extended-irq --]
[-- Type: text/plain, Size: 926 bytes --]

This has been wrong since at least 2.6.12.  I haven't seen any bug
reports, but it's clearly incorrect.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/pnp/pnpacpi/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/rsparser.c	2008-03-20 11:50:19.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/rsparser.c	2008-03-20 12:02:18.000000000 -0600
@@ -818,9 +818,9 @@
 	resource->data.extended_irq.triggering = triggering;
 	resource->data.extended_irq.polarity = polarity;
 	if (triggering == ACPI_EDGE_SENSITIVE)
-		resource->data.irq.sharable = ACPI_EXCLUSIVE;
+		resource->data.extended_irq.sharable = ACPI_EXCLUSIVE;
 	else
-		resource->data.irq.sharable = ACPI_SHARED;
+		resource->data.extended_irq.sharable = ACPI_SHARED;
 	resource->data.extended_irq.interrupt_count = 1;
 	resource->data.extended_irq.interrupts[0] = p->start;
 }

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 12/37] PNPACPI: use temporaries to reduce repetition
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (10 preceding siblings ...)
  2008-03-26 17:11 ` [patch 11/37] PNPACPI: pnpacpi_encode_ext_irq() wrongly set "irq" instead of "extended_irq" Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 13/37] PNPACPI: hoist dma_flags() out of pnpacpi_parse_allocated_dmaresource() Bjorn Helgaas
                   ` (25 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnpacpi-use-acpi-resource-temporaries --]
[-- Type: text/plain, Size: 10705 bytes --]

No functional change, just fewer words and fewer chances for
transcription errors.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/pnp/pnpacpi/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/rsparser.c	2008-03-20 12:07:31.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/rsparser.c	2008-03-20 12:14:54.000000000 -0600
@@ -278,6 +278,14 @@
 					      void *data)
 {
 	struct pnp_resource_table *res_table = data;
+	struct acpi_resource_irq *irq;
+	struct acpi_resource_dma *dma;
+	struct acpi_resource_io *io;
+	struct acpi_resource_fixed_io *fixed_io;
+	struct acpi_resource_memory24 *memory24;
+	struct acpi_resource_memory32 *memory32;
+	struct acpi_resource_fixed_memory32 *fixed_memory32;
+	struct acpi_resource_extended_irq *extended_irq;
 	int i;
 
 	switch (res->type) {
@@ -286,29 +294,32 @@
 		 * Per spec, only one interrupt per descriptor is allowed in
 		 * _CRS, but some firmware violates this, so parse them all.
 		 */
-		for (i = 0; i < res->data.irq.interrupt_count; i++) {
+		irq = &res->data.irq;
+		for (i = 0; i < irq->interrupt_count; i++) {
 			pnpacpi_parse_allocated_irqresource(res_table,
-				res->data.irq.interrupts[i],
-				res->data.irq.triggering,
-				res->data.irq.polarity,
-				res->data.irq.sharable);
+				irq->interrupts[i],
+				irq->triggering,
+				irq->polarity,
+				irq->sharable);
 		}
 		break;
 
 	case ACPI_RESOURCE_TYPE_DMA:
-		if (res->data.dma.channel_count > 0)
+		dma = &res->data.dma;
+		if (dma->channel_count > 0)
 			pnpacpi_parse_allocated_dmaresource(res_table,
-				res->data.dma.channels[0],
-				res->data.dma.type,
-				res->data.dma.bus_master,
-				res->data.dma.transfer);
+				dma->channels[0],
+				dma->type,
+				dma->bus_master,
+				dma->transfer);
 		break;
 
 	case ACPI_RESOURCE_TYPE_IO:
+		io = &res->data.io;
 		pnpacpi_parse_allocated_ioresource(res_table,
-			res->data.io.minimum,
-			res->data.io.address_length,
-			res->data.io.io_decode);
+			io->minimum,
+			io->address_length,
+			io->io_decode);
 		break;
 
 	case ACPI_RESOURCE_TYPE_START_DEPENDENT:
@@ -316,9 +327,10 @@
 		break;
 
 	case ACPI_RESOURCE_TYPE_FIXED_IO:
+		fixed_io = &res->data.fixed_io;
 		pnpacpi_parse_allocated_ioresource(res_table,
-			res->data.fixed_io.address,
-			res->data.fixed_io.address_length,
+			fixed_io->address,
+			fixed_io->address_length,
 			ACPI_DECODE_10);
 		break;
 
@@ -329,22 +341,25 @@
 		break;
 
 	case ACPI_RESOURCE_TYPE_MEMORY24:
+		memory24 = &res->data.memory24;
 		pnpacpi_parse_allocated_memresource(res_table,
-			res->data.memory24.minimum,
-			res->data.memory24.address_length,
-			res->data.memory24.write_protect);
+			memory24->minimum,
+			memory24->address_length,
+			memory24->write_protect);
 		break;
 	case ACPI_RESOURCE_TYPE_MEMORY32:
+		memory32 = &res->data.memory32;
 		pnpacpi_parse_allocated_memresource(res_table,
-			res->data.memory32.minimum,
-			res->data.memory32.address_length,
-			res->data.memory32.write_protect);
+			memory32->minimum,
+			memory32->address_length,
+			memory32->write_protect);
 		break;
 	case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
+		fixed_memory32 = &res->data.fixed_memory32;
 		pnpacpi_parse_allocated_memresource(res_table,
-			res->data.fixed_memory32.address,
-			res->data.fixed_memory32.address_length,
-			res->data.fixed_memory32.write_protect);
+			fixed_memory32->address,
+			fixed_memory32->address_length,
+			fixed_memory32->write_protect);
 		break;
 	case ACPI_RESOURCE_TYPE_ADDRESS16:
 	case ACPI_RESOURCE_TYPE_ADDRESS32:
@@ -358,15 +373,16 @@
 		break;
 
 	case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
-		if (res->data.extended_irq.producer_consumer == ACPI_PRODUCER)
+		extended_irq = &res->data.extended_irq;
+		if (extended_irq->producer_consumer == ACPI_PRODUCER)
 			return AE_OK;
 
-		for (i = 0; i < res->data.extended_irq.interrupt_count; i++) {
+		for (i = 0; i < extended_irq->interrupt_count; i++) {
 			pnpacpi_parse_allocated_irqresource(res_table,
-				res->data.extended_irq.interrupts[i],
-				res->data.extended_irq.triggering,
-				res->data.extended_irq.polarity,
-				res->data.extended_irq.sharable);
+				extended_irq->interrupts[i],
+				extended_irq->triggering,
+				extended_irq->polarity,
+				extended_irq->sharable);
 		}
 		break;
 
@@ -795,122 +811,136 @@
 static void pnpacpi_encode_irq(struct acpi_resource *resource,
 			       struct resource *p)
 {
+	struct acpi_resource_irq *irq = &resource->data.irq;
 	int triggering, polarity;
 
 	decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, &polarity);
-	resource->data.irq.triggering = triggering;
-	resource->data.irq.polarity = polarity;
+	irq->triggering = triggering;
+	irq->polarity = polarity;
 	if (triggering == ACPI_EDGE_SENSITIVE)
-		resource->data.irq.sharable = ACPI_EXCLUSIVE;
+		irq->sharable = ACPI_EXCLUSIVE;
 	else
-		resource->data.irq.sharable = ACPI_SHARED;
-	resource->data.irq.interrupt_count = 1;
-	resource->data.irq.interrupts[0] = p->start;
+		irq->sharable = ACPI_SHARED;
+	irq->interrupt_count = 1;
+	irq->interrupts[0] = p->start;
 }
 
 static void pnpacpi_encode_ext_irq(struct acpi_resource *resource,
 				   struct resource *p)
 {
+	struct acpi_resource_extended_irq *extended_irq = &resource->data.extended_irq;
 	int triggering, polarity;
 
 	decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, &polarity);
-	resource->data.extended_irq.producer_consumer = ACPI_CONSUMER;
-	resource->data.extended_irq.triggering = triggering;
-	resource->data.extended_irq.polarity = polarity;
+	extended_irq->producer_consumer = ACPI_CONSUMER;
+	extended_irq->triggering = triggering;
+	extended_irq->polarity = polarity;
 	if (triggering == ACPI_EDGE_SENSITIVE)
-		resource->data.extended_irq.sharable = ACPI_EXCLUSIVE;
+		extended_irq->sharable = ACPI_EXCLUSIVE;
 	else
-		resource->data.extended_irq.sharable = ACPI_SHARED;
-	resource->data.extended_irq.interrupt_count = 1;
-	resource->data.extended_irq.interrupts[0] = p->start;
+		extended_irq->sharable = ACPI_SHARED;
+	extended_irq->interrupt_count = 1;
+	extended_irq->interrupts[0] = p->start;
 }
 
 static void pnpacpi_encode_dma(struct acpi_resource *resource,
 			       struct resource *p)
 {
+	struct acpi_resource_dma *dma = &resource->data.dma;
+
 	/* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */
 	switch (p->flags & IORESOURCE_DMA_SPEED_MASK) {
 	case IORESOURCE_DMA_TYPEA:
-		resource->data.dma.type = ACPI_TYPE_A;
+		dma->type = ACPI_TYPE_A;
 		break;
 	case IORESOURCE_DMA_TYPEB:
-		resource->data.dma.type = ACPI_TYPE_B;
+		dma->type = ACPI_TYPE_B;
 		break;
 	case IORESOURCE_DMA_TYPEF:
-		resource->data.dma.type = ACPI_TYPE_F;
+		dma->type = ACPI_TYPE_F;
 		break;
 	default:
-		resource->data.dma.type = ACPI_COMPATIBILITY;
+		dma->type = ACPI_COMPATIBILITY;
 	}
 
 	switch (p->flags & IORESOURCE_DMA_TYPE_MASK) {
 	case IORESOURCE_DMA_8BIT:
-		resource->data.dma.transfer = ACPI_TRANSFER_8;
+		dma->transfer = ACPI_TRANSFER_8;
 		break;
 	case IORESOURCE_DMA_8AND16BIT:
-		resource->data.dma.transfer = ACPI_TRANSFER_8_16;
+		dma->transfer = ACPI_TRANSFER_8_16;
 		break;
 	default:
-		resource->data.dma.transfer = ACPI_TRANSFER_16;
+		dma->transfer = ACPI_TRANSFER_16;
 	}
 
-	resource->data.dma.bus_master = !!(p->flags & IORESOURCE_DMA_MASTER);
-	resource->data.dma.channel_count = 1;
-	resource->data.dma.channels[0] = p->start;
+	dma->bus_master = !!(p->flags & IORESOURCE_DMA_MASTER);
+	dma->channel_count = 1;
+	dma->channels[0] = p->start;
 }
 
 static void pnpacpi_encode_io(struct acpi_resource *resource,
 			      struct resource *p)
 {
+	struct acpi_resource_io *io = &resource->data.io;
+
 	/* Note: pnp_assign_port will copy pnp_port->flags into p->flags */
-	resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR) ?
+	io->io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR) ?
 	    ACPI_DECODE_16 : ACPI_DECODE_10;
-	resource->data.io.minimum = p->start;
-	resource->data.io.maximum = p->end;
-	resource->data.io.alignment = 0;	/* Correct? */
-	resource->data.io.address_length = p->end - p->start + 1;
+	io->minimum = p->start;
+	io->maximum = p->end;
+	io->alignment = 0;	/* Correct? */
+	io->address_length = p->end - p->start + 1;
 }
 
 static void pnpacpi_encode_fixed_io(struct acpi_resource *resource,
 				    struct resource *p)
 {
-	resource->data.fixed_io.address = p->start;
-	resource->data.fixed_io.address_length = p->end - p->start + 1;
+	struct acpi_resource_fixed_io *fixed_io = &resource->data.fixed_io;
+
+	fixed_io->address = p->start;
+	fixed_io->address_length = p->end - p->start + 1;
 }
 
 static void pnpacpi_encode_mem24(struct acpi_resource *resource,
 				 struct resource *p)
 {
+	struct acpi_resource_memory24 *memory24 = &resource->data.memory24;
+
 	/* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */
-	resource->data.memory24.write_protect =
+	memory24->write_protect =
 	    (p->flags & IORESOURCE_MEM_WRITEABLE) ?
 	    ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
-	resource->data.memory24.minimum = p->start;
-	resource->data.memory24.maximum = p->end;
-	resource->data.memory24.alignment = 0;
-	resource->data.memory24.address_length = p->end - p->start + 1;
+	memory24->minimum = p->start;
+	memory24->maximum = p->end;
+	memory24->alignment = 0;
+	memory24->address_length = p->end - p->start + 1;
 }
 
 static void pnpacpi_encode_mem32(struct acpi_resource *resource,
 				 struct resource *p)
 {
-	resource->data.memory32.write_protect =
+	struct acpi_resource_memory32 *memory32 = &resource->data.memory32;
+
+	memory32->write_protect =
 	    (p->flags & IORESOURCE_MEM_WRITEABLE) ?
 	    ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
-	resource->data.memory32.minimum = p->start;
-	resource->data.memory32.maximum = p->end;
-	resource->data.memory32.alignment = 0;
-	resource->data.memory32.address_length = p->end - p->start + 1;
+	memory32->minimum = p->start;
+	memory32->maximum = p->end;
+	memory32->alignment = 0;
+	memory32->address_length = p->end - p->start + 1;
 }
 
 static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource,
 				       struct resource *p)
 {
-	resource->data.fixed_memory32.write_protect =
+	struct acpi_resource_fixed_memory32 *fixed_memory32 = &resource->data.fixed_memory32;
+
+	fixed_memory32->write_protect =
 	    (p->flags & IORESOURCE_MEM_WRITEABLE) ?
 	    ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
-	resource->data.fixed_memory32.address = p->start;
-	resource->data.fixed_memory32.address_length = p->end - p->start + 1;
+	fixed_memory32->address = p->start;
+	fixed_memory32->address_length = p->end - p->start + 1;
 }
 
 int pnpacpi_encode_resources(struct pnp_resource_table *res_table,

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 13/37] PNPACPI: hoist dma_flags() out of pnpacpi_parse_allocated_dmaresource()
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (11 preceding siblings ...)
  2008-03-26 17:11 ` [patch 12/37] PNPACPI: use temporaries to reduce repetition Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 14/37] PNPACPI: extend irq_flags() to set IORESOURCE_IRQ_SHAREABLE when appropriate Bjorn Helgaas
                   ` (24 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnpacpi-hoist-dma-flags --]
[-- Type: text/plain, Size: 1386 bytes --]

Hoist dma_flags() out of pnpacpi_parse_allocated_dmaresource() into its
caller.  This makes pnpacpi_parse_allocated_dmaresource() more similar
to pnpbios_parse_allocated_dmaresource().

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/pnp/pnpacpi/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/rsparser.c	2008-03-21 15:08:36.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/rsparser.c	2008-03-21 15:10:22.000000000 -0600
@@ -167,8 +167,7 @@
 }
 
 static void pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res,
-						u32 dma, int type,
-						int bus_master, int transfer)
+						u32 dma, int flags)
 {
 	int i = 0;
 	static unsigned char warned;
@@ -178,8 +177,7 @@
 		i++;
 	if (i < PNP_MAX_DMA) {
 		res->dma_resource[i].flags = IORESOURCE_DMA;	// Also clears _UNSET flag
-		res->dma_resource[i].flags |=
-		    dma_flags(type, bus_master, transfer);
+		res->dma_resource[i].flags |= flags;
 		if (dma == -1) {
 			res->dma_resource[i].flags |= IORESOURCE_DISABLED;
 			return;
@@ -309,9 +307,8 @@
 		if (dma->channel_count > 0)
 			pnpacpi_parse_allocated_dmaresource(res_table,
 				dma->channels[0],
-				dma->type,
-				dma->bus_master,
-				dma->transfer);
+				dma_flags(dma->type, dma->bus_master,
+					  dma->transfer));
 		break;
 
 	case ACPI_RESOURCE_TYPE_IO:

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 14/37] PNPACPI: extend irq_flags() to set IORESOURCE_IRQ_SHAREABLE when appropriate
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (12 preceding siblings ...)
  2008-03-26 17:11 ` [patch 13/37] PNPACPI: hoist dma_flags() out of pnpacpi_parse_allocated_dmaresource() Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 15/37] PNPACPI: pass pnp_dev instead of acpi_handle Bjorn Helgaas
                   ` (23 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnpacpi-add-shareability-to-irq-flags --]
[-- Type: text/plain, Size: 2514 bytes --]

This simplifies IRQ resource parsing slightly by computing all the
IORESOURCE_IRQ_* flags at the same time.

This also keeps track of shareability information when parsing options
from _PRS.  Previously we ignored shareability in _PRS.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/pnp/pnpacpi/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/rsparser.c	2008-03-21 15:10:22.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/rsparser.c	2008-03-21 15:10:23.000000000 -0600
@@ -32,19 +32,26 @@
 /*
  * Allocated Resources
  */
-static int irq_flags(int triggering, int polarity)
+static int irq_flags(int triggering, int polarity, int shareable)
 {
+	int flags;
+
 	if (triggering == ACPI_LEVEL_SENSITIVE) {
 		if (polarity == ACPI_ACTIVE_LOW)
-			return IORESOURCE_IRQ_LOWLEVEL;
+			flags = IORESOURCE_IRQ_LOWLEVEL;
 		else
-			return IORESOURCE_IRQ_HIGHLEVEL;
+			flags = IORESOURCE_IRQ_HIGHLEVEL;
 	} else {
 		if (polarity == ACPI_ACTIVE_LOW)
-			return IORESOURCE_IRQ_LOWEDGE;
+			flags = IORESOURCE_IRQ_LOWEDGE;
 		else
-			return IORESOURCE_IRQ_HIGHEDGE;
+			flags = IORESOURCE_IRQ_HIGHEDGE;
 	}
+
+	if (shareable)
+		flags |= IORESOURCE_IRQ_SHAREABLE;
+
+	return flags;
 }
 
 static void decode_irq_flags(int flag, int *triggering, int *polarity)
@@ -108,16 +115,13 @@
 	}
 
 	res->irq_resource[i].flags = IORESOURCE_IRQ;	// Also clears _UNSET flag
-	res->irq_resource[i].flags |= irq_flags(triggering, polarity);
+	res->irq_resource[i].flags |= irq_flags(triggering, polarity, shareable);
 	irq = acpi_register_gsi(gsi, triggering, polarity);
 	if (irq < 0) {
 		res->irq_resource[i].flags |= IORESOURCE_DISABLED;
 		return;
 	}
 
-	if (shareable)
-		res->irq_resource[i].flags |= IORESOURCE_IRQ_SHAREABLE;
-
 	res->irq_resource[i].start = irq;
 	res->irq_resource[i].end = irq;
 	pcibios_penalize_isa_irq(irq, 1);
@@ -439,7 +443,7 @@
 	for (i = 0; i < p->interrupt_count; i++)
 		if (p->interrupts[i])
 			__set_bit(p->interrupts[i], irq->map);
-	irq->flags = irq_flags(p->triggering, p->polarity);
+	irq->flags = irq_flags(p->triggering, p->polarity, p->sharable);
 
 	pnp_register_irq_resource(option, irq);
 }
@@ -459,7 +463,7 @@
 	for (i = 0; i < p->interrupt_count; i++)
 		if (p->interrupts[i])
 			__set_bit(p->interrupts[i], irq->map);
-	irq->flags = irq_flags(p->triggering, p->polarity);
+	irq->flags = irq_flags(p->triggering, p->polarity, p->sharable);
 
 	pnp_register_irq_resource(option, irq);
 }

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 15/37] PNPACPI: pass pnp_dev instead of acpi_handle
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (13 preceding siblings ...)
  2008-03-26 17:11 ` [patch 14/37] PNPACPI: extend irq_flags() to set IORESOURCE_IRQ_SHAREABLE when appropriate Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 16/37] PNP: remove pnp_resource_table from internal get/set interfaces Bjorn Helgaas
                   ` (22 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnpacpi-use-pnp_dev --]
[-- Type: text/plain, Size: 2057 bytes --]

Pass the pnp_dev pointer when possible instead of the acpi_handle.
This allows better error messages and reduces the chance of error
in the caller.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/pnp/pnpacpi/core.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/core.c	2008-03-21 15:35:05.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/core.c	2008-03-21 15:36:00.000000000 -0600
@@ -88,10 +88,10 @@
 {
 	acpi_handle handle = dev->data;
 	struct acpi_buffer buffer;
-	int ret = 0;
+	int ret;
 	acpi_status status;
 
-	ret = pnpacpi_build_resource_template(handle, &buffer);
+	ret = pnpacpi_build_resource_template(dev, &buffer);
 	if (ret)
 		return ret;
 	ret = pnpacpi_encode_resources(res, &buffer);
Index: work7/drivers/pnp/pnpacpi/pnpacpi.h
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/pnpacpi.h	2008-03-21 15:28:07.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/pnpacpi.h	2008-03-21 15:36:00.000000000 -0600
@@ -8,5 +8,5 @@
 acpi_status pnpacpi_parse_allocated_resource(acpi_handle, struct pnp_resource_table*);
 acpi_status pnpacpi_parse_resource_option_data(acpi_handle, struct pnp_dev*);
 int pnpacpi_encode_resources(struct pnp_resource_table *, struct acpi_buffer *);
-int pnpacpi_build_resource_template(acpi_handle, struct acpi_buffer*);
+int pnpacpi_build_resource_template(struct pnp_dev *, struct acpi_buffer *);
 #endif
Index: work7/drivers/pnp/pnpacpi/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/rsparser.c	2008-03-21 15:35:59.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/rsparser.c	2008-03-21 15:36:00.000000000 -0600
@@ -775,9 +775,10 @@
 	return AE_OK;
 }
 
-int pnpacpi_build_resource_template(acpi_handle handle,
+int pnpacpi_build_resource_template(struct pnp_dev *dev,
 				    struct acpi_buffer *buffer)
 {
+	acpi_handle handle = dev->data;
 	struct acpi_resource *resource;
 	int res_cnt = 0;
 	acpi_status status;

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 16/37] PNP: remove pnp_resource_table from internal get/set interfaces
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (14 preceding siblings ...)
  2008-03-26 17:11 ` [patch 15/37] PNPACPI: pass pnp_dev instead of acpi_handle Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 17/37] PNP: remove more pnp_resource_table arguments Bjorn Helgaas
                   ` (21 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-remove-pnp_resource_table-args-from-get-set --]
[-- Type: text/plain, Size: 5378 bytes --]

When we call protocol->get() and protocol->set() methods, we currently
supply pointers to both the pnp_dev and the pnp_resource_table even
though the pnp_resource_table should always be the one associated with
the pnp_dev.

This removes the pnp_resource_table arguments to make it clear that
these methods only operate on the specified pnp_dev.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

---
 include/linux/pnp.h        |    4 ++--
 drivers/pnp/interface.c    |    2 +-
 drivers/pnp/manager.c      |    2 +-
 drivers/pnp/isapnp/core.c  |   11 +++++------
 drivers/pnp/pnpacpi/core.c |    8 +++-----
 drivers/pnp/pnpbios/core.c |   10 ++++------
 6 files changed, 16 insertions(+), 21 deletions(-)

Index: work7/include/linux/pnp.h
===================================================================
--- work7.orig/include/linux/pnp.h	2008-03-25 14:48:32.000000000 -0600
+++ work7/include/linux/pnp.h	2008-03-25 14:48:39.000000000 -0600
@@ -328,8 +328,8 @@
 	char *name;
 
 	/* resource control functions */
-	int (*get) (struct pnp_dev *dev, struct pnp_resource_table *res);
-	int (*set) (struct pnp_dev *dev, struct pnp_resource_table *res);
+	int (*get) (struct pnp_dev *dev);
+	int (*set) (struct pnp_dev *dev);
 	int (*disable) (struct pnp_dev *dev);
 
 	/* protocol specific suspend/resume */
Index: work7/drivers/pnp/interface.c
===================================================================
--- work7.orig/drivers/pnp/interface.c	2008-03-25 14:48:21.000000000 -0600
+++ work7/drivers/pnp/interface.c	2008-03-25 14:48:39.000000000 -0600
@@ -364,7 +364,7 @@
 	if (!strnicmp(buf, "get", 3)) {
 		mutex_lock(&pnp_res_mutex);
 		if (pnp_can_read(dev))
-			dev->protocol->get(dev, &dev->res);
+			dev->protocol->get(dev);
 		mutex_unlock(&pnp_res_mutex);
 		goto done;
 	}
Index: work7/drivers/pnp/manager.c
===================================================================
--- work7.orig/drivers/pnp/manager.c	2008-03-25 14:48:21.000000000 -0600
+++ work7/drivers/pnp/manager.c	2008-03-25 14:48:39.000000000 -0600
@@ -473,7 +473,7 @@
 		return -EINVAL;
 	}
 
-	if (dev->protocol->set(dev, &dev->res) < 0) {
+	if (dev->protocol->set(dev) < 0) {
 		dev_err(&dev->dev, "activation failed\n");
 		return -EIO;
 	}
Index: work7/drivers/pnp/isapnp/core.c
===================================================================
--- work7.orig/drivers/pnp/isapnp/core.c	2008-03-25 14:48:35.000000000 -0600
+++ work7/drivers/pnp/isapnp/core.c	2008-03-25 14:48:39.000000000 -0600
@@ -978,21 +978,20 @@
 	return 0;
 }
 
-static int isapnp_get_resources(struct pnp_dev *dev,
-				struct pnp_resource_table *res)
+static int isapnp_get_resources(struct pnp_dev *dev)
 {
 	int ret;
 
-	pnp_init_resource_table(res);
+	pnp_init_resource_table(&dev->res);
 	isapnp_cfg_begin(dev->card->number, dev->number);
-	ret = isapnp_read_resources(dev, res);
+	ret = isapnp_read_resources(dev, &dev->res);
 	isapnp_cfg_end();
 	return ret;
 }
 
-static int isapnp_set_resources(struct pnp_dev *dev,
-				struct pnp_resource_table *res)
+static int isapnp_set_resources(struct pnp_dev *dev)
 {
+	struct pnp_resource_table *res = &dev->res;
 	int tmp;
 
 	isapnp_cfg_begin(dev->card->number, dev->number);
Index: work7/drivers/pnp/pnpacpi/core.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/core.c	2008-03-25 14:48:38.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/core.c	2008-03-25 14:48:39.000000000 -0600
@@ -73,8 +73,7 @@
 	return 1;
 }
 
-static int pnpacpi_get_resources(struct pnp_dev *dev,
-				 struct pnp_resource_table *res)
+static int pnpacpi_get_resources(struct pnp_dev *dev)
 {
 	acpi_status status;
 
@@ -83,8 +82,7 @@
 	return ACPI_FAILURE(status) ? -ENODEV : 0;
 }
 
-static int pnpacpi_set_resources(struct pnp_dev *dev,
-				 struct pnp_resource_table *res)
+static int pnpacpi_set_resources(struct pnp_dev *dev)
 {
 	acpi_handle handle = dev->data;
 	struct acpi_buffer buffer;
@@ -94,7 +92,7 @@
 	ret = pnpacpi_build_resource_template(dev, &buffer);
 	if (ret)
 		return ret;
-	ret = pnpacpi_encode_resources(res, &buffer);
+	ret = pnpacpi_encode_resources(&dev->res, &buffer);
 	if (ret) {
 		kfree(buffer.pointer);
 		return ret;
Index: work7/drivers/pnp/pnpbios/core.c
===================================================================
--- work7.orig/drivers/pnp/pnpbios/core.c	2008-03-25 14:48:31.000000000 -0600
+++ work7/drivers/pnp/pnpbios/core.c	2008-03-25 14:48:39.000000000 -0600
@@ -204,8 +204,7 @@
 
 #endif				/* CONFIG_HOTPLUG */
 
-static int pnpbios_get_resources(struct pnp_dev *dev,
-				 struct pnp_resource_table *res)
+static int pnpbios_get_resources(struct pnp_dev *dev)
 {
 	u8 nodenum = dev->number;
 	struct pnp_bios_node *node;
@@ -220,14 +219,13 @@
 		kfree(node);
 		return -ENODEV;
 	}
-	pnpbios_read_resources_from_node(res, node);
+	pnpbios_read_resources_from_node(&dev->res, node);
 	dev->active = pnp_is_active(dev);
 	kfree(node);
 	return 0;
 }
 
-static int pnpbios_set_resources(struct pnp_dev *dev,
-				 struct pnp_resource_table *res)
+static int pnpbios_set_resources(struct pnp_dev *dev)
 {
 	u8 nodenum = dev->number;
 	struct pnp_bios_node *node;
@@ -243,7 +241,7 @@
 		kfree(node);
 		return -ENODEV;
 	}
-	if (pnpbios_write_resources_to_node(res, node) < 0) {
+	if (pnpbios_write_resources_to_node(&dev->res, node) < 0) {
 		kfree(node);
 		return -1;
 	}

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 17/37] PNP: remove more pnp_resource_table arguments
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (15 preceding siblings ...)
  2008-03-26 17:11 ` [patch 16/37] PNP: remove pnp_resource_table from internal get/set interfaces Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 18/37] PNP: add pnp_init_resources(struct pnp_dev *) interface Bjorn Helgaas
                   ` (20 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-remove-more-pnp_resource_table-args --]
[-- Type: text/plain, Size: 17491 bytes --]

Stop passing around struct pnp_resource_table pointers.  In most cases,
the caller doesn't need to know how the resources are stored inside
the struct pnp_dev.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

---
 drivers/pnp/isapnp/core.c      |    6 ++--
 drivers/pnp/pnpacpi/core.c     |   11 ++-----
 drivers/pnp/pnpacpi/pnpacpi.h  |    6 ++--
 drivers/pnp/pnpacpi/rsparser.c |   55 +++++++++++++++++++++-----------------
 drivers/pnp/pnpbios/core.c     |    4 +-
 drivers/pnp/pnpbios/pnpbios.h  |    4 +-
 drivers/pnp/pnpbios/rsparser.c |   58 ++++++++++++++++++++---------------------
 7 files changed, 73 insertions(+), 71 deletions(-)

Index: work7/drivers/pnp/isapnp/core.c
===================================================================
--- work7.orig/drivers/pnp/isapnp/core.c	2008-03-25 14:48:39.000000000 -0600
+++ work7/drivers/pnp/isapnp/core.c	2008-03-25 14:48:44.000000000 -0600
@@ -934,9 +934,9 @@
 EXPORT_SYMBOL(isapnp_cfg_end);
 EXPORT_SYMBOL(isapnp_write_byte);
 
-static int isapnp_read_resources(struct pnp_dev *dev,
-				 struct pnp_resource_table *res)
+static int isapnp_read_resources(struct pnp_dev *dev)
 {
+	struct pnp_resource_table *res = &dev->res;
 	int tmp, ret;
 
 	dev->active = isapnp_read_byte(ISAPNP_CFG_ACTIVATE);
@@ -984,7 +984,7 @@
 
 	pnp_init_resource_table(&dev->res);
 	isapnp_cfg_begin(dev->card->number, dev->number);
-	ret = isapnp_read_resources(dev, &dev->res);
+	ret = isapnp_read_resources(dev);
 	isapnp_cfg_end();
 	return ret;
 }
Index: work7/drivers/pnp/pnpacpi/core.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/core.c	2008-03-25 14:48:39.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/core.c	2008-03-25 14:48:44.000000000 -0600
@@ -77,8 +77,7 @@
 {
 	acpi_status status;
 
-	status = pnpacpi_parse_allocated_resource((acpi_handle) dev->data,
-						  &dev->res);
+	status = pnpacpi_parse_allocated_resource(dev);
 	return ACPI_FAILURE(status) ? -ENODEV : 0;
 }
 
@@ -92,7 +91,7 @@
 	ret = pnpacpi_build_resource_template(dev, &buffer);
 	if (ret)
 		return ret;
-	ret = pnpacpi_encode_resources(&dev->res, &buffer);
+	ret = pnpacpi_encode_resources(dev, &buffer);
 	if (ret) {
 		kfree(buffer.pointer);
 		return ret;
@@ -183,8 +182,7 @@
 
 	if (dev->active) {
 		/* parse allocated resource */
-		status = pnpacpi_parse_allocated_resource(device->handle,
-							  &dev->res);
+		status = pnpacpi_parse_allocated_resource(dev);
 		if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
 			pnp_err("PnPACPI: METHOD_NAME__CRS failure for %s",
 				acpi_device_hid(device));
@@ -192,8 +190,7 @@
 	}
 
 	if (dev->capabilities & PNP_CONFIGURABLE) {
-		status = pnpacpi_parse_resource_option_data(device->handle,
-							    dev);
+		status = pnpacpi_parse_resource_option_data(dev);
 		if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
 			pnp_err("PnPACPI: METHOD_NAME__PRS failure for %s",
 				acpi_device_hid(device));
Index: work7/drivers/pnp/pnpacpi/pnpacpi.h
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/pnpacpi.h	2008-03-25 14:48:38.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/pnpacpi.h	2008-03-25 14:48:44.000000000 -0600
@@ -5,8 +5,8 @@
 #include <linux/acpi.h>
 #include <linux/pnp.h>
 
-acpi_status pnpacpi_parse_allocated_resource(acpi_handle, struct pnp_resource_table*);
-acpi_status pnpacpi_parse_resource_option_data(acpi_handle, struct pnp_dev*);
-int pnpacpi_encode_resources(struct pnp_resource_table *, struct acpi_buffer *);
+acpi_status pnpacpi_parse_allocated_resource(struct pnp_dev *);
+acpi_status pnpacpi_parse_resource_option_data(struct pnp_dev *);
+int pnpacpi_encode_resources(struct pnp_dev *, struct acpi_buffer *);
 int pnpacpi_build_resource_template(struct pnp_dev *, struct acpi_buffer *);
 #endif
Index: work7/drivers/pnp/pnpacpi/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/rsparser.c	2008-03-25 14:48:38.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/rsparser.c	2008-03-25 14:48:44.000000000 -0600
@@ -76,10 +76,11 @@
 	}
 }
 
-static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res,
+static void pnpacpi_parse_allocated_irqresource(struct pnp_dev *dev,
 						u32 gsi, int triggering,
 						int polarity, int shareable)
 {
+	struct pnp_resource_table *res = &dev->res;
 	int i = 0;
 	int irq;
 	int p, t;
@@ -170,9 +171,10 @@
 	return flags;
 }
 
-static void pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res,
+static void pnpacpi_parse_allocated_dmaresource(struct pnp_dev *dev,
 						u32 dma, int flags)
 {
+	struct pnp_resource_table *res = &dev->res;
 	int i = 0;
 	static unsigned char warned;
 
@@ -195,9 +197,10 @@
 	}
 }
 
-static void pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res,
+static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev,
 					       u64 io, u64 len, int io_decode)
 {
+	struct pnp_resource_table *res = &dev->res;
 	int i = 0;
 	static unsigned char warned;
 
@@ -221,10 +224,11 @@
 	}
 }
 
-static void pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res,
+static void pnpacpi_parse_allocated_memresource(struct pnp_dev *dev,
 						u64 mem, u64 len,
 						int write_protect)
 {
+	struct pnp_resource_table *res = &dev->res;
 	int i = 0;
 	static unsigned char warned;
 
@@ -249,7 +253,7 @@
 	}
 }
 
-static void pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table,
+static void pnpacpi_parse_allocated_address_space(struct pnp_dev *dev,
 						  struct acpi_resource *res)
 {
 	struct acpi_resource_address64 addr, *p = &addr;
@@ -266,11 +270,11 @@
 		return;
 
 	if (p->resource_type == ACPI_MEMORY_RANGE)
-		pnpacpi_parse_allocated_memresource(res_table,
+		pnpacpi_parse_allocated_memresource(dev,
 			p->minimum, p->address_length,
 			p->info.mem.write_protect);
 	else if (p->resource_type == ACPI_IO_RANGE)
-		pnpacpi_parse_allocated_ioresource(res_table,
+		pnpacpi_parse_allocated_ioresource(dev,
 			p->minimum, p->address_length,
 			p->granularity == 0xfff ? ACPI_DECODE_10 :
 				ACPI_DECODE_16);
@@ -279,7 +283,7 @@
 static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
 					      void *data)
 {
-	struct pnp_resource_table *res_table = data;
+	struct pnp_dev *dev = data;
 	struct acpi_resource_irq *irq;
 	struct acpi_resource_dma *dma;
 	struct acpi_resource_io *io;
@@ -298,7 +302,7 @@
 		 */
 		irq = &res->data.irq;
 		for (i = 0; i < irq->interrupt_count; i++) {
-			pnpacpi_parse_allocated_irqresource(res_table,
+			pnpacpi_parse_allocated_irqresource(dev,
 				irq->interrupts[i],
 				irq->triggering,
 				irq->polarity,
@@ -309,7 +313,7 @@
 	case ACPI_RESOURCE_TYPE_DMA:
 		dma = &res->data.dma;
 		if (dma->channel_count > 0)
-			pnpacpi_parse_allocated_dmaresource(res_table,
+			pnpacpi_parse_allocated_dmaresource(dev,
 				dma->channels[0],
 				dma_flags(dma->type, dma->bus_master,
 					  dma->transfer));
@@ -317,7 +321,7 @@
 
 	case ACPI_RESOURCE_TYPE_IO:
 		io = &res->data.io;
-		pnpacpi_parse_allocated_ioresource(res_table,
+		pnpacpi_parse_allocated_ioresource(dev,
 			io->minimum,
 			io->address_length,
 			io->io_decode);
@@ -329,7 +333,7 @@
 
 	case ACPI_RESOURCE_TYPE_FIXED_IO:
 		fixed_io = &res->data.fixed_io;
-		pnpacpi_parse_allocated_ioresource(res_table,
+		pnpacpi_parse_allocated_ioresource(dev,
 			fixed_io->address,
 			fixed_io->address_length,
 			ACPI_DECODE_10);
@@ -343,21 +347,21 @@
 
 	case ACPI_RESOURCE_TYPE_MEMORY24:
 		memory24 = &res->data.memory24;
-		pnpacpi_parse_allocated_memresource(res_table,
+		pnpacpi_parse_allocated_memresource(dev,
 			memory24->minimum,
 			memory24->address_length,
 			memory24->write_protect);
 		break;
 	case ACPI_RESOURCE_TYPE_MEMORY32:
 		memory32 = &res->data.memory32;
-		pnpacpi_parse_allocated_memresource(res_table,
+		pnpacpi_parse_allocated_memresource(dev,
 			memory32->minimum,
 			memory32->address_length,
 			memory32->write_protect);
 		break;
 	case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
 		fixed_memory32 = &res->data.fixed_memory32;
-		pnpacpi_parse_allocated_memresource(res_table,
+		pnpacpi_parse_allocated_memresource(dev,
 			fixed_memory32->address,
 			fixed_memory32->address_length,
 			fixed_memory32->write_protect);
@@ -365,7 +369,7 @@
 	case ACPI_RESOURCE_TYPE_ADDRESS16:
 	case ACPI_RESOURCE_TYPE_ADDRESS32:
 	case ACPI_RESOURCE_TYPE_ADDRESS64:
-		pnpacpi_parse_allocated_address_space(res_table, res);
+		pnpacpi_parse_allocated_address_space(dev, res);
 		break;
 
 	case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
@@ -379,7 +383,7 @@
 			return AE_OK;
 
 		for (i = 0; i < extended_irq->interrupt_count; i++) {
-			pnpacpi_parse_allocated_irqresource(res_table,
+			pnpacpi_parse_allocated_irqresource(dev,
 				extended_irq->interrupts[i],
 				extended_irq->triggering,
 				extended_irq->polarity,
@@ -398,14 +402,15 @@
 	return AE_OK;
 }
 
-acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle,
-					     struct pnp_resource_table * res)
+acpi_status pnpacpi_parse_allocated_resource(struct pnp_dev *dev)
 {
+	acpi_handle handle = dev->data;
+
 	/* Blank the resource table values */
-	pnp_init_resource_table(res);
+	pnp_init_resource_table(&dev->res);
 
 	return acpi_walk_resources(handle, METHOD_NAME__CRS,
-				   pnpacpi_allocated_resource, res);
+				   pnpacpi_allocated_resource, dev);
 }
 
 static __init void pnpacpi_parse_dma_option(struct pnp_option *option,
@@ -713,9 +718,9 @@
 	return AE_OK;
 }
 
-acpi_status __init pnpacpi_parse_resource_option_data(acpi_handle handle,
-						      struct pnp_dev *dev)
+acpi_status __init pnpacpi_parse_resource_option_data(struct pnp_dev *dev)
 {
+	acpi_handle handle = dev->data;
 	acpi_status status;
 	struct acpipnp_parse_option_s parse_data;
 
@@ -945,9 +950,9 @@
 	fixed_memory32->address_length = p->end - p->start + 1;
 }
 
-int pnpacpi_encode_resources(struct pnp_resource_table *res_table,
-			     struct acpi_buffer *buffer)
+int pnpacpi_encode_resources(struct pnp_dev *dev, struct acpi_buffer *buffer)
 {
+	struct pnp_resource_table *res_table = &dev->res;
 	int i = 0;
 	/* pnpacpi_build_resource_template allocates extra mem */
 	int res_cnt = (buffer->length - 1) / sizeof(struct acpi_resource) - 1;
Index: work7/drivers/pnp/pnpbios/core.c
===================================================================
--- work7.orig/drivers/pnp/pnpbios/core.c	2008-03-25 14:48:39.000000000 -0600
+++ work7/drivers/pnp/pnpbios/core.c	2008-03-25 14:48:44.000000000 -0600
@@ -219,7 +219,7 @@
 		kfree(node);
 		return -ENODEV;
 	}
-	pnpbios_read_resources_from_node(&dev->res, node);
+	pnpbios_read_resources_from_node(dev, node);
 	dev->active = pnp_is_active(dev);
 	kfree(node);
 	return 0;
@@ -241,7 +241,7 @@
 		kfree(node);
 		return -ENODEV;
 	}
-	if (pnpbios_write_resources_to_node(&dev->res, node) < 0) {
+	if (pnpbios_write_resources_to_node(dev, node) < 0) {
 		kfree(node);
 		return -1;
 	}
Index: work7/drivers/pnp/pnpbios/pnpbios.h
===================================================================
--- work7.orig/drivers/pnp/pnpbios/pnpbios.h	2008-03-25 14:48:21.000000000 -0600
+++ work7/drivers/pnp/pnpbios/pnpbios.h	2008-03-25 14:48:44.000000000 -0600
@@ -28,8 +28,8 @@
 extern int  pnpbios_dont_use_current_config;
 
 extern int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node);
-extern int pnpbios_read_resources_from_node(struct pnp_resource_table *res, struct pnp_bios_node * node);
-extern int pnpbios_write_resources_to_node(struct pnp_resource_table *res, struct pnp_bios_node * node);
+extern int pnpbios_read_resources_from_node(struct pnp_dev *dev, struct pnp_bios_node *node);
+extern int pnpbios_write_resources_to_node(struct pnp_dev *dev, struct pnp_bios_node *node);
 extern void pnpid32_to_pnpid(u32 id, char *str);
 
 extern void pnpbios_print_status(const char * module, u16 status);
Index: work7/drivers/pnp/pnpbios/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpbios/rsparser.c	2008-03-25 14:48:29.000000000 -0600
+++ work7/drivers/pnp/pnpbios/rsparser.c	2008-03-25 14:48:44.000000000 -0600
@@ -54,9 +54,9 @@
  * Allocated Resources
  */
 
-static void pnpbios_parse_allocated_irqresource(struct pnp_resource_table *res,
-						int irq)
+static void pnpbios_parse_allocated_irqresource(struct pnp_dev *dev, int irq)
 {
+	struct pnp_resource_table *res = &dev->res;
 	int i = 0;
 
 	while (!(res->irq_resource[i].flags & IORESOURCE_UNSET)
@@ -74,9 +74,9 @@
 	}
 }
 
-static void pnpbios_parse_allocated_dmaresource(struct pnp_resource_table *res,
-						int dma)
+static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma)
 {
+	struct pnp_resource_table *res = &dev->res;
 	int i = 0;
 
 	while (i < PNP_MAX_DMA &&
@@ -93,9 +93,10 @@
 	}
 }
 
-static void pnpbios_parse_allocated_ioresource(struct pnp_resource_table *res,
+static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev,
 					       int io, int len)
 {
+	struct pnp_resource_table *res = &dev->res;
 	int i = 0;
 
 	while (!(res->port_resource[i].flags & IORESOURCE_UNSET)
@@ -112,9 +113,10 @@
 	}
 }
 
-static void pnpbios_parse_allocated_memresource(struct pnp_resource_table *res,
+static void pnpbios_parse_allocated_memresource(struct pnp_dev *dev,
 						int mem, int len)
 {
+	struct pnp_resource_table *res = &dev->res;
 	int i = 0;
 
 	while (!(res->mem_resource[i].flags & IORESOURCE_UNSET)
@@ -131,11 +133,9 @@
 	}
 }
 
-static unsigned char *pnpbios_parse_allocated_resource_data(unsigned char *p,
-							    unsigned char *end,
-							    struct
-							    pnp_resource_table
-							    *res)
+static unsigned char *pnpbios_parse_allocated_resource_data(struct pnp_dev *dev,
+							    unsigned char *p,
+							    unsigned char *end)
 {
 	unsigned int len, tag;
 	int io, size, mask, i;
@@ -144,7 +144,7 @@
 		return NULL;
 
 	/* Blank the resource table values */
-	pnp_init_resource_table(res);
+	pnp_init_resource_table(&dev->res);
 
 	while ((char *)p < (char *)end) {
 
@@ -164,7 +164,7 @@
 				goto len_err;
 			io = *(short *)&p[4];
 			size = *(short *)&p[10];
-			pnpbios_parse_allocated_memresource(res, io, size);
+			pnpbios_parse_allocated_memresource(dev, io, size);
 			break;
 
 		case LARGE_TAG_ANSISTR:
@@ -180,7 +180,7 @@
 				goto len_err;
 			io = *(int *)&p[4];
 			size = *(int *)&p[16];
-			pnpbios_parse_allocated_memresource(res, io, size);
+			pnpbios_parse_allocated_memresource(dev, io, size);
 			break;
 
 		case LARGE_TAG_FIXEDMEM32:
@@ -188,7 +188,7 @@
 				goto len_err;
 			io = *(int *)&p[4];
 			size = *(int *)&p[8];
-			pnpbios_parse_allocated_memresource(res, io, size);
+			pnpbios_parse_allocated_memresource(dev, io, size);
 			break;
 
 		case SMALL_TAG_IRQ:
@@ -199,7 +199,7 @@
 			for (i = 0; i < 16; i++, mask = mask >> 1)
 				if (mask & 0x01)
 					io = i;
-			pnpbios_parse_allocated_irqresource(res, io);
+			pnpbios_parse_allocated_irqresource(dev, io);
 			break;
 
 		case SMALL_TAG_DMA:
@@ -210,7 +210,7 @@
 			for (i = 0; i < 8; i++, mask = mask >> 1)
 				if (mask & 0x01)
 					io = i;
-			pnpbios_parse_allocated_dmaresource(res, io);
+			pnpbios_parse_allocated_dmaresource(dev, io);
 			break;
 
 		case SMALL_TAG_PORT:
@@ -218,7 +218,7 @@
 				goto len_err;
 			io = p[2] + p[3] * 256;
 			size = p[7];
-			pnpbios_parse_allocated_ioresource(res, io, size);
+			pnpbios_parse_allocated_ioresource(dev, io, size);
 			break;
 
 		case SMALL_TAG_VENDOR:
@@ -230,7 +230,7 @@
 				goto len_err;
 			io = p[1] + p[2] * 256;
 			size = p[3];
-			pnpbios_parse_allocated_ioresource(res, io, size);
+			pnpbios_parse_allocated_ioresource(dev, io, size);
 			break;
 
 		case SMALL_TAG_END:
@@ -672,12 +672,12 @@
 	p[3] = len & 0xff;
 }
 
-static unsigned char *pnpbios_encode_allocated_resource_data(unsigned char *p,
-							     unsigned char *end,
-							     struct
-							     pnp_resource_table
-							     *res)
+static unsigned char *pnpbios_encode_allocated_resource_data(struct pnp_dev
+								*dev,
+							     unsigned char *p,
+							     unsigned char *end)
 {
+	struct pnp_resource_table *res = &dev->res;
 	unsigned int len, tag;
 	int port = 0, irq = 0, dma = 0, mem = 0;
 
@@ -786,7 +786,7 @@
 	unsigned char *p = (char *)node->data;
 	unsigned char *end = (char *)(node->data + node->size);
 
-	p = pnpbios_parse_allocated_resource_data(p, end, &dev->res);
+	p = pnpbios_parse_allocated_resource_data(dev, p, end);
 	if (!p)
 		return -EIO;
 	p = pnpbios_parse_resource_option_data(p, end, dev);
@@ -798,25 +798,25 @@
 	return 0;
 }
 
-int pnpbios_read_resources_from_node(struct pnp_resource_table *res,
+int pnpbios_read_resources_from_node(struct pnp_dev *dev,
 				     struct pnp_bios_node *node)
 {
 	unsigned char *p = (char *)node->data;
 	unsigned char *end = (char *)(node->data + node->size);
 
-	p = pnpbios_parse_allocated_resource_data(p, end, res);
+	p = pnpbios_parse_allocated_resource_data(dev, p, end);
 	if (!p)
 		return -EIO;
 	return 0;
 }
 
-int pnpbios_write_resources_to_node(struct pnp_resource_table *res,
+int pnpbios_write_resources_to_node(struct pnp_dev *dev,
 				    struct pnp_bios_node *node)
 {
 	unsigned char *p = (char *)node->data;
 	unsigned char *end = (char *)(node->data + node->size);
 
-	p = pnpbios_encode_allocated_resource_data(p, end, res);
+	p = pnpbios_encode_allocated_resource_data(dev, p, end);
 	if (!p)
 		return -EIO;
 	return 0;

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 18/37] PNP: add pnp_init_resources(struct pnp_dev *) interface
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (16 preceding siblings ...)
  2008-03-26 17:11 ` [patch 17/37] PNP: remove more pnp_resource_table arguments Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 19/37] PNP: remove pnp_resource_table from internal pnp_clean_resource_table interface Bjorn Helgaas
                   ` (19 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-remove-pnp_resource_table-from-init --]
[-- Type: text/plain, Size: 6115 bytes --]

Add pnp_init_resources(struct pnp_dev *), which will replace
pnp_init_resource_table(), which takes a pointer to the
pnp_resource_table itself.  Passing only the pnp_dev * reduces
the possibility for error in the caller and removes the
pnp_resource_table implementation detail from the interface.

Even though pnp_init_resource_table() is exported, I did not
export pnp_init_resources() because it is used only by the PNP
core.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

---
 drivers/pnp/interface.c        |    6 +++---
 drivers/pnp/isapnp/core.c      |    4 ++--
 drivers/pnp/manager.c          |    5 +++++
 drivers/pnp/pnpacpi/core.c     |    2 +-
 drivers/pnp/pnpacpi/rsparser.c |    3 +--
 drivers/pnp/pnpbios/core.c     |    2 +-
 drivers/pnp/pnpbios/rsparser.c |    3 +--
 include/linux/pnp.h            |    2 ++
 8 files changed, 16 insertions(+), 11 deletions(-)

Index: work7/include/linux/pnp.h
===================================================================
--- work7.orig/include/linux/pnp.h	2008-03-25 14:48:39.000000000 -0600
+++ work7/include/linux/pnp.h	2008-03-25 14:48:47.000000000 -0600
@@ -388,6 +388,7 @@
 			       struct pnp_port *data);
 int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data);
 void pnp_init_resource_table(struct pnp_resource_table *table);
+void pnp_init_resources(struct pnp_dev *dev);
 int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res,
 			  int mode);
 int pnp_auto_config_dev(struct pnp_dev *dev);
@@ -435,6 +436,7 @@
 static inline int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data) { return -ENODEV; }
 static inline int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data) { return -ENODEV; }
 static inline void pnp_init_resource_table(struct pnp_resource_table *table) { }
+static inline void pnp_init_resources(struct pnp_dev *dev) { }
 static inline int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res, int mode) { return -ENODEV; }
 static inline int pnp_auto_config_dev(struct pnp_dev *dev) { return -ENODEV; }
 static inline int pnp_validate_config(struct pnp_dev *dev) { return -ENODEV; }
Index: work7/drivers/pnp/manager.c
===================================================================
--- work7.orig/drivers/pnp/manager.c	2008-03-25 14:48:39.000000000 -0600
+++ work7/drivers/pnp/manager.c	2008-03-25 14:48:47.000000000 -0600
@@ -238,6 +238,11 @@
 	}
 }
 
+void pnp_init_resources(struct pnp_dev *dev)
+{
+	pnp_init_resource_table(&dev->res);
+}
+
 /**
  * pnp_clean_resources - clears resources that were not manually set
  * @res: the resources to clean
Index: work7/drivers/pnp/interface.c
===================================================================
--- work7.orig/drivers/pnp/interface.c	2008-03-25 14:48:39.000000000 -0600
+++ work7/drivers/pnp/interface.c	2008-03-25 14:48:47.000000000 -0600
@@ -351,14 +351,14 @@
 	if (!strnicmp(buf, "auto", 4)) {
 		if (dev->active)
 			goto done;
-		pnp_init_resource_table(&dev->res);
+		pnp_init_resources(dev);
 		retval = pnp_auto_config_dev(dev);
 		goto done;
 	}
 	if (!strnicmp(buf, "clear", 5)) {
 		if (dev->active)
 			goto done;
-		pnp_init_resource_table(&dev->res);
+		pnp_init_resources(dev);
 		goto done;
 	}
 	if (!strnicmp(buf, "get", 3)) {
@@ -373,7 +373,7 @@
 		if (dev->active)
 			goto done;
 		buf += 3;
-		pnp_init_resource_table(&dev->res);
+		pnp_init_resources(dev);
 		mutex_lock(&pnp_res_mutex);
 		while (1) {
 			while (isspace(*buf))
Index: work7/drivers/pnp/isapnp/core.c
===================================================================
--- work7.orig/drivers/pnp/isapnp/core.c	2008-03-25 14:48:44.000000000 -0600
+++ work7/drivers/pnp/isapnp/core.c	2008-03-25 14:48:47.000000000 -0600
@@ -438,7 +438,7 @@
 	dev->capabilities |= PNP_READ;
 	dev->capabilities |= PNP_WRITE;
 	dev->capabilities |= PNP_DISABLE;
-	pnp_init_resource_table(&dev->res);
+	pnp_init_resources(dev);
 	return dev;
 }
 
@@ -982,7 +982,7 @@
 {
 	int ret;
 
-	pnp_init_resource_table(&dev->res);
+	pnp_init_resources(dev);
 	isapnp_cfg_begin(dev->card->number, dev->number);
 	ret = isapnp_read_resources(dev);
 	isapnp_cfg_end();
Index: work7/drivers/pnp/pnpacpi/core.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/core.c	2008-03-25 14:48:44.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/core.c	2008-03-25 14:48:47.000000000 -0600
@@ -210,7 +210,7 @@
 
 	/* clear out the damaged flags */
 	if (!dev->active)
-		pnp_init_resource_table(&dev->res);
+		pnp_init_resources(dev);
 	pnp_add_device(dev);
 	num++;
 
Index: work7/drivers/pnp/pnpbios/core.c
===================================================================
--- work7.orig/drivers/pnp/pnpbios/core.c	2008-03-25 14:48:44.000000000 -0600
+++ work7/drivers/pnp/pnpbios/core.c	2008-03-25 14:48:47.000000000 -0600
@@ -346,7 +346,7 @@
 
 	/* clear out the damaged flags */
 	if (!dev->active)
-		pnp_init_resource_table(&dev->res);
+		pnp_init_resources(dev);
 
 	pnp_add_device(dev);
 	pnpbios_interface_attach_device(node);
Index: work7/drivers/pnp/pnpacpi/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/rsparser.c	2008-03-25 14:48:44.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/rsparser.c	2008-03-25 14:48:47.000000000 -0600
@@ -406,8 +406,7 @@
 {
 	acpi_handle handle = dev->data;
 
-	/* Blank the resource table values */
-	pnp_init_resource_table(&dev->res);
+	pnp_init_resources(dev);
 
 	return acpi_walk_resources(handle, METHOD_NAME__CRS,
 				   pnpacpi_allocated_resource, dev);
Index: work7/drivers/pnp/pnpbios/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpbios/rsparser.c	2008-03-25 14:48:44.000000000 -0600
+++ work7/drivers/pnp/pnpbios/rsparser.c	2008-03-25 14:48:47.000000000 -0600
@@ -143,8 +143,7 @@
 	if (!p)
 		return NULL;
 
-	/* Blank the resource table values */
-	pnp_init_resource_table(&dev->res);
+	pnp_init_resources(dev);
 
 	while ((char *)p < (char *)end) {
 

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 19/37] PNP: remove pnp_resource_table from internal pnp_clean_resource_table interface
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (17 preceding siblings ...)
  2008-03-26 17:11 ` [patch 18/37] PNP: add pnp_init_resources(struct pnp_dev *) interface Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 20/37] PNP: make generic pnp_add_irq_resource() Bjorn Helgaas
                   ` (18 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-remove-pnp_resource_table-from-clean --]
[-- Type: text/plain, Size: 1538 bytes --]

This changes pnp_clean_resource_table() to take a pnp_dev pointer
rather than a pnp_resource_table pointer.  This reduces the visibility
of pnp_resource_table and removes an opportunity for error in the
caller.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/pnp/manager.c
===================================================================
--- work7.orig/drivers/pnp/manager.c	2008-03-25 11:03:59.000000000 -0600
+++ work7/drivers/pnp/manager.c	2008-03-25 11:04:52.000000000 -0600
@@ -247,8 +247,9 @@
  * pnp_clean_resources - clears resources that were not manually set
  * @res: the resources to clean
  */
-static void pnp_clean_resource_table(struct pnp_resource_table *res)
+static void pnp_clean_resource_table(struct pnp_dev *dev)
 {
+	struct pnp_resource_table *res = &dev->res;
 	int idx;
 
 	for (idx = 0; idx < PNP_MAX_IRQ; idx++) {
@@ -304,7 +305,7 @@
 		return -ENODEV;
 
 	mutex_lock(&pnp_res_mutex);
-	pnp_clean_resource_table(&dev->res);	/* start with a fresh slate */
+	pnp_clean_resource_table(dev);
 	if (dev->independent) {
 		port = dev->independent->port;
 		mem = dev->independent->mem;
@@ -376,7 +377,7 @@
 	return 1;
 
 fail:
-	pnp_clean_resource_table(&dev->res);
+	pnp_clean_resource_table(dev);
 	mutex_unlock(&pnp_res_mutex);
 	return 0;
 }
@@ -554,7 +555,7 @@
 
 	/* release the resources so that other devices can use them */
 	mutex_lock(&pnp_res_mutex);
-	pnp_clean_resource_table(&dev->res);
+	pnp_clean_resource_table(dev);
 	mutex_unlock(&pnp_res_mutex);
 
 	return 0;

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 20/37] PNP: make generic pnp_add_irq_resource()
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (18 preceding siblings ...)
  2008-03-26 17:11 ` [patch 19/37] PNP: remove pnp_resource_table from internal pnp_clean_resource_table interface Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 21/37] PNP: make generic pnp_add_dma_resource() Bjorn Helgaas
                   ` (17 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-common-add-irq-resource --]
[-- Type: text/plain, Size: 6813 bytes --]

Add a pnp_add_irq_resource() that can be used by all the PNP
backends.  This consolidates a little more pnp_resource_table
knowledge into one place.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

---
 drivers/pnp/base.h             |    2 ++
 drivers/pnp/interface.c        |   14 ++++----------
 drivers/pnp/isapnp/core.c      |    4 +---
 drivers/pnp/pnpacpi/rsparser.c |   28 +++++-----------------------
 drivers/pnp/pnpbios/rsparser.c |   23 ++---------------------
 drivers/pnp/resource.c         |   26 ++++++++++++++++++++++++++
 6 files changed, 40 insertions(+), 57 deletions(-)

Index: work7/drivers/pnp/base.h
===================================================================
--- work7.orig/drivers/pnp/base.h	2008-03-25 14:48:35.000000000 -0600
+++ work7/drivers/pnp/base.h	2008-03-25 14:48:51.000000000 -0600
@@ -14,3 +14,5 @@
 int pnp_check_mem(struct pnp_dev * dev, int idx);
 int pnp_check_irq(struct pnp_dev * dev, int idx);
 int pnp_check_dma(struct pnp_dev * dev, int idx);
+
+int pnp_add_irq_resource(struct pnp_dev *dev, int irq, int flags);
Index: work7/drivers/pnp/resource.c
===================================================================
--- work7.orig/drivers/pnp/resource.c	2008-03-25 14:48:20.000000000 -0600
+++ work7/drivers/pnp/resource.c	2008-03-25 14:48:51.000000000 -0600
@@ -461,6 +461,32 @@
 #endif
 }
 
+#define set(flags)	((flags & IORESOURCE_UNSET) == 0)
+
+int pnp_add_irq_resource(struct pnp_dev *dev, int irq, int flags)
+{
+	struct pnp_resource_table *res = &dev->res;
+	int i = 0;
+	static unsigned char warned;
+
+	while (set(res->irq_resource[i].flags) && i < PNP_MAX_IRQ)
+		i++;
+	if (i >= PNP_MAX_IRQ && !warned) {
+		dev_err(&dev->dev, "too many IRQs (max %d)\n", PNP_MAX_IRQ);
+		warned = 1;
+		return -ENOSPC;
+	}
+
+	res->irq_resource[i].flags = IORESOURCE_IRQ | flags;
+	if (irq < 0) {
+		res->irq_resource[i].flags |= IORESOURCE_DISABLED;
+		return -EINVAL;
+	}
+	res->irq_resource[i].start = irq;
+	res->irq_resource[i].end = irq;
+	return 0;
+}
+
 /* format is: pnp_reserve_irq=irq1[,irq2] .... */
 static int __init pnp_setup_reserve_irq(char *str)
 {
Index: work7/drivers/pnp/isapnp/core.c
===================================================================
--- work7.orig/drivers/pnp/isapnp/core.c	2008-03-25 14:48:47.000000000 -0600
+++ work7/drivers/pnp/isapnp/core.c	2008-03-25 14:48:51.000000000 -0600
@@ -962,9 +962,7 @@
 			     8);
 			if (!ret)
 				continue;
-			res->irq_resource[tmp].start =
-			    res->irq_resource[tmp].end = ret;
-			res->irq_resource[tmp].flags = IORESOURCE_IRQ;
+			pnp_add_irq_resource(dev, ret, 0);
 		}
 		for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) {
 			ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp);
Index: work7/drivers/pnp/pnpacpi/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/rsparser.c	2008-03-25 14:48:47.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/rsparser.c	2008-03-25 14:48:51.000000000 -0600
@@ -22,6 +22,7 @@
 #include <linux/acpi.h>
 #include <linux/pci.h>
 #include "pnpacpi.h"
+#include "../base.h"
 
 #ifdef CONFIG_IA64
 #define valid_IRQ(i) (1)
@@ -80,24 +81,12 @@
 						u32 gsi, int triggering,
 						int polarity, int shareable)
 {
-	struct pnp_resource_table *res = &dev->res;
-	int i = 0;
-	int irq;
+	int irq, flags;
 	int p, t;
-	static unsigned char warned;
 
 	if (!valid_IRQ(gsi))
 		return;
 
-	while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) &&
-	       i < PNP_MAX_IRQ)
-		i++;
-	if (i >= PNP_MAX_IRQ && !warned) {
-		printk(KERN_ERR "pnpacpi: exceeded the max number of IRQ "
-				"resources: %d \n", PNP_MAX_IRQ);
-		warned = 1;
-		return;
-	}
 	/*
 	 * in IO-APIC mode, use overrided attribute. Two reasons:
 	 * 1. BIOS bug in DSDT
@@ -114,18 +103,11 @@
 			polarity = p;
 		}
 	}
+	flags = irq_flags(triggering, polarity, shareable);
 
-	res->irq_resource[i].flags = IORESOURCE_IRQ;	// Also clears _UNSET flag
-	res->irq_resource[i].flags |= irq_flags(triggering, polarity, shareable);
 	irq = acpi_register_gsi(gsi, triggering, polarity);
-	if (irq < 0) {
-		res->irq_resource[i].flags |= IORESOURCE_DISABLED;
-		return;
-	}
-
-	res->irq_resource[i].start = irq;
-	res->irq_resource[i].end = irq;
-	pcibios_penalize_isa_irq(irq, 1);
+	if (pnp_add_irq_resource(dev, irq, flags) == 0)
+		pcibios_penalize_isa_irq(irq, 1);
 }
 
 static int dma_flags(int type, int bus_master, int transfer)
Index: work7/drivers/pnp/pnpbios/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpbios/rsparser.c	2008-03-25 14:48:47.000000000 -0600
+++ work7/drivers/pnp/pnpbios/rsparser.c	2008-03-25 14:48:51.000000000 -0600
@@ -54,26 +54,6 @@
  * Allocated Resources
  */
 
-static void pnpbios_parse_allocated_irqresource(struct pnp_dev *dev, int irq)
-{
-	struct pnp_resource_table *res = &dev->res;
-	int i = 0;
-
-	while (!(res->irq_resource[i].flags & IORESOURCE_UNSET)
-	       && i < PNP_MAX_IRQ)
-		i++;
-	if (i < PNP_MAX_IRQ) {
-		res->irq_resource[i].flags = IORESOURCE_IRQ;	// Also clears _UNSET flag
-		if (irq == -1) {
-			res->irq_resource[i].flags |= IORESOURCE_DISABLED;
-			return;
-		}
-		res->irq_resource[i].start =
-		    res->irq_resource[i].end = (unsigned long)irq;
-		pcibios_penalize_isa_irq(irq, 1);
-	}
-}
-
 static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma)
 {
 	struct pnp_resource_table *res = &dev->res;
@@ -198,7 +178,8 @@
 			for (i = 0; i < 16; i++, mask = mask >> 1)
 				if (mask & 0x01)
 					io = i;
-			pnpbios_parse_allocated_irqresource(dev, io);
+			if (pnp_add_irq_resource(dev, io, 0) == 0)
+				pcibios_penalize_isa_irq(io, 1);
 			break;
 
 		case SMALL_TAG_DMA:
Index: work7/drivers/pnp/interface.c
===================================================================
--- work7.orig/drivers/pnp/interface.c	2008-03-25 14:48:47.000000000 -0600
+++ work7/drivers/pnp/interface.c	2008-03-25 14:48:51.000000000 -0600
@@ -325,6 +325,7 @@
 	struct pnp_dev *dev = to_pnp_dev(dmdev);
 	char *buf = (void *)ubuf;
 	int retval = 0;
+	resource_size_t start;
 
 	if (dev->status & PNP_ATTACHED) {
 		retval = -EBUSY;
@@ -369,7 +370,7 @@
 		goto done;
 	}
 	if (!strnicmp(buf, "set", 3)) {
-		int nport = 0, nmem = 0, nirq = 0, ndma = 0;
+		int nport = 0, nmem = 0, ndma = 0;
 		if (dev->active)
 			goto done;
 		buf += 3;
@@ -430,14 +431,8 @@
 				buf += 3;
 				while (isspace(*buf))
 					++buf;
-				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;
+				start = simple_strtoul(buf, &buf, 0);
+				pnp_add_irq_resource(dev, start, 0);
 				continue;
 			}
 			if (!strnicmp(buf, "dma", 3)) {

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 21/37] PNP: make generic pnp_add_dma_resource()
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (19 preceding siblings ...)
  2008-03-26 17:11 ` [patch 20/37] PNP: make generic pnp_add_irq_resource() Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 22/37] PNP: make generic pnp_add_io_resource() Bjorn Helgaas
                   ` (16 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-common-add-dma-resource --]
[-- Type: text/plain, Size: 6185 bytes --]

Add a pnp_add_dma_resource() that can be used by all the PNP
backends.  This consolidates a little more pnp_resource_table
knowledge into one place.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

---
 drivers/pnp/base.h             |    1 +
 drivers/pnp/isapnp/core.c      |    4 +---
 drivers/pnp/pnpacpi/rsparser.c |   34 ++++------------------------------
 drivers/pnp/pnpbios/rsparser.c |   21 +--------------------
 drivers/pnp/resource.c         |   24 ++++++++++++++++++++++++
 5 files changed, 31 insertions(+), 53 deletions(-)

Index: work7/drivers/pnp/base.h
===================================================================
--- work7.orig/drivers/pnp/base.h	2008-03-25 14:48:51.000000000 -0600
+++ work7/drivers/pnp/base.h	2008-03-25 14:48:54.000000000 -0600
@@ -16,3 +16,4 @@
 int pnp_check_dma(struct pnp_dev * dev, int idx);
 
 int pnp_add_irq_resource(struct pnp_dev *dev, int irq, int flags);
+int pnp_add_dma_resource(struct pnp_dev *dev, int dma, int flags);
Index: work7/drivers/pnp/resource.c
===================================================================
--- work7.orig/drivers/pnp/resource.c	2008-03-25 14:48:51.000000000 -0600
+++ work7/drivers/pnp/resource.c	2008-03-25 14:48:54.000000000 -0600
@@ -487,6 +487,30 @@
 	return 0;
 }
 
+int pnp_add_dma_resource(struct pnp_dev *dev, int dma, int flags)
+{
+	struct pnp_resource_table *res = &dev->res;
+	int i = 0;
+	static unsigned char warned;
+
+	while (set(res->dma_resource[i].flags) && i < PNP_MAX_DMA)
+		i++;
+	if (i >= PNP_MAX_DMA && !warned) {
+		dev_err(&dev->dev, "too many DMAs (max %d)\n", PNP_MAX_DMA);
+		warned = 1;
+		return -ENOSPC;
+	}
+
+	res->dma_resource[i].flags = IORESOURCE_DMA | flags;
+	if (dma < 0) {
+		res->dma_resource[i].flags |= IORESOURCE_DISABLED;
+		return -EINVAL;
+	}
+	res->dma_resource[i].start = dma;
+	res->dma_resource[i].end = dma;
+	return 0;
+}
+
 /* format is: pnp_reserve_irq=irq1[,irq2] .... */
 static int __init pnp_setup_reserve_irq(char *str)
 {
Index: work7/drivers/pnp/isapnp/core.c
===================================================================
--- work7.orig/drivers/pnp/isapnp/core.c	2008-03-25 14:48:51.000000000 -0600
+++ work7/drivers/pnp/isapnp/core.c	2008-03-25 14:48:54.000000000 -0600
@@ -968,9 +968,7 @@
 			ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp);
 			if (ret == 4)
 				continue;
-			res->dma_resource[tmp].start =
-			    res->dma_resource[tmp].end = ret;
-			res->dma_resource[tmp].flags = IORESOURCE_DMA;
+			pnp_add_dma_resource(dev, ret, 0);
 		}
 	}
 	return 0;
Index: work7/drivers/pnp/pnpacpi/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/rsparser.c	2008-03-25 14:48:51.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/rsparser.c	2008-03-25 14:48:54.000000000 -0600
@@ -153,32 +153,6 @@
 	return flags;
 }
 
-static void pnpacpi_parse_allocated_dmaresource(struct pnp_dev *dev,
-						u32 dma, int flags)
-{
-	struct pnp_resource_table *res = &dev->res;
-	int i = 0;
-	static unsigned char warned;
-
-	while (i < PNP_MAX_DMA &&
-	       !(res->dma_resource[i].flags & IORESOURCE_UNSET))
-		i++;
-	if (i < PNP_MAX_DMA) {
-		res->dma_resource[i].flags = IORESOURCE_DMA;	// Also clears _UNSET flag
-		res->dma_resource[i].flags |= flags;
-		if (dma == -1) {
-			res->dma_resource[i].flags |= IORESOURCE_DISABLED;
-			return;
-		}
-		res->dma_resource[i].start = dma;
-		res->dma_resource[i].end = dma;
-	} else if (!warned) {
-		printk(KERN_ERR "pnpacpi: exceeded the max number of DMA "
-				"resources: %d \n", PNP_MAX_DMA);
-		warned = 1;
-	}
-}
-
 static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev,
 					       u64 io, u64 len, int io_decode)
 {
@@ -295,10 +269,10 @@
 	case ACPI_RESOURCE_TYPE_DMA:
 		dma = &res->data.dma;
 		if (dma->channel_count > 0)
-			pnpacpi_parse_allocated_dmaresource(dev,
-				dma->channels[0],
-				dma_flags(dma->type, dma->bus_master,
-					  dma->transfer));
+			pnp_add_dma_resource(dev, dma->channels[0],
+					     dma_flags(dma->type,
+						       dma->bus_master,
+						       dma->transfer));
 		break;
 
 	case ACPI_RESOURCE_TYPE_IO:
Index: work7/drivers/pnp/pnpbios/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpbios/rsparser.c	2008-03-25 14:48:51.000000000 -0600
+++ work7/drivers/pnp/pnpbios/rsparser.c	2008-03-25 14:48:54.000000000 -0600
@@ -54,25 +54,6 @@
  * Allocated Resources
  */
 
-static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma)
-{
-	struct pnp_resource_table *res = &dev->res;
-	int i = 0;
-
-	while (i < PNP_MAX_DMA &&
-	       !(res->dma_resource[i].flags & IORESOURCE_UNSET))
-		i++;
-	if (i < PNP_MAX_DMA) {
-		res->dma_resource[i].flags = IORESOURCE_DMA;	// Also clears _UNSET flag
-		if (dma == -1) {
-			res->dma_resource[i].flags |= IORESOURCE_DISABLED;
-			return;
-		}
-		res->dma_resource[i].start =
-		    res->dma_resource[i].end = (unsigned long)dma;
-	}
-}
-
 static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev,
 					       int io, int len)
 {
@@ -190,7 +171,7 @@
 			for (i = 0; i < 8; i++, mask = mask >> 1)
 				if (mask & 0x01)
 					io = i;
-			pnpbios_parse_allocated_dmaresource(dev, io);
+			pnp_add_dma_resource(dev, io, 0);
 			break;
 
 		case SMALL_TAG_PORT:
Index: work7/drivers/pnp/interface.c
===================================================================
--- work7.orig/drivers/pnp/interface.c	2008-03-25 14:48:51.000000000 -0600
+++ work7/drivers/pnp/interface.c	2008-03-25 14:48:54.000000000 -0600
@@ -370,7 +370,7 @@
 		goto done;
 	}
 	if (!strnicmp(buf, "set", 3)) {
-		int nport = 0, nmem = 0, ndma = 0;
+		int nport = 0, nmem = 0;
 		if (dev->active)
 			goto done;
 		buf += 3;
@@ -439,14 +439,8 @@
 				buf += 3;
 				while (isspace(*buf))
 					++buf;
-				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;
+				start = simple_strtoul(buf, &buf, 0);
+				pnp_add_dma_resource(dev, start, 0);
 				continue;
 			}
 			break;

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 22/37] PNP: make generic pnp_add_io_resource()
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (20 preceding siblings ...)
  2008-03-26 17:11 ` [patch 21/37] PNP: make generic pnp_add_dma_resource() Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 23/37] PNP: make generic pnp_add_mem_resource() Bjorn Helgaas
                   ` (15 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-common-add-io-resource --]
[-- Type: text/plain, Size: 8160 bytes --]

Add a pnp_add_io_resource() that can be used by all the PNP
backends.  This consolidates a little more pnp_resource_table
knowledge into one place.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

---
 drivers/pnp/base.h             |    1 
 drivers/pnp/interface.c        |   20 ++++++------------
 drivers/pnp/isapnp/core.c      |    3 --
 drivers/pnp/pnpacpi/rsparser.c |   45 ++++++-----------------------------------
 drivers/pnp/pnpbios/rsparser.c |   24 +--------------------
 drivers/pnp/resource.c         |   24 +++++++++++++++++++++
 6 files changed, 42 insertions(+), 75 deletions(-)

Index: work7/drivers/pnp/base.h
===================================================================
--- work7.orig/drivers/pnp/base.h	2008-03-25 14:48:54.000000000 -0600
+++ work7/drivers/pnp/base.h	2008-03-25 14:48:57.000000000 -0600
@@ -17,3 +17,4 @@
 
 int pnp_add_irq_resource(struct pnp_dev *dev, int irq, int flags);
 int pnp_add_dma_resource(struct pnp_dev *dev, int dma, int flags);
+int pnp_add_io_resource(struct pnp_dev *dev, resource_size_t start, resource_size_t len, int flags);
Index: work7/drivers/pnp/resource.c
===================================================================
--- work7.orig/drivers/pnp/resource.c	2008-03-25 14:48:54.000000000 -0600
+++ work7/drivers/pnp/resource.c	2008-03-25 14:48:57.000000000 -0600
@@ -511,6 +511,31 @@
 	return 0;
 }
 
+int pnp_add_io_resource(struct pnp_dev *dev, resource_size_t start, resource_size_t len, int flags)
+{
+	struct pnp_resource_table *res = &dev->res;
+	resource_size_t end = start + len - 1;
+	int i = 0;
+	static unsigned char warned;
+
+	while (set(res->port_resource[i].flags) && i < PNP_MAX_PORT)
+		i++;
+	if (i >= PNP_MAX_PORT && !warned) {
+		dev_err(&dev->dev, "too many PORTs (max %d)\n", PNP_MAX_PORT);
+		warned = 1;
+		return -ENOSPC;
+	}
+
+	res->port_resource[i].flags = IORESOURCE_IO | flags;
+	if (len <= 0 || end >= 0x10003) {
+		res->port_resource[i].flags |= IORESOURCE_DISABLED;
+		return -EINVAL;
+	}
+	res->port_resource[i].start = start;
+	res->port_resource[i].end = end;
+	return 0;
+}
+
 /* format is: pnp_reserve_irq=irq1[,irq2] .... */
 static int __init pnp_setup_reserve_irq(char *str)
 {
Index: work7/drivers/pnp/isapnp/core.c
===================================================================
--- work7.orig/drivers/pnp/isapnp/core.c	2008-03-25 14:48:54.000000000 -0600
+++ work7/drivers/pnp/isapnp/core.c	2008-03-25 14:48:57.000000000 -0600
@@ -945,8 +945,7 @@
 			ret = isapnp_read_word(ISAPNP_CFG_PORT + (tmp << 1));
 			if (!ret)
 				continue;
-			res->port_resource[tmp].start = ret;
-			res->port_resource[tmp].flags = IORESOURCE_IO;
+			pnp_add_io_resource(dev, ret, 1, 0);
 		}
 		for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) {
 			ret =
Index: work7/drivers/pnp/pnpacpi/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/rsparser.c	2008-03-25 14:48:54.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/rsparser.c	2008-03-25 14:48:57.000000000 -0600
@@ -153,33 +153,6 @@
 	return flags;
 }
 
-static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev,
-					       u64 io, u64 len, int io_decode)
-{
-	struct pnp_resource_table *res = &dev->res;
-	int i = 0;
-	static unsigned char warned;
-
-	while (!(res->port_resource[i].flags & IORESOURCE_UNSET) &&
-	       i < PNP_MAX_PORT)
-		i++;
-	if (i < PNP_MAX_PORT) {
-		res->port_resource[i].flags = IORESOURCE_IO;	// Also clears _UNSET flag
-		if (io_decode == ACPI_DECODE_16)
-			res->port_resource[i].flags |= PNP_PORT_FLAG_16BITADDR;
-		if (len <= 0 || (io + len - 1) >= 0x10003) {
-			res->port_resource[i].flags |= IORESOURCE_DISABLED;
-			return;
-		}
-		res->port_resource[i].start = io;
-		res->port_resource[i].end = io + len - 1;
-	} else if (!warned) {
-		printk(KERN_ERR "pnpacpi: exceeded the max number of IO "
-				"resources: %d \n", PNP_MAX_PORT);
-		warned = 1;
-	}
-}
-
 static void pnpacpi_parse_allocated_memresource(struct pnp_dev *dev,
 						u64 mem, u64 len,
 						int write_protect)
@@ -230,10 +203,8 @@
 			p->minimum, p->address_length,
 			p->info.mem.write_protect);
 	else if (p->resource_type == ACPI_IO_RANGE)
-		pnpacpi_parse_allocated_ioresource(dev,
-			p->minimum, p->address_length,
-			p->granularity == 0xfff ? ACPI_DECODE_10 :
-				ACPI_DECODE_16);
+		pnp_add_io_resource(dev, p->minimum, p->address_length,
+			p->granularity == 0xfff ? 0 : PNP_PORT_FLAG_16BITADDR);
 }
 
 static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
@@ -277,10 +248,9 @@
 
 	case ACPI_RESOURCE_TYPE_IO:
 		io = &res->data.io;
-		pnpacpi_parse_allocated_ioresource(dev,
-			io->minimum,
-			io->address_length,
-			io->io_decode);
+		pnp_add_io_resource(dev, io->minimum, io->address_length,
+			io->io_decode == ACPI_DECODE_16 ?
+			    PNP_PORT_FLAG_16BITADDR : 0);
 		break;
 
 	case ACPI_RESOURCE_TYPE_START_DEPENDENT:
@@ -289,10 +259,9 @@
 
 	case ACPI_RESOURCE_TYPE_FIXED_IO:
 		fixed_io = &res->data.fixed_io;
-		pnpacpi_parse_allocated_ioresource(dev,
+		pnp_add_io_resource(dev,
 			fixed_io->address,
-			fixed_io->address_length,
-			ACPI_DECODE_10);
+			fixed_io->address_length, 0);
 		break;
 
 	case ACPI_RESOURCE_TYPE_VENDOR:
Index: work7/drivers/pnp/pnpbios/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpbios/rsparser.c	2008-03-25 14:48:54.000000000 -0600
+++ work7/drivers/pnp/pnpbios/rsparser.c	2008-03-25 14:48:57.000000000 -0600
@@ -54,26 +54,6 @@
  * Allocated Resources
  */
 
-static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev,
-					       int io, int len)
-{
-	struct pnp_resource_table *res = &dev->res;
-	int i = 0;
-
-	while (!(res->port_resource[i].flags & IORESOURCE_UNSET)
-	       && i < PNP_MAX_PORT)
-		i++;
-	if (i < PNP_MAX_PORT) {
-		res->port_resource[i].flags = IORESOURCE_IO;	// Also clears _UNSET flag
-		if (len <= 0 || (io + len - 1) >= 0x10003) {
-			res->port_resource[i].flags |= IORESOURCE_DISABLED;
-			return;
-		}
-		res->port_resource[i].start = (unsigned long)io;
-		res->port_resource[i].end = (unsigned long)(io + len - 1);
-	}
-}
-
 static void pnpbios_parse_allocated_memresource(struct pnp_dev *dev,
 						int mem, int len)
 {
@@ -179,7 +159,7 @@
 				goto len_err;
 			io = p[2] + p[3] * 256;
 			size = p[7];
-			pnpbios_parse_allocated_ioresource(dev, io, size);
+			pnp_add_io_resource(dev, io, size, 0);
 			break;
 
 		case SMALL_TAG_VENDOR:
@@ -191,7 +171,7 @@
 				goto len_err;
 			io = p[1] + p[2] * 256;
 			size = p[3];
-			pnpbios_parse_allocated_ioresource(dev, io, size);
+			pnp_add_io_resource(dev, io, size, 0);
 			break;
 
 		case SMALL_TAG_END:
Index: work7/drivers/pnp/interface.c
===================================================================
--- work7.orig/drivers/pnp/interface.c	2008-03-25 14:48:54.000000000 -0600
+++ work7/drivers/pnp/interface.c	2008-03-25 14:48:57.000000000 -0600
@@ -325,7 +325,7 @@
 	struct pnp_dev *dev = to_pnp_dev(dmdev);
 	char *buf = (void *)ubuf;
 	int retval = 0;
-	resource_size_t start;
+	resource_size_t start, end, length;
 
 	if (dev->status & PNP_ATTACHED) {
 		retval = -EBUSY;
@@ -370,7 +370,7 @@
 		goto done;
 	}
 	if (!strnicmp(buf, "set", 3)) {
-		int nport = 0, nmem = 0;
+		int nmem = 0;
 		if (dev->active)
 			goto done;
 		buf += 3;
@@ -383,24 +383,18 @@
 				buf += 2;
 				while (isspace(*buf))
 					++buf;
-				dev->res.port_resource[nport].start =
-				    simple_strtoul(buf, &buf, 0);
+				start = simple_strtoul(buf, &buf, 0);
 				while (isspace(*buf))
 					++buf;
 				if (*buf == '-') {
 					buf += 1;
 					while (isspace(*buf))
 						++buf;
-					dev->res.port_resource[nport].end =
-					    simple_strtoul(buf, &buf, 0);
+					end = simple_strtoul(buf, &buf, 0);
 				} else
-					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;
+					end = start;
+				length = end - start + 1;
+				pnp_add_io_resource(dev, start, length, 0);
 				continue;
 			}
 			if (!strnicmp(buf, "mem", 3)) {

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 23/37] PNP: make generic pnp_add_mem_resource()
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (21 preceding siblings ...)
  2008-03-26 17:11 ` [patch 22/37] PNP: make generic pnp_add_io_resource() Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 24/37] PNP: use dev_printk when possible Bjorn Helgaas
                   ` (14 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-common-add-mem-resource --]
[-- Type: text/plain, Size: 8851 bytes --]

Add a pnp_add_mem_resource() that can be used by all the PNP
backends.  This consolidates a little more pnp_resource_table
knowledge into one place.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

---
 drivers/pnp/base.h             |    1 
 drivers/pnp/interface.c        |   17 ++++---------
 drivers/pnp/isapnp/core.c      |    4 ---
 drivers/pnp/pnpacpi/rsparser.c |   50 +++++++++--------------------------------
 drivers/pnp/pnpbios/rsparser.c |   26 ++-------------------
 drivers/pnp/resource.c         |   24 +++++++++++++++++++
 6 files changed, 46 insertions(+), 76 deletions(-)

Index: work7/drivers/pnp/base.h
===================================================================
--- work7.orig/drivers/pnp/base.h	2008-03-25 14:48:57.000000000 -0600
+++ work7/drivers/pnp/base.h	2008-03-25 14:48:59.000000000 -0600
@@ -18,3 +18,4 @@
 int pnp_add_irq_resource(struct pnp_dev *dev, int irq, int flags);
 int pnp_add_dma_resource(struct pnp_dev *dev, int dma, int flags);
 int pnp_add_io_resource(struct pnp_dev *dev, resource_size_t start, resource_size_t len, int flags);
+int pnp_add_mem_resource(struct pnp_dev *dev, resource_size_t start, resource_size_t len, int flags);
Index: work7/drivers/pnp/resource.c
===================================================================
--- work7.orig/drivers/pnp/resource.c	2008-03-25 14:48:57.000000000 -0600
+++ work7/drivers/pnp/resource.c	2008-03-25 14:48:59.000000000 -0600
@@ -536,6 +536,30 @@
 	return 0;
 }
 
+int pnp_add_mem_resource(struct pnp_dev *dev, resource_size_t start, resource_size_t len, int flags)
+{
+	struct pnp_resource_table *res = &dev->res;
+	int i = 0;
+	static unsigned char warned;
+
+	while (set(res->mem_resource[i].flags) && i < PNP_MAX_MEM)
+		i++;
+	if (i >= PNP_MAX_MEM && !warned) {
+		dev_err(&dev->dev, "too many MEMs (max %d)\n", PNP_MAX_MEM);
+		warned = 1;
+		return -ENOSPC;
+	}
+
+	res->mem_resource[i].flags = IORESOURCE_MEM | flags;
+	if (len <= 0) {
+		res->mem_resource[i].flags |= IORESOURCE_DISABLED;
+		return -EINVAL;
+	}
+	res->mem_resource[i].start = start;
+	res->mem_resource[i].end = start + len - 1;
+	return 0;
+}
+
 /* format is: pnp_reserve_irq=irq1[,irq2] .... */
 static int __init pnp_setup_reserve_irq(char *str)
 {
Index: work7/drivers/pnp/isapnp/core.c
===================================================================
--- work7.orig/drivers/pnp/isapnp/core.c	2008-03-25 14:48:57.000000000 -0600
+++ work7/drivers/pnp/isapnp/core.c	2008-03-25 14:48:59.000000000 -0600
@@ -936,7 +936,6 @@
 
 static int isapnp_read_resources(struct pnp_dev *dev)
 {
-	struct pnp_resource_table *res = &dev->res;
 	int tmp, ret;
 
 	dev->active = isapnp_read_byte(ISAPNP_CFG_ACTIVATE);
@@ -952,8 +951,7 @@
 			    isapnp_read_word(ISAPNP_CFG_MEM + (tmp << 3)) << 8;
 			if (!ret)
 				continue;
-			res->mem_resource[tmp].start = ret;
-			res->mem_resource[tmp].flags = IORESOURCE_MEM;
+			pnp_add_mem_resource(dev, ret, 1, 0);
 		}
 		for (tmp = 0; tmp < ISAPNP_MAX_IRQ; tmp++) {
 			ret =
Index: work7/drivers/pnp/pnpacpi/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/rsparser.c	2008-03-25 14:48:57.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/rsparser.c	2008-03-25 14:48:59.000000000 -0600
@@ -153,35 +153,6 @@
 	return flags;
 }
 
-static void pnpacpi_parse_allocated_memresource(struct pnp_dev *dev,
-						u64 mem, u64 len,
-						int write_protect)
-{
-	struct pnp_resource_table *res = &dev->res;
-	int i = 0;
-	static unsigned char warned;
-
-	while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) &&
-	       (i < PNP_MAX_MEM))
-		i++;
-	if (i < PNP_MAX_MEM) {
-		res->mem_resource[i].flags = IORESOURCE_MEM;	// Also clears _UNSET flag
-		if (len <= 0) {
-			res->mem_resource[i].flags |= IORESOURCE_DISABLED;
-			return;
-		}
-		if (write_protect == ACPI_READ_WRITE_MEMORY)
-			res->mem_resource[i].flags |= IORESOURCE_MEM_WRITEABLE;
-
-		res->mem_resource[i].start = mem;
-		res->mem_resource[i].end = mem + len - 1;
-	} else if (!warned) {
-		printk(KERN_ERR "pnpacpi: exceeded the max number of mem "
-				"resources: %d\n", PNP_MAX_MEM);
-		warned = 1;
-	}
-}
-
 static void pnpacpi_parse_allocated_address_space(struct pnp_dev *dev,
 						  struct acpi_resource *res)
 {
@@ -199,9 +170,9 @@
 		return;
 
 	if (p->resource_type == ACPI_MEMORY_RANGE)
-		pnpacpi_parse_allocated_memresource(dev,
-			p->minimum, p->address_length,
-			p->info.mem.write_protect);
+		pnp_add_mem_resource(dev, p->minimum, p->address_length,
+			p->info.mem.write_protect == ACPI_READ_WRITE_MEMORY ?
+			    IORESOURCE_MEM_WRITEABLE : 0);
 	else if (p->resource_type == ACPI_IO_RANGE)
 		pnp_add_io_resource(dev, p->minimum, p->address_length,
 			p->granularity == 0xfff ? 0 : PNP_PORT_FLAG_16BITADDR);
@@ -272,24 +243,27 @@
 
 	case ACPI_RESOURCE_TYPE_MEMORY24:
 		memory24 = &res->data.memory24;
-		pnpacpi_parse_allocated_memresource(dev,
+		pnp_add_mem_resource(dev,
 			memory24->minimum,
 			memory24->address_length,
-			memory24->write_protect);
+			memory24->write_protect == ACPI_READ_WRITE_MEMORY ?
+			    IORESOURCE_MEM_WRITEABLE : 0);
 		break;
 	case ACPI_RESOURCE_TYPE_MEMORY32:
 		memory32 = &res->data.memory32;
-		pnpacpi_parse_allocated_memresource(dev,
+		pnp_add_mem_resource(dev,
 			memory32->minimum,
 			memory32->address_length,
-			memory32->write_protect);
+			memory32->write_protect == ACPI_READ_WRITE_MEMORY ?
+			    IORESOURCE_MEM_WRITEABLE : 0);
 		break;
 	case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
 		fixed_memory32 = &res->data.fixed_memory32;
-		pnpacpi_parse_allocated_memresource(dev,
+		pnp_add_mem_resource(dev,
 			fixed_memory32->address,
 			fixed_memory32->address_length,
-			fixed_memory32->write_protect);
+			fixed_memory32->write_protect == ACPI_READ_WRITE_MEMORY ?
+			    IORESOURCE_MEM_WRITEABLE : 0);
 		break;
 	case ACPI_RESOURCE_TYPE_ADDRESS16:
 	case ACPI_RESOURCE_TYPE_ADDRESS32:
Index: work7/drivers/pnp/pnpbios/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpbios/rsparser.c	2008-03-25 14:48:57.000000000 -0600
+++ work7/drivers/pnp/pnpbios/rsparser.c	2008-03-25 14:48:59.000000000 -0600
@@ -54,26 +54,6 @@
  * Allocated Resources
  */
 
-static void pnpbios_parse_allocated_memresource(struct pnp_dev *dev,
-						int mem, int len)
-{
-	struct pnp_resource_table *res = &dev->res;
-	int i = 0;
-
-	while (!(res->mem_resource[i].flags & IORESOURCE_UNSET)
-	       && i < PNP_MAX_MEM)
-		i++;
-	if (i < PNP_MAX_MEM) {
-		res->mem_resource[i].flags = IORESOURCE_MEM;	// Also clears _UNSET flag
-		if (len <= 0) {
-			res->mem_resource[i].flags |= IORESOURCE_DISABLED;
-			return;
-		}
-		res->mem_resource[i].start = (unsigned long)mem;
-		res->mem_resource[i].end = (unsigned long)(mem + len - 1);
-	}
-}
-
 static unsigned char *pnpbios_parse_allocated_resource_data(struct pnp_dev *dev,
 							    unsigned char *p,
 							    unsigned char *end)
@@ -104,7 +84,7 @@
 				goto len_err;
 			io = *(short *)&p[4];
 			size = *(short *)&p[10];
-			pnpbios_parse_allocated_memresource(dev, io, size);
+			pnp_add_mem_resource(dev, io, size, 0);
 			break;
 
 		case LARGE_TAG_ANSISTR:
@@ -120,7 +100,7 @@
 				goto len_err;
 			io = *(int *)&p[4];
 			size = *(int *)&p[16];
-			pnpbios_parse_allocated_memresource(dev, io, size);
+			pnp_add_mem_resource(dev, io, size, 0);
 			break;
 
 		case LARGE_TAG_FIXEDMEM32:
@@ -128,7 +108,7 @@
 				goto len_err;
 			io = *(int *)&p[4];
 			size = *(int *)&p[8];
-			pnpbios_parse_allocated_memresource(dev, io, size);
+			pnp_add_mem_resource(dev, io, size, 0);
 			break;
 
 		case SMALL_TAG_IRQ:
Index: work7/drivers/pnp/interface.c
===================================================================
--- work7.orig/drivers/pnp/interface.c	2008-03-25 14:48:57.000000000 -0600
+++ work7/drivers/pnp/interface.c	2008-03-25 14:48:59.000000000 -0600
@@ -370,7 +370,6 @@
 		goto done;
 	}
 	if (!strnicmp(buf, "set", 3)) {
-		int nmem = 0;
 		if (dev->active)
 			goto done;
 		buf += 3;
@@ -401,24 +400,18 @@
 				buf += 3;
 				while (isspace(*buf))
 					++buf;
-				dev->res.mem_resource[nmem].start =
-				    simple_strtoul(buf, &buf, 0);
+				start = simple_strtoul(buf, &buf, 0);
 				while (isspace(*buf))
 					++buf;
 				if (*buf == '-') {
 					buf += 1;
 					while (isspace(*buf))
 						++buf;
-					dev->res.mem_resource[nmem].end =
-					    simple_strtoul(buf, &buf, 0);
+					end = simple_strtoul(buf, &buf, 0);
 				} else
-					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;
+					end = start;
+				length = end - start + 1;
+				pnp_add_mem_resource(dev, start, length, 0);
 				continue;
 			}
 			if (!strnicmp(buf, "irq", 3)) {

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 24/37] PNP: use dev_printk when possible
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (22 preceding siblings ...)
  2008-03-26 17:11 ` [patch 23/37] PNP: make generic pnp_add_mem_resource() Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 25/37] PNPACPI: remove redundant warnings about _CRS/_PRS failures Bjorn Helgaas
                   ` (13 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-dev_printk --]
[-- Type: text/plain, Size: 8204 bytes --]

Use dev_printk() when possible for more informative error messages.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

---
 drivers/pnp/isapnp/core.c      |   38 ++++++++++++++++++--------------------
 drivers/pnp/pnpacpi/rsparser.c |   20 ++++++++++++--------
 drivers/pnp/pnpbios/rsparser.c |   36 ++++++++++++++----------------------
 3 files changed, 44 insertions(+), 50 deletions(-)

Index: work7/drivers/pnp/isapnp/core.c
===================================================================
--- work7.orig/drivers/pnp/isapnp/core.c	2008-03-26 10:00:00.000000000 -0600
+++ work7/drivers/pnp/isapnp/core.c	2008-03-26 10:04:57.000000000 -0600
@@ -741,9 +741,8 @@
 				isapnp_skip_bytes(size);
 			return 1;
 		default:
-			printk(KERN_ERR
-			       "isapnp: unexpected or unknown tag type 0x%x for logical device %i (device %i), ignored\n",
-			       type, dev->number, card->number);
+			dev_err(&dev->dev, "unknown tag 0x%x (card %i), "
+				"ignored\n", type, card->number);
 		}
 __skip:
 		if (size > 0)
@@ -796,9 +795,8 @@
 				isapnp_skip_bytes(size);
 			return;
 		default:
-			printk(KERN_ERR
-			       "isapnp: unexpected or unknown tag type 0x%x for device %i, ignored\n",
-			       type, card->number);
+			dev_err(&card->dev, "unknown tag 0x%x, ignored\n",
+			       type);
 		}
 __skip:
 		if (size > 0)
@@ -844,19 +842,20 @@
 		isapnp_wake(csn);
 		isapnp_peek(header, 9);
 		checksum = isapnp_checksum(header);
-#if 0
-		printk(KERN_DEBUG
-		       "vendor: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
-		       header[0], header[1], header[2], header[3], header[4],
-		       header[5], header[6], header[7], header[8]);
-		printk(KERN_DEBUG "checksum = 0x%x\n", checksum);
-#endif
 		isapnp_to_pnpid((header[1] << 8) | header[0],
 				(header[3] << 8) | header[2], id);
 		card = pnp_alloc_card(&isapnp_protocol, csn, id);
 		if (!card)
 			continue;
 
+#if 0
+		dev_info(&card->dev,
+		       "vendor: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
+		       header[0], header[1], header[2], header[3], header[4],
+		       header[5], header[6], header[7], header[8]);
+		dev_info(&card->dev, "checksum = 0x%x\n", checksum);
+#endif
+
 		INIT_LIST_HEAD(&card->devices);
 		card->serial =
 		    (header[7] << 24) | (header[6] << 16) | (header[5] << 8) |
@@ -864,9 +863,8 @@
 		isapnp_checksum_value = 0x00;
 		isapnp_parse_resource_map(card);
 		if (isapnp_checksum_value != 0x00)
-			printk(KERN_ERR
-			       "isapnp: checksum for device %i is not valid (0x%x)\n",
-			       csn, isapnp_checksum_value);
+			dev_err(&card->dev, "invalid checksum 0x%x\n",
+				isapnp_checksum_value);
 		card->checksum = isapnp_checksum_value;
 
 		pnp_add_card(card);
@@ -1117,13 +1115,13 @@
 	protocol_for_each_card(&isapnp_protocol, card) {
 		cards++;
 		if (isapnp_verbose) {
-			printk(KERN_INFO "isapnp: Card '%s'\n",
-			       card->name[0] ? card->name : "Unknown");
+			dev_info(&card->dev, "card '%s'\n",
+			       card->name[0] ? card->name : "unknown");
 			if (isapnp_verbose < 2)
 				continue;
 			card_for_each_dev(card, dev) {
-				printk(KERN_INFO "isapnp:   Device '%s'\n",
-				       dev->name[0] ? dev->name : "Unknown");
+				dev_info(&card->dev, "device '%s'\n",
+				       dev->name[0] ? dev->name : "unknown");
 			}
 		}
 	}
Index: work7/drivers/pnp/pnpacpi/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/rsparser.c	2008-03-26 10:00:00.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/rsparser.c	2008-03-26 10:01:25.000000000 -0600
@@ -97,7 +97,7 @@
 		p = p ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
 
 		if (triggering != t || polarity != p) {
-			pnp_warn("IRQ %d override to %s, %s",
+			dev_warn(&dev->dev, "IRQ %d override to %s, %s\n",
 				gsi, t ? "edge":"level", p ? "low":"high");
 			triggering = t;
 			polarity = p;
@@ -161,7 +161,7 @@
 
 	status = acpi_resource_to_address64(res, p);
 	if (!ACPI_SUCCESS(status)) {
-		pnp_warn("PnPACPI: failed to convert resource type %d",
+		dev_warn(&dev->dev, "failed to convert resource type %d\n",
 			 res->type);
 		return;
 	}
@@ -294,7 +294,8 @@
 		break;
 
 	default:
-		pnp_warn("PnPACPI: unknown resource type %d", res->type);
+		dev_warn(&dev->dev, "unknown resource type %d in _CRS\n",
+			 res->type);
 		return AE_ERROR;
 	}
 
@@ -560,7 +561,8 @@
 	case ACPI_RESOURCE_TYPE_END_DEPENDENT:
 		/*only one EndDependentFn is allowed */
 		if (!parse_data->option_independent) {
-			pnp_warn("PnPACPI: more than one EndDependentFn");
+			dev_warn(&dev->dev, "more than one EndDependentFn "
+				 "in _PRS\n");
 			return AE_ERROR;
 		}
 		parse_data->option = parse_data->option_independent;
@@ -609,7 +611,8 @@
 		break;
 
 	default:
-		pnp_warn("PnPACPI: unknown resource type %d", res->type);
+		dev_warn(&dev->dev, "unknown resource type %d in _PRS\n",
+			 res->type);
 		return AE_ERROR;
 	}
 
@@ -689,7 +692,7 @@
 	status = acpi_walk_resources(handle, METHOD_NAME__CRS,
 				     pnpacpi_count_resources, &res_cnt);
 	if (ACPI_FAILURE(status)) {
-		pnp_err("Evaluate _CRS failed");
+		dev_err(&dev->dev, "can't evaluate _CRS\n");
 		return -EINVAL;
 	}
 	if (!res_cnt)
@@ -704,7 +707,7 @@
 				     pnpacpi_type_resources, &resource);
 	if (ACPI_FAILURE(status)) {
 		kfree(buffer->pointer);
-		pnp_err("Evaluate _CRS failed");
+		dev_err(&dev->dev, "can't evaluate _CRS\n");
 		return -EINVAL;
 	}
 	/* resource will pointer the end resource now */
@@ -921,7 +924,8 @@
 		case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
 		case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
 		default:	/* other type */
-			pnp_warn("unknown resource type %d", resource->type);
+			dev_warn(&dev->dev, "can't encode unknown resource "
+				 "type %d\n", resource->type);
 			return -EINVAL;
 		}
 		resource++;
Index: work7/drivers/pnp/pnpbios/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpbios/rsparser.c	2008-03-26 10:00:00.000000000 -0600
+++ work7/drivers/pnp/pnpbios/rsparser.c	2008-03-26 10:01:31.000000000 -0600
@@ -161,9 +161,8 @@
 
 		default:	/* an unkown tag */
 len_err:
-			printk(KERN_ERR
-			       "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
-			       tag, len);
+			dev_err(&dev->dev, "unknown tag 0x%x length %d\n",
+				tag, len);
 			break;
 		}
 
@@ -174,8 +173,7 @@
 			p += len + 1;
 	}
 
-	printk(KERN_ERR
-	       "PnPBIOS: Resource structure does not contain an end tag.\n");
+	dev_err(&dev->dev, "no end tag in resource structure\n");
 
 	return NULL;
 }
@@ -382,8 +380,8 @@
 			if (len != 0)
 				goto len_err;
 			if (option_independent == option)
-				printk(KERN_WARNING
-				       "PnPBIOS: Missing SMALL_TAG_STARTDEP tag\n");
+				dev_warn(&dev->dev, "missing "
+					 "SMALL_TAG_STARTDEP tag\n");
 			option = option_independent;
 			break;
 
@@ -392,9 +390,8 @@
 
 		default:	/* an unkown tag */
 len_err:
-			printk(KERN_ERR
-			       "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
-			       tag, len);
+			dev_err(&dev->dev, "unknown tag 0x%x length %d\n",
+				tag, len);
 			break;
 		}
 
@@ -405,8 +402,7 @@
 			p += len + 1;
 	}
 
-	printk(KERN_ERR
-	       "PnPBIOS: Resource structure does not contain an end tag.\n");
+	dev_err(&dev->dev, "no end tag in resource structure\n");
 
 	return NULL;
 }
@@ -484,9 +480,8 @@
 
 		default:	/* an unkown tag */
 len_err:
-			printk(KERN_ERR
-			       "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
-			       tag, len);
+			dev_err(&dev->dev, "unknown tag 0x%x length %d\n",
+				tag, len);
 			break;
 		}
 
@@ -497,8 +492,7 @@
 			p += len + 1;
 	}
 
-	printk(KERN_ERR
-	       "PnPBIOS: Resource structure does not contain an end tag.\n");
+	dev_err(&dev->dev, "no end tag in resource structure\n");
 
 	return NULL;
 }
@@ -678,9 +672,8 @@
 
 		default:	/* an unkown tag */
 len_err:
-			printk(KERN_ERR
-			       "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
-			       tag, len);
+			dev_err(&dev->dev, "unknown tag 0x%x length %d\n",
+				tag, len);
 			break;
 		}
 
@@ -691,8 +684,7 @@
 			p += len + 1;
 	}
 
-	printk(KERN_ERR
-	       "PnPBIOS: Resource structure does not contain an end tag.\n");
+	dev_err(&dev->dev, "no end tag in resource structure\n");
 
 	return NULL;
 }

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 25/37] PNPACPI: remove redundant warnings about _CRS/_PRS failures
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (23 preceding siblings ...)
  2008-03-26 17:11 ` [patch 24/37] PNP: use dev_printk when possible Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 26/37] PNPACPI: remove some pnp_dbg calls Bjorn Helgaas
                   ` (12 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnpacpi-remove-redundant-warnings --]
[-- Type: text/plain, Size: 1345 bytes --]

Any errors should already be reported inside
pnpacpi_parse_allocated_resource() and
pnpacpi_parse_resource_option_data(), so no
need to report them again.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/pnp/pnpacpi/core.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/core.c	2008-03-21 15:22:09.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/core.c	2008-03-21 15:22:51.000000000 -0600
@@ -180,22 +180,11 @@
 	else
 		strncpy(dev->name, acpi_device_bid(device), sizeof(dev->name));
 
-	if (dev->active) {
-		/* parse allocated resource */
-		status = pnpacpi_parse_allocated_resource(dev);
-		if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
-			pnp_err("PnPACPI: METHOD_NAME__CRS failure for %s",
-				acpi_device_hid(device));
-		}
-	}
+	if (dev->active)
+		pnpacpi_parse_allocated_resource(dev);
 
-	if (dev->capabilities & PNP_CONFIGURABLE) {
-		status = pnpacpi_parse_resource_option_data(dev);
-		if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
-			pnp_err("PnPACPI: METHOD_NAME__PRS failure for %s",
-				acpi_device_hid(device));
-		}
-	}
+	if (dev->capabilities & PNP_CONFIGURABLE)
+		pnpacpi_parse_resource_option_data(dev);
 
 	if (device->flags.compatible_ids) {
 		struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 26/37] PNPACPI: remove some pnp_dbg calls
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (24 preceding siblings ...)
  2008-03-26 17:11 ` [patch 25/37] PNPACPI: remove redundant warnings about _CRS/_PRS failures Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 27/37] PNP: use conventional "i" for loop indices Bjorn Helgaas
                   ` (11 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnpacpi-remove-debug-prints --]
[-- Type: text/plain, Size: 2351 bytes --]

These are turned off by default and don't print much useful information
anyway.  Anybody debugging this area will likely need to add his or her
own printks anyway.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/pnp/pnpacpi/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/rsparser.c	2008-03-25 10:14:46.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/rsparser.c	2008-03-25 10:14:50.000000000 -0600
@@ -701,7 +701,6 @@
 	buffer->pointer = kzalloc(buffer->length - 1, GFP_KERNEL);
 	if (!buffer->pointer)
 		return -ENOMEM;
-	pnp_dbg("Res cnt %d", res_cnt);
 	resource = (struct acpi_resource *)buffer->pointer;
 	status = acpi_walk_resources(handle, METHOD_NAME__CRS,
 				     pnpacpi_type_resources, &resource);
@@ -860,56 +859,47 @@
 	struct acpi_resource *resource = buffer->pointer;
 	int port = 0, irq = 0, dma = 0, mem = 0;
 
-	pnp_dbg("res cnt %d", res_cnt);
 	while (i < res_cnt) {
 		switch (resource->type) {
 		case ACPI_RESOURCE_TYPE_IRQ:
-			pnp_dbg("Encode irq");
 			pnpacpi_encode_irq(resource,
 					   &res_table->irq_resource[irq]);
 			irq++;
 			break;
 
 		case ACPI_RESOURCE_TYPE_DMA:
-			pnp_dbg("Encode dma");
 			pnpacpi_encode_dma(resource,
 					   &res_table->dma_resource[dma]);
 			dma++;
 			break;
 		case ACPI_RESOURCE_TYPE_IO:
-			pnp_dbg("Encode io");
 			pnpacpi_encode_io(resource,
 					  &res_table->port_resource[port]);
 			port++;
 			break;
 		case ACPI_RESOURCE_TYPE_FIXED_IO:
-			pnp_dbg("Encode fixed io");
 			pnpacpi_encode_fixed_io(resource,
 						&res_table->
 						port_resource[port]);
 			port++;
 			break;
 		case ACPI_RESOURCE_TYPE_MEMORY24:
-			pnp_dbg("Encode mem24");
 			pnpacpi_encode_mem24(resource,
 					     &res_table->mem_resource[mem]);
 			mem++;
 			break;
 		case ACPI_RESOURCE_TYPE_MEMORY32:
-			pnp_dbg("Encode mem32");
 			pnpacpi_encode_mem32(resource,
 					     &res_table->mem_resource[mem]);
 			mem++;
 			break;
 		case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
-			pnp_dbg("Encode fixed mem32");
 			pnpacpi_encode_fixed_mem32(resource,
 						   &res_table->
 						   mem_resource[mem]);
 			mem++;
 			break;
 		case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
-			pnp_dbg("Encode ext irq");
 			pnpacpi_encode_ext_irq(resource,
 					       &res_table->irq_resource[irq]);
 			irq++;

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 27/37] PNP: use conventional "i" for loop indices
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (25 preceding siblings ...)
  2008-03-26 17:11 ` [patch 26/37] PNPACPI: remove some pnp_dbg calls Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 28/37] PNP: add pnp_get_resource() interface Bjorn Helgaas
                   ` (10 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-rename-temps --]
[-- Type: text/plain, Size: 6590 bytes --]

Cosmetic only: just use "i" instead of "tmp".

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/pnp/resource.c
===================================================================
--- work7.orig/drivers/pnp/resource.c	2008-03-24 16:32:00.000000000 -0600
+++ work7/drivers/pnp/resource.c	2008-03-24 16:33:17.000000000 -0600
@@ -215,7 +215,7 @@
 
 int pnp_check_port(struct pnp_dev *dev, int idx)
 {
-	int tmp;
+	int i;
 	struct pnp_dev *tdev;
 	resource_size_t *port, *end, *tport, *tend;
 
@@ -234,18 +234,18 @@
 	}
 
 	/* check if the resource is reserved */
-	for (tmp = 0; tmp < 8; tmp++) {
-		int rport = pnp_reserve_io[tmp << 1];
-		int rend = pnp_reserve_io[(tmp << 1) + 1] + rport - 1;
+	for (i = 0; i < 8; i++) {
+		int rport = pnp_reserve_io[i << 1];
+		int rend = pnp_reserve_io[(i << 1) + 1] + rport - 1;
 		if (ranged_conflict(port, end, &rport, &rend))
 			return 0;
 	}
 
 	/* check for internal conflicts */
-	for (tmp = 0; tmp < PNP_MAX_PORT && tmp != idx; tmp++) {
-		if (dev->res.port_resource[tmp].flags & IORESOURCE_IO) {
-			tport = &dev->res.port_resource[tmp].start;
-			tend = &dev->res.port_resource[tmp].end;
+	for (i = 0; i < PNP_MAX_PORT && i != idx; i++) {
+		if (dev->res.port_resource[i].flags & IORESOURCE_IO) {
+			tport = &dev->res.port_resource[i].start;
+			tend = &dev->res.port_resource[i].end;
 			if (ranged_conflict(port, end, tport, tend))
 				return 0;
 		}
@@ -255,13 +255,13 @@
 	pnp_for_each_dev(tdev) {
 		if (tdev == dev)
 			continue;
-		for (tmp = 0; tmp < PNP_MAX_PORT; tmp++) {
-			if (tdev->res.port_resource[tmp].flags & IORESOURCE_IO) {
+		for (i = 0; i < PNP_MAX_PORT; i++) {
+			if (tdev->res.port_resource[i].flags & IORESOURCE_IO) {
 				if (cannot_compare
-				    (tdev->res.port_resource[tmp].flags))
+				    (tdev->res.port_resource[i].flags))
 					continue;
-				tport = &tdev->res.port_resource[tmp].start;
-				tend = &tdev->res.port_resource[tmp].end;
+				tport = &tdev->res.port_resource[i].start;
+				tend = &tdev->res.port_resource[i].end;
 				if (ranged_conflict(port, end, tport, tend))
 					return 0;
 			}
@@ -273,7 +273,7 @@
 
 int pnp_check_mem(struct pnp_dev *dev, int idx)
 {
-	int tmp;
+	int i;
 	struct pnp_dev *tdev;
 	resource_size_t *addr, *end, *taddr, *tend;
 
@@ -292,18 +292,18 @@
 	}
 
 	/* check if the resource is reserved */
-	for (tmp = 0; tmp < 8; tmp++) {
-		int raddr = pnp_reserve_mem[tmp << 1];
-		int rend = pnp_reserve_mem[(tmp << 1) + 1] + raddr - 1;
+	for (i = 0; i < 8; i++) {
+		int raddr = pnp_reserve_mem[i << 1];
+		int rend = pnp_reserve_mem[(i << 1) + 1] + raddr - 1;
 		if (ranged_conflict(addr, end, &raddr, &rend))
 			return 0;
 	}
 
 	/* check for internal conflicts */
-	for (tmp = 0; tmp < PNP_MAX_MEM && tmp != idx; tmp++) {
-		if (dev->res.mem_resource[tmp].flags & IORESOURCE_MEM) {
-			taddr = &dev->res.mem_resource[tmp].start;
-			tend = &dev->res.mem_resource[tmp].end;
+	for (i = 0; i < PNP_MAX_MEM && i != idx; i++) {
+		if (dev->res.mem_resource[i].flags & IORESOURCE_MEM) {
+			taddr = &dev->res.mem_resource[i].start;
+			tend = &dev->res.mem_resource[i].end;
 			if (ranged_conflict(addr, end, taddr, tend))
 				return 0;
 		}
@@ -313,13 +313,13 @@
 	pnp_for_each_dev(tdev) {
 		if (tdev == dev)
 			continue;
-		for (tmp = 0; tmp < PNP_MAX_MEM; tmp++) {
-			if (tdev->res.mem_resource[tmp].flags & IORESOURCE_MEM) {
+		for (i = 0; i < PNP_MAX_MEM; i++) {
+			if (tdev->res.mem_resource[i].flags & IORESOURCE_MEM) {
 				if (cannot_compare
-				    (tdev->res.mem_resource[tmp].flags))
+				    (tdev->res.mem_resource[i].flags))
 					continue;
-				taddr = &tdev->res.mem_resource[tmp].start;
-				tend = &tdev->res.mem_resource[tmp].end;
+				taddr = &tdev->res.mem_resource[i].start;
+				tend = &tdev->res.mem_resource[i].end;
 				if (ranged_conflict(addr, end, taddr, tend))
 					return 0;
 			}
@@ -336,7 +336,7 @@
 
 int pnp_check_irq(struct pnp_dev *dev, int idx)
 {
-	int tmp;
+	int i;
 	struct pnp_dev *tdev;
 	resource_size_t *irq = &dev->res.irq_resource[idx].start;
 
@@ -349,15 +349,15 @@
 		return 0;
 
 	/* check if the resource is reserved */
-	for (tmp = 0; tmp < 16; tmp++) {
-		if (pnp_reserve_irq[tmp] == *irq)
+	for (i = 0; i < 16; i++) {
+		if (pnp_reserve_irq[i] == *irq)
 			return 0;
 	}
 
 	/* check for internal conflicts */
-	for (tmp = 0; tmp < PNP_MAX_IRQ && tmp != idx; tmp++) {
-		if (dev->res.irq_resource[tmp].flags & IORESOURCE_IRQ) {
-			if (dev->res.irq_resource[tmp].start == *irq)
+	for (i = 0; i < PNP_MAX_IRQ && i != idx; i++) {
+		if (dev->res.irq_resource[i].flags & IORESOURCE_IRQ) {
+			if (dev->res.irq_resource[i].start == *irq)
 				return 0;
 		}
 	}
@@ -388,12 +388,12 @@
 	pnp_for_each_dev(tdev) {
 		if (tdev == dev)
 			continue;
-		for (tmp = 0; tmp < PNP_MAX_IRQ; tmp++) {
-			if (tdev->res.irq_resource[tmp].flags & IORESOURCE_IRQ) {
+		for (i = 0; i < PNP_MAX_IRQ; i++) {
+			if (tdev->res.irq_resource[i].flags & IORESOURCE_IRQ) {
 				if (cannot_compare
-				    (tdev->res.irq_resource[tmp].flags))
+				    (tdev->res.irq_resource[i].flags))
 					continue;
-				if ((tdev->res.irq_resource[tmp].start == *irq))
+				if ((tdev->res.irq_resource[i].start == *irq))
 					return 0;
 			}
 		}
@@ -405,7 +405,7 @@
 int pnp_check_dma(struct pnp_dev *dev, int idx)
 {
 #ifndef CONFIG_IA64
-	int tmp;
+	int i;
 	struct pnp_dev *tdev;
 	resource_size_t *dma = &dev->res.dma_resource[idx].start;
 
@@ -418,15 +418,15 @@
 		return 0;
 
 	/* check if the resource is reserved */
-	for (tmp = 0; tmp < 8; tmp++) {
-		if (pnp_reserve_dma[tmp] == *dma)
+	for (i = 0; i < 8; i++) {
+		if (pnp_reserve_dma[i] == *dma)
 			return 0;
 	}
 
 	/* check for internal conflicts */
-	for (tmp = 0; tmp < PNP_MAX_DMA && tmp != idx; tmp++) {
-		if (dev->res.dma_resource[tmp].flags & IORESOURCE_DMA) {
-			if (dev->res.dma_resource[tmp].start == *dma)
+	for (i = 0; i < PNP_MAX_DMA && i != idx; i++) {
+		if (dev->res.dma_resource[i].flags & IORESOURCE_DMA) {
+			if (dev->res.dma_resource[i].start == *dma)
 				return 0;
 		}
 	}
@@ -443,12 +443,12 @@
 	pnp_for_each_dev(tdev) {
 		if (tdev == dev)
 			continue;
-		for (tmp = 0; tmp < PNP_MAX_DMA; tmp++) {
-			if (tdev->res.dma_resource[tmp].flags & IORESOURCE_DMA) {
+		for (i = 0; i < PNP_MAX_DMA; i++) {
+			if (tdev->res.dma_resource[i].flags & IORESOURCE_DMA) {
 				if (cannot_compare
-				    (tdev->res.dma_resource[tmp].flags))
+				    (tdev->res.dma_resource[i].flags))
 					continue;
-				if ((tdev->res.dma_resource[tmp].start == *dma))
+				if ((tdev->res.dma_resource[i].start == *dma))
 					return 0;
 			}
 		}

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 28/37] PNP: add pnp_get_resource() interface
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (26 preceding siblings ...)
  2008-03-26 17:11 ` [patch 27/37] PNP: use conventional "i" for loop indices Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 23:15   ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 29/37] PNP: convert encoders to use pnp_get_resource(), not pnp_resource_table Bjorn Helgaas
                   ` (9 subsequent siblings)
  37 siblings, 1 reply; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-add-get-resource --]
[-- Type: text/plain, Size: 1924 bytes --]

This adds a pnp_get_resource() that works the same way as
platform_get_resource().  This will enable us to consolidate
many pnp_resource_table references in one place, which will
make it easier to make the table dynamic.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

---
 include/linux/pnp.h    |    1 +
 drivers/pnp/resource.c |   17 +++++++++++++++++
 2 files changed, 18 insertions(+)

Index: work7/include/linux/pnp.h
===================================================================
--- work7.orig/include/linux/pnp.h	2008-03-24 15:26:03.000000000 -0600
+++ work7/include/linux/pnp.h	2008-03-24 15:39:26.000000000 -0600
@@ -25,6 +25,7 @@
 /*
  * Resource Management
  */
+struct resource *pnp_get_resource(struct pnp_dev *, unsigned int, unsigned int);
 
 /* Use these instead of directly reading pnp_dev to get resource information */
 #define pnp_port_start(dev,bar)   ((dev)->res.port_resource[(bar)].start)
Index: work7/drivers/pnp/resource.c
===================================================================
--- work7.orig/drivers/pnp/resource.c	2008-03-24 15:26:03.000000000 -0600
+++ work7/drivers/pnp/resource.c	2008-03-24 15:40:25.000000000 -0600
@@ -560,6 +560,32 @@
 	return 0;
 }
 
+struct resource *pnp_get_resource(struct pnp_dev *dev,
+				  unsigned int type, unsigned int num)
+{
+	struct pnp_resource_table *res = &dev->res;
+
+	switch (type) {
+	case IORESOURCE_IO:
+		if (num >= PNP_MAX_PORT)
+			return NULL;
+		return &res->port_resource[num];
+	case IORESOURCE_MEM:
+		if (num >= PNP_MAX_MEM)
+			return NULL;
+		return &res->mem_resource[num];
+	case IORESOURCE_IRQ:
+		if (num >= PNP_MAX_IRQ)
+			return NULL;
+		return &res->irq_resource[num];
+	case IORESOURCE_DMA:
+		if (num >= PNP_MAX_DMA)
+			return NULL;
+		return &res->dma_resource[num];
+	}
+	return NULL;
+}
+
 /* format is: pnp_reserve_irq=irq1[,irq2] .... */
 static int __init pnp_setup_reserve_irq(char *str)
 {

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 29/37] PNP: convert encoders to use pnp_get_resource(), not pnp_resource_table
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (27 preceding siblings ...)
  2008-03-26 17:11 ` [patch 28/37] PNP: add pnp_get_resource() interface Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 30/37] PNP: convert resource accessors " Bjorn Helgaas
                   ` (8 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-convert-encoders-to-pnp_get_resource --]
[-- Type: text/plain, Size: 7004 bytes --]

This removes more direct references to pnp_resource_table.  This
path is used when setting the resources used by a device.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/pnp/isapnp/core.c
===================================================================
--- work7.orig/drivers/pnp/isapnp/core.c	2008-03-26 10:04:57.000000000 -0600
+++ work7/drivers/pnp/isapnp/core.c	2008-03-26 10:18:06.000000000 -0600
@@ -982,42 +982,37 @@
 
 static int isapnp_set_resources(struct pnp_dev *dev)
 {
-	struct pnp_resource_table *res = &dev->res;
-	int tmp;
+	int i, irq;
+	struct resource *res;
 
 	isapnp_cfg_begin(dev->card->number, dev->number);
 	dev->active = 1;
-	for (tmp = 0;
-	     tmp < ISAPNP_MAX_PORT
-	     && (res->port_resource[tmp].
-		 flags & (IORESOURCE_IO | IORESOURCE_UNSET)) == IORESOURCE_IO;
-	     tmp++)
-		isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1),
-				  res->port_resource[tmp].start);
-	for (tmp = 0;
-	     tmp < ISAPNP_MAX_IRQ
-	     && (res->irq_resource[tmp].
-		 flags & (IORESOURCE_IRQ | IORESOURCE_UNSET)) == IORESOURCE_IRQ;
-	     tmp++) {
-		int irq = res->irq_resource[tmp].start;
-		if (irq == 2)
-			irq = 9;
-		isapnp_write_byte(ISAPNP_CFG_IRQ + (tmp << 1), irq);
-	}
-	for (tmp = 0;
-	     tmp < ISAPNP_MAX_DMA
-	     && (res->dma_resource[tmp].
-		 flags & (IORESOURCE_DMA | IORESOURCE_UNSET)) == IORESOURCE_DMA;
-	     tmp++)
-		isapnp_write_byte(ISAPNP_CFG_DMA + tmp,
-				  res->dma_resource[tmp].start);
-	for (tmp = 0;
-	     tmp < ISAPNP_MAX_MEM
-	     && (res->mem_resource[tmp].
-		 flags & (IORESOURCE_MEM | IORESOURCE_UNSET)) == IORESOURCE_MEM;
-	     tmp++)
-		isapnp_write_word(ISAPNP_CFG_MEM + (tmp << 3),
-				  (res->mem_resource[tmp].start >> 8) & 0xffff);
+	for (i = 0; i < ISAPNP_MAX_PORT; i++) {
+		res = pnp_get_resource(dev, IORESOURCE_IO, i);
+		if (res && !(res->flags & IORESOURCE_UNSET))
+			isapnp_write_word(ISAPNP_CFG_PORT + (i << 1),
+					  res->start);
+	}
+	for (i = 0; i < ISAPNP_MAX_IRQ; i++) {
+		res = pnp_get_resource(dev, IORESOURCE_IRQ, i);
+		if (res && !(res->flags & IORESOURCE_UNSET)) {
+			irq = res->start;
+			if (irq == 2)
+				irq = 9;
+			isapnp_write_byte(ISAPNP_CFG_IRQ + (i << 1), irq);
+		}
+	}
+	for (i = 0; i < ISAPNP_MAX_DMA; i++) {
+		res = pnp_get_resource(dev, IORESOURCE_DMA, i);
+		if (res && !(res->flags & IORESOURCE_UNSET))
+			isapnp_write_byte(ISAPNP_CFG_DMA + i, res->start);
+	}
+	for (i = 0; i < ISAPNP_MAX_MEM; i++) {
+		res = pnp_get_resource(dev, IORESOURCE_MEM, i);
+		if (res && !(res->flags & IORESOURCE_UNSET))
+			isapnp_write_word(ISAPNP_CFG_MEM + (i << 3),
+					  (res->start >> 8) & 0xffff);
+	}
 	/* FIXME: We aren't handling 32bit mems properly here */
 	isapnp_activate(dev->number);
 	isapnp_cfg_end();
Index: work7/drivers/pnp/pnpacpi/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/rsparser.c	2008-03-26 10:18:03.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/rsparser.c	2008-03-26 10:18:06.000000000 -0600
@@ -852,7 +852,6 @@
 
 int pnpacpi_encode_resources(struct pnp_dev *dev, struct acpi_buffer *buffer)
 {
-	struct pnp_resource_table *res_table = &dev->res;
 	int i = 0;
 	/* pnpacpi_build_resource_template allocates extra mem */
 	int res_cnt = (buffer->length - 1) / sizeof(struct acpi_resource) - 1;
@@ -863,45 +862,43 @@
 		switch (resource->type) {
 		case ACPI_RESOURCE_TYPE_IRQ:
 			pnpacpi_encode_irq(resource,
-					   &res_table->irq_resource[irq]);
+				pnp_get_resource(dev, IORESOURCE_IRQ, irq));
 			irq++;
 			break;
 
 		case ACPI_RESOURCE_TYPE_DMA:
 			pnpacpi_encode_dma(resource,
-					   &res_table->dma_resource[dma]);
+				pnp_get_resource(dev, IORESOURCE_DMA, dma));
 			dma++;
 			break;
 		case ACPI_RESOURCE_TYPE_IO:
 			pnpacpi_encode_io(resource,
-					  &res_table->port_resource[port]);
+				pnp_get_resource(dev, IORESOURCE_IO, port));
 			port++;
 			break;
 		case ACPI_RESOURCE_TYPE_FIXED_IO:
 			pnpacpi_encode_fixed_io(resource,
-						&res_table->
-						port_resource[port]);
+				pnp_get_resource(dev, IORESOURCE_IO, port));
 			port++;
 			break;
 		case ACPI_RESOURCE_TYPE_MEMORY24:
 			pnpacpi_encode_mem24(resource,
-					     &res_table->mem_resource[mem]);
+				pnp_get_resource(dev, IORESOURCE_MEM, mem));
 			mem++;
 			break;
 		case ACPI_RESOURCE_TYPE_MEMORY32:
 			pnpacpi_encode_mem32(resource,
-					     &res_table->mem_resource[mem]);
+				pnp_get_resource(dev, IORESOURCE_MEM, mem));
 			mem++;
 			break;
 		case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
 			pnpacpi_encode_fixed_mem32(resource,
-						   &res_table->
-						   mem_resource[mem]);
+				pnp_get_resource(dev, IORESOURCE_MEM, mem));
 			mem++;
 			break;
 		case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
 			pnpacpi_encode_ext_irq(resource,
-					       &res_table->irq_resource[irq]);
+				pnp_get_resource(dev, IORESOURCE_IRQ, irq));
 			irq++;
 			break;
 		case ACPI_RESOURCE_TYPE_START_DEPENDENT:
Index: work7/drivers/pnp/pnpbios/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpbios/rsparser.c	2008-03-26 10:01:31.000000000 -0600
+++ work7/drivers/pnp/pnpbios/rsparser.c	2008-03-26 10:18:06.000000000 -0600
@@ -592,7 +592,6 @@
 							     unsigned char *p,
 							     unsigned char *end)
 {
-	struct pnp_resource_table *res = &dev->res;
 	unsigned int len, tag;
 	int port = 0, irq = 0, dma = 0, mem = 0;
 
@@ -615,42 +614,48 @@
 		case LARGE_TAG_MEM:
 			if (len != 9)
 				goto len_err;
-			pnpbios_encode_mem(p, &res->mem_resource[mem]);
+			pnpbios_encode_mem(p,
+				pnp_get_resource(dev, IORESOURCE_MEM, mem));
 			mem++;
 			break;
 
 		case LARGE_TAG_MEM32:
 			if (len != 17)
 				goto len_err;
-			pnpbios_encode_mem32(p, &res->mem_resource[mem]);
+			pnpbios_encode_mem32(p,
+				pnp_get_resource(dev, IORESOURCE_MEM, mem));
 			mem++;
 			break;
 
 		case LARGE_TAG_FIXEDMEM32:
 			if (len != 9)
 				goto len_err;
-			pnpbios_encode_fixed_mem32(p, &res->mem_resource[mem]);
+			pnpbios_encode_fixed_mem32(p,
+				pnp_get_resource(dev, IORESOURCE_MEM, mem));
 			mem++;
 			break;
 
 		case SMALL_TAG_IRQ:
 			if (len < 2 || len > 3)
 				goto len_err;
-			pnpbios_encode_irq(p, &res->irq_resource[irq]);
+			pnpbios_encode_irq(p,
+				pnp_get_resource(dev, IORESOURCE_IRQ, irq));
 			irq++;
 			break;
 
 		case SMALL_TAG_DMA:
 			if (len != 2)
 				goto len_err;
-			pnpbios_encode_dma(p, &res->dma_resource[dma]);
+			pnpbios_encode_dma(p,
+				pnp_get_resource(dev, IORESOURCE_DMA, dma));
 			dma++;
 			break;
 
 		case SMALL_TAG_PORT:
 			if (len != 7)
 				goto len_err;
-			pnpbios_encode_port(p, &res->port_resource[port]);
+			pnpbios_encode_port(p,
+				pnp_get_resource(dev, IORESOURCE_IO, port));
 			port++;
 			break;
 
@@ -661,7 +666,8 @@
 		case SMALL_TAG_FIXEDPORT:
 			if (len != 3)
 				goto len_err;
-			pnpbios_encode_fixed_port(p, &res->port_resource[port]);
+			pnpbios_encode_fixed_port(p,
+				pnp_get_resource(dev, IORESOURCE_IO, port));
 			port++;
 			break;
 

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 30/37] PNP: convert resource accessors to use pnp_get_resource(), not pnp_resource_table
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (28 preceding siblings ...)
  2008-03-26 17:11 ` [patch 29/37] PNP: convert encoders to use pnp_get_resource(), not pnp_resource_table Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 31/37] PNP: convert resource checks " Bjorn Helgaas
                   ` (7 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-convert-accessors-to-pnp_get_resource --]
[-- Type: text/plain, Size: 4085 bytes --]

This removes more direct references to pnp_resource_table.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/include/linux/pnp.h
===================================================================
--- work7.orig/include/linux/pnp.h	2008-03-24 15:19:46.000000000 -0600
+++ work7/include/linux/pnp.h	2008-03-24 15:19:47.000000000 -0600
@@ -28,12 +28,24 @@
 struct resource *pnp_get_resource(struct pnp_dev *, unsigned int, unsigned int);
 
 /* Use these instead of directly reading pnp_dev to get resource information */
-#define pnp_port_start(dev,bar)   ((dev)->res.port_resource[(bar)].start)
-#define pnp_port_end(dev,bar)     ((dev)->res.port_resource[(bar)].end)
-#define pnp_port_flags(dev,bar)   ((dev)->res.port_resource[(bar)].flags)
-#define pnp_port_valid(dev,bar) \
-	((pnp_port_flags((dev),(bar)) & (IORESOURCE_IO | IORESOURCE_UNSET)) \
-		== IORESOURCE_IO)
+
+#define pnp_port_start(dev,bar)	\
+	pnp_get_resource(dev, IORESOURCE_IO, bar)->start
+#define pnp_port_end(dev,bar)	\
+	pnp_get_resource(dev, IORESOURCE_IO, bar)->end
+#define pnp_port_flags(dev,bar)	\
+	pnp_get_resource(dev, IORESOURCE_IO, bar)->flags
+
+static inline resource_size_t pnp_port_valid(struct pnp_dev *dev,
+					     unsigned int bar)
+{
+	struct resource *res = pnp_get_resource(dev, IORESOURCE_IO, bar);
+
+	if (res && !(res->flags & IORESOURCE_UNSET))
+		return 1;
+	return 0;
+}
+
 #define pnp_port_len(dev,bar) \
 	((pnp_port_start((dev),(bar)) == 0 &&	\
 	  pnp_port_end((dev),(bar)) ==		\
@@ -42,12 +54,23 @@
 	 (pnp_port_end((dev),(bar)) -		\
 	  pnp_port_start((dev),(bar)) + 1))
 
-#define pnp_mem_start(dev,bar)   ((dev)->res.mem_resource[(bar)].start)
-#define pnp_mem_end(dev,bar)     ((dev)->res.mem_resource[(bar)].end)
-#define pnp_mem_flags(dev,bar)   ((dev)->res.mem_resource[(bar)].flags)
-#define pnp_mem_valid(dev,bar) \
-	((pnp_mem_flags((dev),(bar)) & (IORESOURCE_MEM | IORESOURCE_UNSET)) \
-		== IORESOURCE_MEM)
+#define pnp_mem_start(dev,bar)	\
+	pnp_get_resource(dev, IORESOURCE_MEM, bar)->start
+#define pnp_mem_end(dev,bar)	\
+	pnp_get_resource(dev, IORESOURCE_MEM, bar)->end
+#define pnp_mem_flags(dev,bar)	\
+	pnp_get_resource(dev, IORESOURCE_MEM, bar)->flags
+
+static inline resource_size_t pnp_mem_valid(struct pnp_dev *dev,
+					    unsigned int bar)
+{
+	struct resource *res = pnp_get_resource(dev, IORESOURCE_MEM, bar);
+
+	if (res && !(res->flags & IORESOURCE_UNSET))
+		return 1;
+	return 0;
+}
+
 #define pnp_mem_len(dev,bar) \
 	((pnp_mem_start((dev),(bar)) == 0 &&	\
 	  pnp_mem_end((dev),(bar)) ==		\
@@ -56,17 +79,35 @@
 	 (pnp_mem_end((dev),(bar)) -		\
 	  pnp_mem_start((dev),(bar)) + 1))
 
-#define pnp_irq(dev,bar)	 ((dev)->res.irq_resource[(bar)].start)
-#define pnp_irq_flags(dev,bar)	 ((dev)->res.irq_resource[(bar)].flags)
-#define pnp_irq_valid(dev,bar) \
-	((pnp_irq_flags((dev),(bar)) & (IORESOURCE_IRQ | IORESOURCE_UNSET)) \
-		== IORESOURCE_IRQ)
-
-#define pnp_dma(dev,bar)	 ((dev)->res.dma_resource[(bar)].start)
-#define pnp_dma_flags(dev,bar)	 ((dev)->res.dma_resource[(bar)].flags)
-#define pnp_dma_valid(dev,bar) \
-	((pnp_dma_flags((dev),(bar)) & (IORESOURCE_DMA | IORESOURCE_UNSET)) \
-		== IORESOURCE_DMA)
+#define pnp_irq(dev,bar)	\
+	pnp_get_resource(dev, IORESOURCE_IRQ, bar)->start
+#define pnp_irq_flags(dev,bar)	\
+	pnp_get_resource(dev, IORESOURCE_IRQ, bar)->flags
+
+static inline resource_size_t pnp_irq_valid(struct pnp_dev *dev,
+					    unsigned int bar)
+{
+	struct resource *res = pnp_get_resource(dev, IORESOURCE_IRQ, bar);
+
+	if (res && !(res->flags & IORESOURCE_UNSET))
+		return 1;
+	return 0;
+}
+
+#define pnp_dma(dev,bar)	\
+	pnp_get_resource(dev, IORESOURCE_DMA, bar)->start
+#define pnp_dma_flags(dev,bar)	\
+	pnp_get_resource(dev, IORESOURCE_DMA, bar)->flags
+
+static inline resource_size_t pnp_dma_valid(struct pnp_dev *dev,
+					    unsigned int bar)
+{
+	struct resource *res = pnp_get_resource(dev, IORESOURCE_DMA, bar);
+
+	if (res && !(res->flags & IORESOURCE_UNSET))
+		return 1;
+	return 0;
+}
 
 #define PNP_PORT_FLAG_16BITADDR	(1<<0)
 #define PNP_PORT_FLAG_FIXED	(1<<1)

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 31/37] PNP: convert resource checks to use pnp_get_resource(), not pnp_resource_table
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (29 preceding siblings ...)
  2008-03-26 17:11 ` [patch 30/37] PNP: convert resource accessors " Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 32/37] PNP: convert resource assign functions " Bjorn Helgaas
                   ` (6 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-convert-checks-to-pnp_get_resource --]
[-- Type: text/plain, Size: 6319 bytes --]

This removes more direct references to pnp_resource_table.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/pnp/resource.c
===================================================================
--- work7.orig/drivers/pnp/resource.c	2008-03-24 16:35:33.000000000 -0600
+++ work7/drivers/pnp/resource.c	2008-03-24 16:50:00.000000000 -0600
@@ -216,14 +216,17 @@
 int pnp_check_port(struct pnp_dev *dev, int idx)
 {
 	int i;
+	struct resource *res, *tres;
 	struct pnp_dev *tdev;
 	resource_size_t *port, *end, *tport, *tend;
 
-	port = &dev->res.port_resource[idx].start;
-	end = &dev->res.port_resource[idx].end;
+	res = pnp_get_resource(dev, IORESOURCE_IO, idx);
+
+	port = &res->start;
+	end = &res->end;
 
 	/* if the resource doesn't exist, don't complain about it */
-	if (cannot_compare(dev->res.port_resource[idx].flags))
+	if (cannot_compare(res->flags))
 		return 1;
 
 	/* check if the resource is already in use, skip if the
@@ -243,9 +246,10 @@
 
 	/* check for internal conflicts */
 	for (i = 0; i < PNP_MAX_PORT && i != idx; i++) {
-		if (dev->res.port_resource[i].flags & IORESOURCE_IO) {
-			tport = &dev->res.port_resource[i].start;
-			tend = &dev->res.port_resource[i].end;
+		tres = pnp_get_resource(dev, IORESOURCE_IO, i);
+		if (tres->flags & IORESOURCE_IO) {
+			tport = &tres->start;
+			tend = &tres->end;
 			if (ranged_conflict(port, end, tport, tend))
 				return 0;
 		}
@@ -256,12 +260,12 @@
 		if (tdev == dev)
 			continue;
 		for (i = 0; i < PNP_MAX_PORT; i++) {
-			if (tdev->res.port_resource[i].flags & IORESOURCE_IO) {
-				if (cannot_compare
-				    (tdev->res.port_resource[i].flags))
+			tres = pnp_get_resource(dev, IORESOURCE_IO, i);
+			if (tres->flags & IORESOURCE_IO) {
+				if (cannot_compare(tres->flags))
 					continue;
-				tport = &tdev->res.port_resource[i].start;
-				tend = &tdev->res.port_resource[i].end;
+				tport = &tres->start;
+				tend = &tres->end;
 				if (ranged_conflict(port, end, tport, tend))
 					return 0;
 			}
@@ -274,14 +278,17 @@
 int pnp_check_mem(struct pnp_dev *dev, int idx)
 {
 	int i;
+	struct resource *res, *tres;
 	struct pnp_dev *tdev;
 	resource_size_t *addr, *end, *taddr, *tend;
 
-	addr = &dev->res.mem_resource[idx].start;
-	end = &dev->res.mem_resource[idx].end;
+	res = pnp_get_resource(dev, IORESOURCE_MEM, idx);
+
+	addr = &res->start;
+	end = &res->end;
 
 	/* if the resource doesn't exist, don't complain about it */
-	if (cannot_compare(dev->res.mem_resource[idx].flags))
+	if (cannot_compare(res->flags))
 		return 1;
 
 	/* check if the resource is already in use, skip if the
@@ -301,9 +308,10 @@
 
 	/* check for internal conflicts */
 	for (i = 0; i < PNP_MAX_MEM && i != idx; i++) {
-		if (dev->res.mem_resource[i].flags & IORESOURCE_MEM) {
-			taddr = &dev->res.mem_resource[i].start;
-			tend = &dev->res.mem_resource[i].end;
+		tres = pnp_get_resource(dev, IORESOURCE_MEM, i);
+		if (tres->flags & IORESOURCE_MEM) {
+			taddr = &tres->start;
+			tend = &tres->end;
 			if (ranged_conflict(addr, end, taddr, tend))
 				return 0;
 		}
@@ -314,12 +322,12 @@
 		if (tdev == dev)
 			continue;
 		for (i = 0; i < PNP_MAX_MEM; i++) {
-			if (tdev->res.mem_resource[i].flags & IORESOURCE_MEM) {
-				if (cannot_compare
-				    (tdev->res.mem_resource[i].flags))
+			tres = pnp_get_resource(dev, IORESOURCE_MEM, i);
+			if (tres->flags & IORESOURCE_MEM) {
+				if (cannot_compare(tres->flags))
 					continue;
-				taddr = &tdev->res.mem_resource[i].start;
-				tend = &tdev->res.mem_resource[i].end;
+				taddr = &tres->start;
+				tend = &tres->end;
 				if (ranged_conflict(addr, end, taddr, tend))
 					return 0;
 			}
@@ -337,11 +345,16 @@
 int pnp_check_irq(struct pnp_dev *dev, int idx)
 {
 	int i;
+	struct resource *res, *tres;
 	struct pnp_dev *tdev;
-	resource_size_t *irq = &dev->res.irq_resource[idx].start;
+	resource_size_t *irq;
+
+	res = pnp_get_resource(dev, IORESOURCE_IRQ, idx);
+
+	irq = &res->start;
 
 	/* if the resource doesn't exist, don't complain about it */
-	if (cannot_compare(dev->res.irq_resource[idx].flags))
+	if (cannot_compare(res->flags))
 		return 1;
 
 	/* check if the resource is valid */
@@ -356,8 +369,9 @@
 
 	/* check for internal conflicts */
 	for (i = 0; i < PNP_MAX_IRQ && i != idx; i++) {
-		if (dev->res.irq_resource[i].flags & IORESOURCE_IRQ) {
-			if (dev->res.irq_resource[i].start == *irq)
+		tres = pnp_get_resource(dev, IORESOURCE_IRQ, i);
+		if (tres->flags & IORESOURCE_IRQ) {
+			if (tres->start == *irq)
 				return 0;
 		}
 	}
@@ -389,11 +403,11 @@
 		if (tdev == dev)
 			continue;
 		for (i = 0; i < PNP_MAX_IRQ; i++) {
-			if (tdev->res.irq_resource[i].flags & IORESOURCE_IRQ) {
-				if (cannot_compare
-				    (tdev->res.irq_resource[i].flags))
+			tres = pnp_get_resource(dev, IORESOURCE_IRQ, i);
+			if (tres->flags & IORESOURCE_IRQ) {
+				if (cannot_compare(tres->flags))
 					continue;
-				if ((tdev->res.irq_resource[i].start == *irq))
+				if (tres->start == *irq)
 					return 0;
 			}
 		}
@@ -406,11 +420,16 @@
 {
 #ifndef CONFIG_IA64
 	int i;
+	struct resource *res, *tres;
 	struct pnp_dev *tdev;
-	resource_size_t *dma = &dev->res.dma_resource[idx].start;
+	resource_size_t *dma;
+
+	res = pnp_get_resource(dev, IORESOURCE_DMA, idx);
+
+	dma = &res->start;
 
 	/* if the resource doesn't exist, don't complain about it */
-	if (cannot_compare(dev->res.dma_resource[idx].flags))
+	if (cannot_compare(res->flags))
 		return 1;
 
 	/* check if the resource is valid */
@@ -425,8 +444,9 @@
 
 	/* check for internal conflicts */
 	for (i = 0; i < PNP_MAX_DMA && i != idx; i++) {
-		if (dev->res.dma_resource[i].flags & IORESOURCE_DMA) {
-			if (dev->res.dma_resource[i].start == *dma)
+		tres = pnp_get_resource(dev, IORESOURCE_DMA, i);
+		if (tres->flags & IORESOURCE_DMA) {
+			if (tres->start == *dma)
 				return 0;
 		}
 	}
@@ -444,11 +464,11 @@
 		if (tdev == dev)
 			continue;
 		for (i = 0; i < PNP_MAX_DMA; i++) {
-			if (tdev->res.dma_resource[i].flags & IORESOURCE_DMA) {
-				if (cannot_compare
-				    (tdev->res.dma_resource[i].flags))
+			tres = pnp_get_resource(dev, IORESOURCE_DMA, i);
+			if (tres->flags & IORESOURCE_DMA) {
+				if (cannot_compare(tres->flags))
 					continue;
-				if ((tdev->res.dma_resource[i].start == *dma))
+				if (tres->start == *dma)
 					return 0;
 			}
 		}

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 32/37] PNP: convert resource assign functions to use pnp_get_resource(), not pnp_resource_table
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (30 preceding siblings ...)
  2008-03-26 17:11 ` [patch 31/37] PNP: convert resource checks " Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 33/37] PNP: remove PNP_MAX_* uses Bjorn Helgaas
                   ` (5 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-convert-assign-to-pnp_get_resource --]
[-- Type: text/plain, Size: 3297 bytes --]

This removes more direct references to pnp_resource_table.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/pnp/manager.c
===================================================================
--- work7.orig/drivers/pnp/manager.c	2008-03-25 09:11:25.000000000 -0600
+++ work7/drivers/pnp/manager.c	2008-03-25 09:18:54.000000000 -0600
@@ -19,6 +19,7 @@
 
 static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx)
 {
+	struct resource *res;
 	resource_size_t *start, *end;
 	unsigned long *flags;
 
@@ -28,13 +29,15 @@
 		return 1;
 	}
 
+	res = pnp_get_resource(dev, IORESOURCE_IO, idx);
+
 	/* check if this resource has been manually set, if so skip */
-	if (!(dev->res.port_resource[idx].flags & IORESOURCE_AUTO))
+	if (!(res->flags & IORESOURCE_AUTO))
 		return 1;
 
-	start = &dev->res.port_resource[idx].start;
-	end = &dev->res.port_resource[idx].end;
-	flags = &dev->res.port_resource[idx].flags;
+	start = &res->start;
+	end = &res->end;
+	flags = &res->flags;
 
 	/* set the initial values */
 	*flags |= rule->flags | IORESOURCE_IO;
@@ -60,6 +63,7 @@
 
 static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx)
 {
+	struct resource *res;
 	resource_size_t *start, *end;
 	unsigned long *flags;
 
@@ -69,13 +73,15 @@
 		return 1;
 	}
 
+	res = pnp_get_resource(dev, IORESOURCE_MEM, idx);
+
 	/* check if this resource has been manually set, if so skip */
-	if (!(dev->res.mem_resource[idx].flags & IORESOURCE_AUTO))
+	if (!(res->flags & IORESOURCE_AUTO))
 		return 1;
 
-	start = &dev->res.mem_resource[idx].start;
-	end = &dev->res.mem_resource[idx].end;
-	flags = &dev->res.mem_resource[idx].flags;
+	start = &res->start;
+	end = &res->end;
+	flags = &res->flags;
 
 	/* set the initial values */
 	*flags |= rule->flags | IORESOURCE_MEM;
@@ -111,6 +117,7 @@
 
 static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx)
 {
+	struct resource *res;
 	resource_size_t *start, *end;
 	unsigned long *flags;
 	int i;
@@ -126,13 +133,15 @@
 		return 1;
 	}
 
+	res = pnp_get_resource(dev, IORESOURCE_IRQ, idx);
+
 	/* check if this resource has been manually set, if so skip */
-	if (!(dev->res.irq_resource[idx].flags & IORESOURCE_AUTO))
+	if (!(res->flags & IORESOURCE_AUTO))
 		return 1;
 
-	start = &dev->res.irq_resource[idx].start;
-	end = &dev->res.irq_resource[idx].end;
-	flags = &dev->res.irq_resource[idx].flags;
+	start = &res->start;
+	end = &res->end;
+	flags = &res->flags;
 
 	/* set the initial values */
 	*flags |= rule->flags | IORESOURCE_IRQ;
@@ -161,6 +170,7 @@
 
 static void pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx)
 {
+	struct resource *res;
 	resource_size_t *start, *end;
 	unsigned long *flags;
 	int i;
@@ -175,13 +185,15 @@
 		return;
 	}
 
+	res = pnp_get_resource(dev, IORESOURCE_DMA, idx);
+
 	/* check if this resource has been manually set, if so skip */
-	if (!(dev->res.dma_resource[idx].flags & IORESOURCE_AUTO))
+	if (!(res->flags & IORESOURCE_AUTO))
 		return;
 
-	start = &dev->res.dma_resource[idx].start;
-	end = &dev->res.dma_resource[idx].end;
-	flags = &dev->res.dma_resource[idx].flags;
+	start = &res->start;
+	end = &res->end;
+	flags = &res->flags;
 
 	/* set the initial values */
 	*flags |= rule->flags | IORESOURCE_DMA;

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 33/37] PNP: remove PNP_MAX_* uses
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (31 preceding siblings ...)
  2008-03-26 17:11 ` [patch 32/37] PNP: convert resource assign functions " Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 34/37] PNP: remove unused interfaces using pnp_resource_table Bjorn Helgaas
                   ` (4 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-remove-max-uses --]
[-- Type: text/plain, Size: 9174 bytes --]

Remove some PNP_MAX_* uses.  The pnp_resource_table isn't
dynamic yet, but with pnp_get_resource(), we can start moving
away from the table size constants.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

---
 drivers/pnp/interface.c |   43 +++++++++++++++++++++----------------------
 drivers/pnp/quirks.c    |   15 +++++++++------
 drivers/pnp/resource.c  |   40 ++++++++++++++++++++++++----------------
 drivers/pnp/system.c    |   21 ++++++++++-----------
 4 files changed, 64 insertions(+), 55 deletions(-)

Index: work7/drivers/pnp/interface.c
===================================================================
--- work7.orig/drivers/pnp/interface.c	2008-03-24 16:35:22.000000000 -0600
+++ work7/drivers/pnp/interface.c	2008-03-24 16:51:17.000000000 -0600
@@ -243,11 +243,14 @@
 
 static DEVICE_ATTR(options, S_IRUGO, pnp_show_options, NULL);
 
+#define set(flags)      ((flags & IORESOURCE_UNSET) == 0)
+
 static ssize_t pnp_show_current_resources(struct device *dmdev,
 					  struct device_attribute *attr,
 					  char *buf)
 {
 	struct pnp_dev *dev = to_pnp_dev(dmdev);
+	struct resource *res;
 	int i, ret;
 	pnp_info_buffer_t *buffer;
 
@@ -267,50 +270,46 @@
 	else
 		pnp_printf(buffer, "disabled\n");
 
-	for (i = 0; i < PNP_MAX_PORT; i++) {
-		if (pnp_port_valid(dev, i)) {
+	for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IO, i)); i++) {
+		if (set(res->flags)) {
 			pnp_printf(buffer, "io");
-			if (pnp_port_flags(dev, i) & IORESOURCE_DISABLED)
+			if (res->flags & IORESOURCE_DISABLED)
 				pnp_printf(buffer, " disabled\n");
 			else
 				pnp_printf(buffer, " 0x%llx-0x%llx\n",
-					   (unsigned long long)
-					   pnp_port_start(dev, i),
-					   (unsigned long long)pnp_port_end(dev,
-									    i));
+					   (unsigned long long) res->start,
+					   (unsigned long long) res->end);
 		}
 	}
-	for (i = 0; i < PNP_MAX_MEM; i++) {
-		if (pnp_mem_valid(dev, i)) {
+	for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) {
+		if (set(res->flags)) {
 			pnp_printf(buffer, "mem");
-			if (pnp_mem_flags(dev, i) & IORESOURCE_DISABLED)
+			if (res->flags & IORESOURCE_DISABLED)
 				pnp_printf(buffer, " disabled\n");
 			else
 				pnp_printf(buffer, " 0x%llx-0x%llx\n",
-					   (unsigned long long)
-					   pnp_mem_start(dev, i),
-					   (unsigned long long)pnp_mem_end(dev,
-									   i));
+					   (unsigned long long) res->start,
+					   (unsigned long long) res->end);
 		}
 	}
-	for (i = 0; i < PNP_MAX_IRQ; i++) {
-		if (pnp_irq_valid(dev, i)) {
+	for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IRQ, i)); i++) {
+		if (set(res->flags)) {
 			pnp_printf(buffer, "irq");
-			if (pnp_irq_flags(dev, i) & IORESOURCE_DISABLED)
+			if (res->flags & IORESOURCE_DISABLED)
 				pnp_printf(buffer, " disabled\n");
 			else
 				pnp_printf(buffer, " %lld\n",
-					   (unsigned long long)pnp_irq(dev, i));
+					   (unsigned long long) res->start);
 		}
 	}
-	for (i = 0; i < PNP_MAX_DMA; i++) {
-		if (pnp_dma_valid(dev, i)) {
+	for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_DMA, i)); i++) {
+		if (set(res->flags)) {
 			pnp_printf(buffer, "dma");
-			if (pnp_dma_flags(dev, i) & IORESOURCE_DISABLED)
+			if (res->flags & IORESOURCE_DISABLED)
 				pnp_printf(buffer, " disabled\n");
 			else
 				pnp_printf(buffer, " %lld\n",
-					   (unsigned long long)pnp_dma(dev, i));
+					   (unsigned long long) res->start);
 		}
 	}
 	ret = (buffer->curr - buf);
Index: work7/drivers/pnp/quirks.c
===================================================================
--- work7.orig/drivers/pnp/quirks.c	2008-03-24 16:35:22.000000000 -0600
+++ work7/drivers/pnp/quirks.c	2008-03-24 16:51:17.000000000 -0600
@@ -114,6 +114,7 @@
 static void quirk_system_pci_resources(struct pnp_dev *dev)
 {
 	struct pci_dev *pdev = NULL;
+	struct resource *res;
 	resource_size_t pnp_start, pnp_end, pci_start, pci_end;
 	int i, j;
 
@@ -134,13 +135,15 @@
 
 			pci_start = pci_resource_start(pdev, i);
 			pci_end = pci_resource_end(pdev, i);
-			for (j = 0; j < PNP_MAX_MEM; j++) {
-				if (!pnp_mem_valid(dev, j) ||
-				    pnp_mem_len(dev, j) == 0)
+			for (j = 0;
+			     (res = pnp_get_resource(dev, IORESOURCE_MEM, j));
+			     j++) {
+				if (res->flags & IORESOURCE_UNSET ||
+				    (res->start == 0 && res->end == 0))
 					continue;
 
-				pnp_start = pnp_mem_start(dev, j);
-				pnp_end = pnp_mem_end(dev, j);
+				pnp_start = res->start;
+				pnp_end = res->end;
 
 				/*
 				 * If the PNP region doesn't overlap the PCI
@@ -173,7 +176,7 @@
 					pci_name(pdev), i,
 					(unsigned long long) pci_start,
 					(unsigned long long) pci_end);
-				pnp_mem_flags(dev, j) = 0;
+				res->flags = 0;
 			}
 		}
 	}
Index: work7/drivers/pnp/resource.c
===================================================================
--- work7.orig/drivers/pnp/resource.c	2008-03-24 16:51:28.000000000 -0600
+++ work7/drivers/pnp/resource.c	2008-03-24 16:58:00.000000000 -0600
@@ -245,8 +245,9 @@
 	}
 
 	/* check for internal conflicts */
-	for (i = 0; i < PNP_MAX_PORT && i != idx; i++) {
-		tres = pnp_get_resource(dev, IORESOURCE_IO, i);
+	for (i = 0;
+	     i != idx && (tres = pnp_get_resource(dev, IORESOURCE_IO, i));
+	     i++) {
 		if (tres->flags & IORESOURCE_IO) {
 			tport = &tres->start;
 			tend = &tres->end;
@@ -259,8 +260,9 @@
 	pnp_for_each_dev(tdev) {
 		if (tdev == dev)
 			continue;
-		for (i = 0; i < PNP_MAX_PORT; i++) {
-			tres = pnp_get_resource(dev, IORESOURCE_IO, i);
+		for (i = 0;
+		     (tres = pnp_get_resource(dev, IORESOURCE_IO, i));
+		     i++) {
 			if (tres->flags & IORESOURCE_IO) {
 				if (cannot_compare(tres->flags))
 					continue;
@@ -307,8 +309,9 @@
 	}
 
 	/* check for internal conflicts */
-	for (i = 0; i < PNP_MAX_MEM && i != idx; i++) {
-		tres = pnp_get_resource(dev, IORESOURCE_MEM, i);
+	for (i = 0;
+	     i != idx && (tres = pnp_get_resource(dev, IORESOURCE_MEM, i));
+	     i++) {
 		if (tres->flags & IORESOURCE_MEM) {
 			taddr = &tres->start;
 			tend = &tres->end;
@@ -321,8 +324,9 @@
 	pnp_for_each_dev(tdev) {
 		if (tdev == dev)
 			continue;
-		for (i = 0; i < PNP_MAX_MEM; i++) {
-			tres = pnp_get_resource(dev, IORESOURCE_MEM, i);
+		for (i = 0;
+		     (tres = pnp_get_resource(dev, IORESOURCE_MEM, i));
+		     i++) {
 			if (tres->flags & IORESOURCE_MEM) {
 				if (cannot_compare(tres->flags))
 					continue;
@@ -368,8 +372,9 @@
 	}
 
 	/* check for internal conflicts */
-	for (i = 0; i < PNP_MAX_IRQ && i != idx; i++) {
-		tres = pnp_get_resource(dev, IORESOURCE_IRQ, i);
+	for (i = 0;
+	     i != idx && (tres = pnp_get_resource(dev, IORESOURCE_IRQ, i));
+	     i++) {
 		if (tres->flags & IORESOURCE_IRQ) {
 			if (tres->start == *irq)
 				return 0;
@@ -402,8 +407,9 @@
 	pnp_for_each_dev(tdev) {
 		if (tdev == dev)
 			continue;
-		for (i = 0; i < PNP_MAX_IRQ; i++) {
-			tres = pnp_get_resource(dev, IORESOURCE_IRQ, i);
+		for (i = 0;
+		     (tres = pnp_get_resource(dev, IORESOURCE_IRQ, i));
+		     i++) {
 			if (tres->flags & IORESOURCE_IRQ) {
 				if (cannot_compare(tres->flags))
 					continue;
@@ -443,8 +449,9 @@
 	}
 
 	/* check for internal conflicts */
-	for (i = 0; i < PNP_MAX_DMA && i != idx; i++) {
-		tres = pnp_get_resource(dev, IORESOURCE_DMA, i);
+	for (i = 0;
+	     i != idx && (tres = pnp_get_resource(dev, IORESOURCE_DMA, i));
+	     i++) {
 		if (tres->flags & IORESOURCE_DMA) {
 			if (tres->start == *dma)
 				return 0;
@@ -463,8 +470,9 @@
 	pnp_for_each_dev(tdev) {
 		if (tdev == dev)
 			continue;
-		for (i = 0; i < PNP_MAX_DMA; i++) {
-			tres = pnp_get_resource(dev, IORESOURCE_DMA, i);
+		for (i = 0;
+		     (tres = pnp_get_resource(dev, IORESOURCE_DMA, i));
+		     i++) {
 			if (tres->flags & IORESOURCE_DMA) {
 				if (cannot_compare(tres->flags))
 					continue;
Index: work7/drivers/pnp/system.c
===================================================================
--- work7.orig/drivers/pnp/system.c	2008-03-24 16:35:22.000000000 -0600
+++ work7/drivers/pnp/system.c	2008-03-24 16:51:17.000000000 -0600
@@ -56,14 +56,15 @@
 
 static void reserve_resources_of_dev(struct pnp_dev *dev)
 {
+	struct resource *res;
 	int i;
 
-	for (i = 0; i < PNP_MAX_PORT; i++) {
-		if (!pnp_port_valid(dev, i))
+	for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IO, i)); i++) {
+		if (res->flags & IORESOURCE_UNSET)
 			continue;
-		if (pnp_port_start(dev, i) == 0)
+		if (res->start == 0)
 			continue;	/* disabled */
-		if (pnp_port_start(dev, i) < 0x100)
+		if (res->start < 0x100)
 			/*
 			 * Below 0x100 is only standard PC hardware
 			 * (pics, kbd, timer, dma, ...)
@@ -73,19 +74,17 @@
 			 * So, do nothing
 			 */
 			continue;
-		if (pnp_port_end(dev, i) < pnp_port_start(dev, i))
+		if (res->end < res->start)
 			continue;	/* invalid */
 
-		reserve_range(dev, pnp_port_start(dev, i),
-			      pnp_port_end(dev, i), 1);
+		reserve_range(dev, res->start, res->end, 1);
 	}
 
-	for (i = 0; i < PNP_MAX_MEM; i++) {
-		if (!pnp_mem_valid(dev, i))
+	for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) {
+		if (res->flags & IORESOURCE_UNSET)
 			continue;
 
-		reserve_range(dev, pnp_mem_start(dev, i),
-			      pnp_mem_end(dev, i), 0);
+		reserve_range(dev, res->start, res->end, 0);
 	}
 }
 

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 34/37] PNP: remove unused interfaces using pnp_resource_table
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (32 preceding siblings ...)
  2008-03-26 17:11 ` [patch 33/37] PNP: remove PNP_MAX_* uses Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 35/37] rtc: dont reference pnp_resource_table directly Bjorn Helgaas
                   ` (3 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-remove-unused-interfaces --]
[-- Type: text/plain, Size: 6143 bytes --]

Rene Herman <rene.herman@gmail.com> recently removed the only in-tree
driver uses of:

    pnp_init_resource_table()
    pnp_manual_config_dev()
    pnp_resource_change()

in this change:

    http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=109c53f840e551d6e99ecfd8b0131a968332c89f

These are no longer used in the PNP core either, so we can just remove
them completely.

It's possible that there are out-of-tree drivers that use these
interfaces.  They should be changed to either (1) use PNP quirks
to work around broken hardware or firmware, or (2) use the sysfs
interfaces to control resource usage from userspace.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

---
 drivers/pnp/manager.c |   78 +-------------------------------------------------
 include/linux/pnp.h   |    9 -----
 2 files changed, 3 insertions(+), 84 deletions(-)

Index: work7/include/linux/pnp.h
===================================================================
--- work7.orig/include/linux/pnp.h	2008-03-25 14:49:10.000000000 -0600
+++ work7/include/linux/pnp.h	2008-03-25 14:49:13.000000000 -0600
@@ -429,18 +429,14 @@
 int pnp_register_port_resource(struct pnp_option *option,
 			       struct pnp_port *data);
 int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data);
-void pnp_init_resource_table(struct pnp_resource_table *table);
 void pnp_init_resources(struct pnp_dev *dev);
-int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res,
-			  int mode);
 int pnp_auto_config_dev(struct pnp_dev *dev);
 int pnp_validate_config(struct pnp_dev *dev);
 int pnp_start_dev(struct pnp_dev *dev);
 int pnp_stop_dev(struct pnp_dev *dev);
 int pnp_activate_dev(struct pnp_dev *dev);
 int pnp_disable_dev(struct pnp_dev *dev);
-void pnp_resource_change(struct resource *resource, resource_size_t start,
-			 resource_size_t size);
+
 
 /* protocol helpers */
 int pnp_is_active(struct pnp_dev *dev);
@@ -477,16 +473,13 @@
 static inline int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data) { return -ENODEV; }
 static inline int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data) { return -ENODEV; }
 static inline int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data) { return -ENODEV; }
-static inline void pnp_init_resource_table(struct pnp_resource_table *table) { }
 static inline void pnp_init_resources(struct pnp_dev *dev) { }
-static inline int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res, int mode) { return -ENODEV; }
 static inline int pnp_auto_config_dev(struct pnp_dev *dev) { return -ENODEV; }
 static inline int pnp_validate_config(struct pnp_dev *dev) { return -ENODEV; }
 static inline int pnp_start_dev(struct pnp_dev *dev) { return -ENODEV; }
 static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; }
 static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; }
 static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; }
-static inline void pnp_resource_change(struct resource *resource, resource_size_t start, resource_size_t size) { }
 
 /* protocol helpers */
 static inline int pnp_is_active(struct pnp_dev *dev) { return 0; }
Index: work7/drivers/pnp/manager.c
===================================================================
--- work7.orig/drivers/pnp/manager.c	2008-03-25 14:49:12.000000000 -0600
+++ work7/drivers/pnp/manager.c	2008-03-25 14:49:13.000000000 -0600
@@ -216,8 +216,9 @@
  * pnp_init_resources - Resets a resource table to default values.
  * @table: pointer to the desired resource table
  */
-void pnp_init_resource_table(struct pnp_resource_table *table)
+void pnp_init_resources(struct pnp_dev *dev)
 {
+	struct pnp_resource_table *table = &dev->res;
 	int idx;
 
 	for (idx = 0; idx < PNP_MAX_IRQ; idx++) {
@@ -250,11 +251,6 @@
 	}
 }
 
-void pnp_init_resources(struct pnp_dev *dev)
-{
-	pnp_init_resource_table(&dev->res);
-}
-
 /**
  * pnp_clean_resources - clears resources that were not manually set
  * @res: the resources to clean
@@ -395,59 +391,6 @@
 }
 
 /**
- * pnp_manual_config_dev - Disables Auto Config and Manually sets the resource table
- * @dev: pointer to the desired device
- * @res: pointer to the new resource config
- * @mode: 0 or PNP_CONFIG_FORCE
- *
- * This function can be used by drivers that want to manually set thier resources.
- */
-int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res,
-			  int mode)
-{
-	int i;
-	struct pnp_resource_table *bak;
-
-	if (!pnp_can_configure(dev))
-		return -ENODEV;
-	bak = pnp_alloc(sizeof(struct pnp_resource_table));
-	if (!bak)
-		return -ENOMEM;
-	*bak = dev->res;
-
-	mutex_lock(&pnp_res_mutex);
-	dev->res = *res;
-	if (!(mode & PNP_CONFIG_FORCE)) {
-		for (i = 0; i < PNP_MAX_PORT; i++) {
-			if (!pnp_check_port(dev, i))
-				goto fail;
-		}
-		for (i = 0; i < PNP_MAX_MEM; i++) {
-			if (!pnp_check_mem(dev, i))
-				goto fail;
-		}
-		for (i = 0; i < PNP_MAX_IRQ; i++) {
-			if (!pnp_check_irq(dev, i))
-				goto fail;
-		}
-		for (i = 0; i < PNP_MAX_DMA; i++) {
-			if (!pnp_check_dma(dev, i))
-				goto fail;
-		}
-	}
-	mutex_unlock(&pnp_res_mutex);
-
-	kfree(bak);
-	return 0;
-
-fail:
-	dev->res = *bak;
-	mutex_unlock(&pnp_res_mutex);
-	kfree(bak);
-	return -EINVAL;
-}
-
-/**
  * pnp_auto_config_dev - automatically assigns resources to a device
  * @dev: pointer to the desired device
  */
@@ -573,24 +516,7 @@
 	return 0;
 }
 
-/**
- * pnp_resource_change - change one resource
- * @resource: pointer to resource to be changed
- * @start: start of region
- * @size: size of region
- */
-void pnp_resource_change(struct resource *resource, resource_size_t start,
-			 resource_size_t size)
-{
-	resource->flags &= ~(IORESOURCE_AUTO | IORESOURCE_UNSET);
-	resource->start = start;
-	resource->end = start + size - 1;
-}
-
-EXPORT_SYMBOL(pnp_manual_config_dev);
 EXPORT_SYMBOL(pnp_start_dev);
 EXPORT_SYMBOL(pnp_stop_dev);
 EXPORT_SYMBOL(pnp_activate_dev);
 EXPORT_SYMBOL(pnp_disable_dev);
-EXPORT_SYMBOL(pnp_resource_change);
-EXPORT_SYMBOL(pnp_init_resource_table);

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 35/37] rtc: dont reference pnp_resource_table directly
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (33 preceding siblings ...)
  2008-03-26 17:11 ` [patch 34/37] PNP: remove unused interfaces using pnp_resource_table Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 36/37] PNP: make pnp_resource_table private to PNP core Bjorn Helgaas
                   ` (2 subsequent siblings)
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: rtc-remove-pnp_resource_table-use --]
[-- Type: text/plain, Size: 920 bytes --]

pnp_resource_table is going away soon, so use the more
generic public interfaces instead.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/drivers/rtc/rtc-cmos.c
===================================================================
--- work7.orig/drivers/rtc/rtc-cmos.c	2008-03-25 17:04:44.000000000 -0600
+++ work7/drivers/rtc/rtc-cmos.c	2008-03-25 17:04:45.000000000 -0600
@@ -855,11 +855,12 @@
 		 * don't define the IRQ. It should always be safe to
 		 * hardcode it in these cases
 		 */
-		return cmos_do_probe(&pnp->dev, &pnp->res.port_resource[0], 8);
+		return cmos_do_probe(&pnp->dev,
+				pnp_get_resource(pnp, IORESOURCE_IO, 0), 8);
 	else
 		return cmos_do_probe(&pnp->dev,
-				     &pnp->res.port_resource[0],
-				     pnp->res.irq_resource[0].start);
+				pnp_get_resource(pnp, IORESOURCE_IO, 0),
+				pnp_irq(pnp, 0));
 }
 
 static void __exit cmos_pnp_remove(struct pnp_dev *pnp)

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 36/37] PNP: make pnp_resource_table private to PNP core
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (34 preceding siblings ...)
  2008-03-26 17:11 ` [patch 35/37] rtc: dont reference pnp_resource_table directly Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 17:11 ` [patch 37/37] PNP: make interfaces private to the " Bjorn Helgaas
  2008-03-26 22:42 ` [patch 00/37] PNP resource_table cleanups Len Brown
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-private-resource-table --]
[-- Type: text/plain, Size: 5485 bytes --]

There are no remaining references to the PNP_MAX_* constants or
the pnp_resource_table structure outside of the PNP core.  Make
them private to the PNP core.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

---
 drivers/pnp/base.h     |   12 ++++++++++++
 drivers/pnp/core.c     |    8 ++++++++
 drivers/pnp/manager.c  |    4 ++--
 drivers/pnp/resource.c |   10 +++++-----
 include/linux/pnp.h    |   14 ++------------
 5 files changed, 29 insertions(+), 19 deletions(-)

Index: work7/include/linux/pnp.h
===================================================================
--- work7.orig/include/linux/pnp.h	2008-03-26 11:10:33.000000000 -0600
+++ work7/include/linux/pnp.h	2008-03-26 11:10:34.000000000 -0600
@@ -13,14 +13,11 @@
 #include <linux/errno.h>
 #include <linux/mod_devicetable.h>
 
-#define PNP_MAX_PORT		40
-#define PNP_MAX_MEM		24
-#define PNP_MAX_IRQ		2
-#define PNP_MAX_DMA		2
 #define PNP_NAME_LEN		50
 
 struct pnp_protocol;
 struct pnp_dev;
+struct pnp_resource_table;
 
 /*
  * Resource Management
@@ -160,13 +157,6 @@
 	struct pnp_option *next;	/* used to chain dependent resources */
 };
 
-struct pnp_resource_table {
-	struct resource port_resource[PNP_MAX_PORT];
-	struct resource mem_resource[PNP_MAX_MEM];
-	struct resource dma_resource[PNP_MAX_DMA];
-	struct resource irq_resource[PNP_MAX_IRQ];
-};
-
 /*
  * Device Management
  */
@@ -236,7 +226,7 @@
 	int capabilities;
 	struct pnp_option *independent;
 	struct pnp_option *dependent;
-	struct pnp_resource_table res;
+	struct pnp_resource_table *res;
 
 	char name[PNP_NAME_LEN];	/* contains a human-readable name */
 	unsigned short regs;		/* ISAPnP: supported registers */
Index: work7/drivers/pnp/base.h
===================================================================
--- work7.orig/drivers/pnp/base.h	2008-03-26 11:10:26.000000000 -0600
+++ work7/drivers/pnp/base.h	2008-03-26 11:10:34.000000000 -0600
@@ -19,3 +19,15 @@
 int pnp_add_dma_resource(struct pnp_dev *dev, int dma, int flags);
 int pnp_add_io_resource(struct pnp_dev *dev, resource_size_t start, resource_size_t len, int flags);
 int pnp_add_mem_resource(struct pnp_dev *dev, resource_size_t start, resource_size_t len, int flags);
+
+#define PNP_MAX_PORT		40
+#define PNP_MAX_MEM		24
+#define PNP_MAX_IRQ		2
+#define PNP_MAX_DMA		2
+
+struct pnp_resource_table {
+	struct resource port_resource[PNP_MAX_PORT];
+	struct resource mem_resource[PNP_MAX_MEM];
+	struct resource dma_resource[PNP_MAX_DMA];
+	struct resource irq_resource[PNP_MAX_IRQ];
+};
Index: work7/drivers/pnp/manager.c
===================================================================
--- work7.orig/drivers/pnp/manager.c	2008-03-26 11:10:33.000000000 -0600
+++ work7/drivers/pnp/manager.c	2008-03-26 11:10:34.000000000 -0600
@@ -218,7 +218,7 @@
  */
 void pnp_init_resources(struct pnp_dev *dev)
 {
-	struct pnp_resource_table *table = &dev->res;
+	struct pnp_resource_table *table = dev->res;
 	int idx;
 
 	for (idx = 0; idx < PNP_MAX_IRQ; idx++) {
@@ -257,7 +257,7 @@
  */
 static void pnp_clean_resource_table(struct pnp_dev *dev)
 {
-	struct pnp_resource_table *res = &dev->res;
+	struct pnp_resource_table *res = dev->res;
 	int idx;
 
 	for (idx = 0; idx < PNP_MAX_IRQ; idx++) {
Index: work7/drivers/pnp/resource.c
===================================================================
--- work7.orig/drivers/pnp/resource.c	2008-03-26 11:10:32.000000000 -0600
+++ work7/drivers/pnp/resource.c	2008-03-26 11:10:34.000000000 -0600
@@ -493,7 +493,7 @@
 
 int pnp_add_irq_resource(struct pnp_dev *dev, int irq, int flags)
 {
-	struct pnp_resource_table *res = &dev->res;
+	struct pnp_resource_table *res = dev->res;
 	int i = 0;
 	static unsigned char warned;
 
@@ -517,7 +517,7 @@
 
 int pnp_add_dma_resource(struct pnp_dev *dev, int dma, int flags)
 {
-	struct pnp_resource_table *res = &dev->res;
+	struct pnp_resource_table *res = dev->res;
 	int i = 0;
 	static unsigned char warned;
 
@@ -541,7 +541,7 @@
 
 int pnp_add_io_resource(struct pnp_dev *dev, resource_size_t start, resource_size_t len, int flags)
 {
-	struct pnp_resource_table *res = &dev->res;
+	struct pnp_resource_table *res = dev->res;
 	resource_size_t end = start + len - 1;
 	int i = 0;
 	static unsigned char warned;
@@ -566,7 +566,7 @@
 
 int pnp_add_mem_resource(struct pnp_dev *dev, resource_size_t start, resource_size_t len, int flags)
 {
-	struct pnp_resource_table *res = &dev->res;
+	struct pnp_resource_table *res = dev->res;
 	int i = 0;
 	static unsigned char warned;
 
@@ -591,7 +591,7 @@
 struct resource *pnp_get_resource(struct pnp_dev *dev,
 				  unsigned int type, unsigned int num)
 {
-	struct pnp_resource_table *res = &dev->res;
+	struct pnp_resource_table *res = dev->res;
 
 	switch (type) {
 	case IORESOURCE_IO:
Index: work7/drivers/pnp/core.c
===================================================================
--- work7.orig/drivers/pnp/core.c	2008-03-26 10:54:04.000000000 -0600
+++ work7/drivers/pnp/core.c	2008-03-26 11:10:34.000000000 -0600
@@ -106,6 +106,7 @@
 	pnp_free_option(dev->independent);
 	pnp_free_option(dev->dependent);
 	pnp_free_ids(dev);
+	kfree(dev->res);
 	kfree(dev);
 }
 
@@ -118,6 +119,12 @@
 	if (!dev)
 		return NULL;
 
+	dev->res = kzalloc(sizeof(struct pnp_resource_table), GFP_KERNEL);
+	if (!dev->res) {
+		kfree(dev);
+		return NULL;
+	}
+
 	dev->protocol = protocol;
 	dev->number = id;
 
@@ -127,6 +134,7 @@
 
 	dev_id = pnp_add_id(dev, pnpid);
 	if (!dev_id) {
+		kfree(dev->res);
 		kfree(dev);
 		return NULL;
 	}

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 37/37] PNP: make interfaces private to the PNP core
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (35 preceding siblings ...)
  2008-03-26 17:11 ` [patch 36/37] PNP: make pnp_resource_table private to PNP core Bjorn Helgaas
@ 2008-03-26 17:11 ` Bjorn Helgaas
  2008-03-26 22:42 ` [patch 00/37] PNP resource_table cleanups Len Brown
  37 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 17:11 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-make-interfaces-private --]
[-- Type: text/plain, Size: 6660 bytes --]

The interfaces for registering protocols, devices, cards,
and resource options should only be used inside the PNP core.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

---
 drivers/pnp/base.h  |   24 +++++++++++++++++++++++-
 include/linux/pnp.h |   34 ----------------------------------
 2 files changed, 23 insertions(+), 35 deletions(-)

Index: work7/include/linux/pnp.h
===================================================================
--- work7.orig/include/linux/pnp.h	2008-03-25 15:28:23.000000000 -0600
+++ work7/include/linux/pnp.h	2008-03-25 15:37:32.000000000 -0600
@@ -390,19 +390,12 @@
 #if defined(CONFIG_PNP)
 
 /* device management */
-int pnp_register_protocol(struct pnp_protocol *protocol);
-void pnp_unregister_protocol(struct pnp_protocol *protocol);
-int pnp_add_device(struct pnp_dev *dev);
 int pnp_device_attach(struct pnp_dev *pnp_dev);
 void pnp_device_detach(struct pnp_dev *pnp_dev);
 extern struct list_head pnp_global;
 extern int pnp_platform_devices;
 
 /* multidevice card support */
-int pnp_add_card(struct pnp_card *card);
-void pnp_remove_card(struct pnp_card *card);
-int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev);
-void pnp_remove_card_device(struct pnp_dev *dev);
 struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
 					const char *id, struct pnp_dev *from);
 void pnp_release_card_device(struct pnp_dev *dev);
@@ -411,23 +404,12 @@
 extern struct list_head pnp_cards;
 
 /* resource management */
-struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev);
-struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev,
-						 int priority);
-int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data);
-int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data);
-int pnp_register_port_resource(struct pnp_option *option,
-			       struct pnp_port *data);
-int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data);
-void pnp_init_resources(struct pnp_dev *dev);
 int pnp_auto_config_dev(struct pnp_dev *dev);
-int pnp_validate_config(struct pnp_dev *dev);
 int pnp_start_dev(struct pnp_dev *dev);
 int pnp_stop_dev(struct pnp_dev *dev);
 int pnp_activate_dev(struct pnp_dev *dev);
 int pnp_disable_dev(struct pnp_dev *dev);
 
-
 /* protocol helpers */
 int pnp_is_active(struct pnp_dev *dev);
 int compare_pnp_id(struct pnp_id *pos, const char *id);
@@ -437,35 +419,19 @@
 #else
 
 /* device management */
-static inline int pnp_register_protocol(struct pnp_protocol *protocol) { return -ENODEV; }
-static inline void pnp_unregister_protocol(struct pnp_protocol *protocol) { }
-static inline int pnp_init_device(struct pnp_dev *dev) { return -ENODEV; }
-static inline int pnp_add_device(struct pnp_dev *dev) { return -ENODEV; }
 static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; }
 static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { }
 
 #define pnp_platform_devices 0
 
 /* multidevice card support */
-static inline int pnp_add_card(struct pnp_card *card) { return -ENODEV; }
-static inline void pnp_remove_card(struct pnp_card *card) { }
-static inline int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev) { return -ENODEV; }
-static inline void pnp_remove_card_device(struct pnp_dev *dev) { }
 static inline struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, const char *id, struct pnp_dev *from) { return NULL; }
 static inline void pnp_release_card_device(struct pnp_dev *dev) { }
 static inline int pnp_register_card_driver(struct pnp_card_driver *drv) { return -ENODEV; }
 static inline void pnp_unregister_card_driver(struct pnp_card_driver *drv) { }
 
 /* resource management */
-static inline struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev) { return NULL; }
-static inline struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev, int priority) { return NULL; }
-static inline int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data) { return -ENODEV; }
-static inline int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data) { return -ENODEV; }
-static inline int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data) { return -ENODEV; }
-static inline int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data) { return -ENODEV; }
-static inline void pnp_init_resources(struct pnp_dev *dev) { }
 static inline int pnp_auto_config_dev(struct pnp_dev *dev) { return -ENODEV; }
-static inline int pnp_validate_config(struct pnp_dev *dev) { return -ENODEV; }
 static inline int pnp_start_dev(struct pnp_dev *dev) { return -ENODEV; }
 static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; }
 static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; }
Index: work7/drivers/pnp/base.h
===================================================================
--- work7.orig/drivers/pnp/base.h	2008-03-25 15:28:29.000000000 -0600
+++ work7/drivers/pnp/base.h	2008-03-25 15:32:05.000000000 -0600
@@ -1,10 +1,32 @@
 extern spinlock_t pnp_lock;
 void *pnp_alloc(long size);
+
+int pnp_register_protocol(struct pnp_protocol *protocol);
+void pnp_unregister_protocol(struct pnp_protocol *protocol);
+
 struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *, int id, char *pnpid);
 struct pnp_card *pnp_alloc_card(struct pnp_protocol *, int id, char *pnpid);
+
+int pnp_add_device(struct pnp_dev *dev);
 struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id);
-struct pnp_id *pnp_add_card_id(struct pnp_card *card, char *id);
 int pnp_interface_attach_device(struct pnp_dev *dev);
+
+int pnp_add_card(struct pnp_card *card);
+struct pnp_id *pnp_add_card_id(struct pnp_card *card, char *id);
+void pnp_remove_card(struct pnp_card *card);
+int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev);
+void pnp_remove_card_device(struct pnp_dev *dev);
+
+struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev);
+struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev,
+						 int priority);
+int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data);
+int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data);
+int pnp_register_port_resource(struct pnp_option *option,
+			       struct pnp_port *data);
+int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data);
+void pnp_init_resources(struct pnp_dev *dev);
+
 void pnp_fixup_device(struct pnp_dev *dev);
 void pnp_free_option(struct pnp_option *option);
 int __pnp_add_device(struct pnp_dev *dev);

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [patch 00/37] PNP resource_table cleanups
  2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
                   ` (36 preceding siblings ...)
  2008-03-26 17:11 ` [patch 37/37] PNP: make interfaces private to the " Bjorn Helgaas
@ 2008-03-26 22:42 ` Len Brown
  2008-03-26 23:13   ` Bjorn Helgaas
  37 siblings, 1 reply; 50+ messages in thread
From: Len Brown @ 2008-03-26 22:42 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

i386:

#1 errs.ACPI.ACPI_DEBUG.ACPI_PROCFS.HIBERNATION.X86_LOCAL_APIC.X86_IO_APIC
Cleaning...Building...
ERROR: "pnp_get_resource" [sound/oss/sb.ko] undefined!
ERROR: "pnp_get_resource" [sound/oss/ad1848.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/wavefront/snd-wavefront.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/snd-sscape.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/snd-opl3sa2.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/snd-es18xx.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/snd-dt019x.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/snd-cmi8330.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/snd-azt2320.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/snd-als100.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/sb/snd-sbawe.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/sb/snd-sb16.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/sb/snd-es968.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/opti9xx/snd-opti93x.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/opti9xx/snd-opti92x-cs4231.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/opti9xx/snd-opti92x-ad1848.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/gus/snd-interwave.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/gus/snd-interwave-stb.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/cs423x/snd-cs4236.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/cs423x/snd-cs4232.ko] undefined!
ERROR: "pnp_get_resource" [sound/isa/ad1816a/snd-ad1816a.ko] undefined!
ERROR: "pnp_get_resource" [sound/drivers/mpu401/snd-mpu401.ko] undefined!
ERROR: "pnp_get_resource" [drivers/watchdog/sc1200wdt.ko] undefined!
ERROR: "pnp_get_resource" [drivers/telephony/ixj.ko] undefined!
ERROR: "pnp_get_resource" [drivers/scsi/sym53c416.ko] undefined!
ERROR: "pnp_get_resource" [drivers/scsi/g_NCR5380_mmio.ko] undefined!
ERROR: "pnp_get_resource" [drivers/scsi/g_NCR5380.ko] undefined!
ERROR: "pnp_get_resource" [drivers/scsi/aha1542.ko] undefined!
ERROR: "pnp_get_resource" [drivers/scsi/aha152x.ko] undefined!
ERROR: "pnp_get_resource" [drivers/pcmcia/i82365.ko] undefined!
ERROR: "pnp_get_resource" [drivers/parport/parport_pc.ko] undefined!
ERROR: "pnp_get_resource" [drivers/net/smc-ultra.ko] undefined!
ERROR: "pnp_get_resource" [drivers/net/sb1000.ko] undefined!
ERROR: "pnp_get_resource" [drivers/net/ne.ko] undefined!
ERROR: "pnp_get_resource" [drivers/net/irda/smsc-ircc2.ko] undefined!
ERROR: "pnp_get_resource" [drivers/net/irda/nsc-ircc.ko] undefined!
ERROR: "pnp_get_resource" [drivers/net/3c515.ko] undefined!
ERROR: "pnp_get_resource" [drivers/net/3c509.ko] undefined!
ERROR: "pnp_get_resource" [drivers/mmc/host/wbsd.ko] undefined!
ERROR: "pnp_get_resource" [drivers/media/radio/radio-sf16fmi.ko] undefined!
ERROR: "pnp_get_resource" [drivers/media/radio/radio-cadet.ko] undefined!
ERROR: "pnp_get_resource" [drivers/isdn/hisax/hisax_fcpcipnp.ko] undefined!
ERROR: "pnp_get_resource" [drivers/isdn/hisax/hisax.ko] undefined!
ERROR: "pnp_get_resource" [drivers/input/gameport/ns558.ko] undefined!
ERROR: "pnp_get_resource" [drivers/ide/ide-pnp.ko] undefined!
ERROR: "pnp_get_resource" [drivers/char/tpm/tpm_tis.ko] undefined!
ERROR: "pnp_get_resource" [drivers/char/tpm/tpm_infineon.ko] undefined!
Build FAILED

x86_64:

#33 errs.allmodconfig
Cleaning...Building...
ERROR: "pnp_get_resource" [sound/oss/sb.ko] undefined!
ERROR: "pnp_get_resource" [sound/drivers/mpu401/snd-mpu401.ko] undefined!
ERROR: "pnp_get_resource" [drivers/watchdog/sc1200wdt.ko] undefined!
ERROR: "pnp_get_resource" [drivers/serial/8250_pnp.ko] undefined!
ERROR: "pnp_get_resource" [drivers/rtc/rtc-cmos.ko] undefined!
ERROR: "pnp_get_resource" [drivers/parport/parport_pc.ko] undefined!
ERROR: "pnp_get_resource" [drivers/net/sb1000.ko] undefined!
ERROR: "pnp_get_resource" [drivers/net/irda/smsc-ircc2.ko] undefined!
ERROR: "pnp_get_resource" [drivers/net/irda/nsc-ircc.ko] undefined!
ERROR: "pnp_get_resource" [drivers/mmc/host/wbsd.ko] undefined!
ERROR: "pnp_get_resource" [drivers/input/serio/i8042.ko] undefined!
ERROR: "pnp_get_resource" [drivers/input/gameport/ns558.ko] undefined!
ERROR: "pnp_get_resource" [drivers/ide/ide-pnp.ko] undefined!
ERROR: "pnp_get_resource" [drivers/char/tpm/tpm_tis.ko] undefined!
ERROR: "pnp_get_resource" [drivers/char/tpm/tpm_infineon.ko] undefined!
Build FAILED


ia64:

#9 errs.allmodconfig
Cleaning...Building...
ERROR: "pnp_get_resource" [sound/drivers/mpu401/snd-mpu401.ko] undefined!
ERROR: "pnp_get_resource" [drivers/serial/8250_pnp.ko] undefined!
ERROR: "pnp_get_resource" [drivers/parport/parport_pc.ko] undefined!
ERROR: "pnp_get_resource" [drivers/net/sb1000.ko] undefined!
ERROR: "pnp_get_resource" [drivers/input/serio/i8042.ko] undefined!
ERROR: "pnp_get_resource" [drivers/input/gameport/ns558.ko] undefined!
ERROR: "pnp_get_resource" [drivers/ide/ide-pnp.ko] undefined!
ERROR: "pnp_get_resource" [drivers/char/tpm/tpm_tis.ko] undefined!
ERROR: "pnp_get_resource" [drivers/char/tpm/tpm_infineon.ko] undefined!
Build FAILED

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [patch 00/37] PNP resource_table cleanups
  2008-03-26 22:42 ` [patch 00/37] PNP resource_table cleanups Len Brown
@ 2008-03-26 23:13   ` Bjorn Helgaas
  2008-03-27  0:30     ` Rene Herman
  0 siblings, 1 reply; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 23:13 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

On Wednesday 26 March 2008 04:42:10 pm Len Brown wrote:
> i386:
> 
> #1 errs.ACPI.ACPI_DEBUG.ACPI_PROCFS.HIBERNATION.X86_LOCAL_APIC.X86_IO_APIC
> Cleaning...Building...
> ERROR: "pnp_get_resource" [sound/oss/sb.ko] undefined!
> ERROR: "pnp_get_resource" [sound/oss/ad1848.ko] undefined!

Oops, sorry, I forgot to export pnp_get_resource().  I'll post an
updated patch as a response to the original.  Is that easy for you
to handle, Len?  If not, let me know what you'd prefer.

Bjorn


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [patch 28/37] PNP: add pnp_get_resource() interface
  2008-03-26 17:11 ` [patch 28/37] PNP: add pnp_get_resource() interface Bjorn Helgaas
@ 2008-03-26 23:15   ` Bjorn Helgaas
  0 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-26 23:15 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

PNP: add pnp_get_resource() interface

This adds a pnp_get_resource() that works the same way as
platform_get_resource().  This will enable us to consolidate
many pnp_resource_table references in one place, which will
make it easier to make the table dynamic.

I used EXPORT_SYMBOL, not EXPORT_SYMBOL_GPL, because it doesn't
seem right to break existing non-GPL PNP drivers.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

---
 drivers/pnp/resource.c |   27 +++++++++++++++++++++++++++
 include/linux/pnp.h    |    1 +
 2 files changed, 28 insertions(+)

Index: work7/include/linux/pnp.h
===================================================================
--- work7.orig/include/linux/pnp.h	2008-03-26 11:10:22.000000000 -0600
+++ work7/include/linux/pnp.h	2008-03-26 16:50:05.000000000 -0600
@@ -25,6 +25,7 @@
 /*
  * Resource Management
  */
+struct resource *pnp_get_resource(struct pnp_dev *, unsigned int, unsigned int);
 
 /* Use these instead of directly reading pnp_dev to get resource information */
 #define pnp_port_start(dev,bar)   ((dev)->res.port_resource[(bar)].start)
Index: work7/drivers/pnp/resource.c
===================================================================
--- work7.orig/drivers/pnp/resource.c	2008-03-26 11:10:29.000000000 -0600
+++ work7/drivers/pnp/resource.c	2008-03-26 16:50:42.000000000 -0600
@@ -560,6 +560,33 @@
 	return 0;
 }
 
+struct resource *pnp_get_resource(struct pnp_dev *dev,
+				  unsigned int type, unsigned int num)
+{
+	struct pnp_resource_table *res = &dev->res;
+
+	switch (type) {
+	case IORESOURCE_IO:
+		if (num >= PNP_MAX_PORT)
+			return NULL;
+		return &res->port_resource[num];
+	case IORESOURCE_MEM:
+		if (num >= PNP_MAX_MEM)
+			return NULL;
+		return &res->mem_resource[num];
+	case IORESOURCE_IRQ:
+		if (num >= PNP_MAX_IRQ)
+			return NULL;
+		return &res->irq_resource[num];
+	case IORESOURCE_DMA:
+		if (num >= PNP_MAX_DMA)
+			return NULL;
+		return &res->dma_resource[num];
+	}
+	return NULL;
+}
+EXPORT_SYMBOL(pnp_get_resource);
+
 /* format is: pnp_reserve_irq=irq1[,irq2] .... */
 static int __init pnp_setup_reserve_irq(char *str)
 {

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [patch 00/37] PNP resource_table cleanups
  2008-03-26 23:13   ` Bjorn Helgaas
@ 2008-03-27  0:30     ` Rene Herman
  2008-03-27 17:50       ` Bjorn Helgaas
  0 siblings, 1 reply; 50+ messages in thread
From: Rene Herman @ 2008-03-27  0:30 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Len Brown, linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Jaroslav Kysela,
	Andrew Morton

On 27-03-08 00:13, Bjorn Helgaas wrote:

> Oops, sorry, I forgot to export pnp_get_resource().  I'll post an updated
> patch as a response to the original.  Is that easy for you to handle,
> Len?  If not, let me know what you'd prefer.

Works for me at least. Only had time for a quick test. After applying these, 
my snd-cs4236 driver ISAPnP soundcard is no longer found.

Rene.


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [patch 00/37] PNP resource_table cleanups
  2008-03-27  0:30     ` Rene Herman
@ 2008-03-27 17:50       ` Bjorn Helgaas
  2008-03-31 19:40         ` Rene Herman
  0 siblings, 1 reply; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-27 17:50 UTC (permalink / raw)
  To: Rene Herman
  Cc: Len Brown, linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Jaroslav Kysela,
	Andrew Morton

On Wednesday 26 March 2008 06:30:16 pm Rene Herman wrote:
> On 27-03-08 00:13, Bjorn Helgaas wrote:
> 
> > Oops, sorry, I forgot to export pnp_get_resource().  I'll post an updated
> > patch as a response to the original.  Is that easy for you to handle,
> > Len?  If not, let me know what you'd prefer.
> 
> Works for me at least. Only had time for a quick test. After applying these, 
> my snd-cs4236 driver ISAPnP soundcard is no longer found.

Are any ISAPNP devices at all found?  It's possible I broke ISAPNP
completely, because I don't have anything to test it with.  If you
have a chance, maybe you could turn on CONFIG_PNP_DEBUG and send me
a dmesg log.

Bjorn

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [patch 00/37] PNP resource_table cleanups
  2008-03-27 17:50       ` Bjorn Helgaas
@ 2008-03-31 19:40         ` Rene Herman
  2008-03-31 19:48           ` Rene Herman
  2008-03-31 20:51           ` Bjorn Helgaas
  0 siblings, 2 replies; 50+ messages in thread
From: Rene Herman @ 2008-03-31 19:40 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Len Brown, linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: Type: text/plain, Size: 1033 bytes --]

On 27-03-08 18:50, Bjorn Helgaas wrote:

> Are any ISAPNP devices at all found?

Yes, but at most 100 * 10^4 / 2^16 percent of them. Trouble is in 04/37:

http://lkml.org/lkml/2008/3/26/273

The numeric part of the ID is a 4-digit hexadecimal value, not just decimal, 
so '0'+ don't work. Unfortunately, that one has a few dependents, so you'll 
probably want to restructure things yourself. If I just place the attached 
on top, the card's found again.

Not too much avail unfortunately, as I then get a resource assignment 
problem with your patches:

pnp: the driver 'cs4236_isapnp' has been registered
cs4236_isapnp 01:01.00: driver attached
cs4236_isapnp 01:01.02: driver attached
cs4236_isapnp 01:01.03: driver attached
cs4236_isapnp 01:01.00: unable to assign resources
CS4236+ WSS PnP configure failed for WSS (out of resources?)
isapnp detection failed and probing for CS4236+ is not supported

(and exact same thing for snd-es18xx) which I'll try to look at next, but 
this ID thing will certainly need a fix first.

Rene.

[-- Attachment #2: isapnp_to_pnpid.diff --]
[-- Type: text/plain, Size: 914 bytes --]

diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index c4b95b5..0a41e05 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -403,14 +403,12 @@ static void __init isapnp_skip_bytes(int count)
 static void isapnp_to_pnpid(unsigned short vendor, unsigned short device,
 			    char *id)
 {
-	id[0] = 'A' + ((vendor >> 2) & 0x3f) - 1;
-	id[1] = 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1;
-	id[2] = 'A' + ((vendor >> 8) & 0x1f) - 1;
-	id[3] = '0' + ((device >> 4) & 0x0f);
-	id[4] = '0' + (device & 0x0f);
-	id[5] = '0' + ((device >> 12) & 0x0f);
-	id[6] = '0' + ((device >> 8) & 0x0f);
-	id[7] = '\0';
+	sprintf(id, "%c%c%c%x%x%x%x",
+		'A' + ((vendor >> 2) & 0x3f) - 1,
+		'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1,
+		'A' + ((vendor >> 8) & 0x1f) - 1,
+		(device >> 4) & 0x0f, device & 0x0f,
+		(device >> 12) & 0x0f, (device >> 8) & 0x0f);
 }
 
 /*

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* Re: [patch 00/37] PNP resource_table cleanups
  2008-03-31 19:40         ` Rene Herman
@ 2008-03-31 19:48           ` Rene Herman
  2008-03-31 20:51           ` Bjorn Helgaas
  1 sibling, 0 replies; 50+ messages in thread
From: Rene Herman @ 2008-03-31 19:48 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Len Brown, linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Jaroslav Kysela,
	Andrew Morton

On 31-03-08 21:40, Rene Herman wrote:

> On 27-03-08 18:50, Bjorn Helgaas wrote:
> 
>> Are any ISAPNP devices at all found?
> 
> Yes, but at most 100 * 10^4 / 2^16 percent of them. Trouble is in 04/37:

Well, that should read "Yes, no less than 100 * 10^4 / 2^16 percent of them 
even" but you get the point...

Rene.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [patch 00/37] PNP resource_table cleanups
  2008-03-31 19:40         ` Rene Herman
  2008-03-31 19:48           ` Rene Herman
@ 2008-03-31 20:51           ` Bjorn Helgaas
  2008-03-31 21:38             ` Rene Herman
  1 sibling, 1 reply; 50+ messages in thread
From: Bjorn Helgaas @ 2008-03-31 20:51 UTC (permalink / raw)
  To: Rene Herman
  Cc: Len Brown, linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Jaroslav Kysela,
	Andrew Morton

On Monday 31 March 2008 01:40:03 pm Rene Herman wrote:
> On 27-03-08 18:50, Bjorn Helgaas wrote:
> 
> > Are any ISAPNP devices at all found?
> 
> Yes, but at most 100 * 10^4 / 2^16 percent of them. Trouble is in 04/37:
> 
> http://lkml.org/lkml/2008/3/26/273
> 
> The numeric part of the ID is a 4-digit hexadecimal value, not just decimal, 
> so '0'+ don't work. Unfortunately, that one has a few dependents, so you'll 
> probably want to restructure things yourself. If I just place the attached 
> on top, the card's found again.

Ah, right.  Thanks for tracking that down.  I forgot to factor out
isapnp_to_pnpid() and pnpid32_to_pnpid() (and acpi_ex_eisa_id_to_string()
for that matter, though that's buried in the ACPI CA)-- they're really
doing the same thing and we should only need one copy (plus the CA
one).

> Not too much avail unfortunately, as I then get a resource assignment 
> problem with your patches:
> 
> pnp: the driver 'cs4236_isapnp' has been registered
> cs4236_isapnp 01:01.00: driver attached
> cs4236_isapnp 01:01.02: driver attached
> cs4236_isapnp 01:01.03: driver attached
> cs4236_isapnp 01:01.00: unable to assign resources
> CS4236+ WSS PnP configure failed for WSS (out of resources?)
> isapnp detection failed and probing for CS4236+ is not supported
> 
> (and exact same thing for snd-es18xx) which I'll try to look at next, but 
> this ID thing will certainly need a fix first.

Hmmm...  that sounds harder.  I'll read over it again and see if I
can figure anything out.

Bjorn


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [patch 00/37] PNP resource_table cleanups
  2008-03-31 20:51           ` Bjorn Helgaas
@ 2008-03-31 21:38             ` Rene Herman
  2008-04-01 10:16               ` Rene Herman
  0 siblings, 1 reply; 50+ messages in thread
From: Rene Herman @ 2008-03-31 21:38 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Len Brown, linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: Type: text/plain, Size: 649 bytes --]

On 31-03-08 22:51, Bjorn Helgaas wrote:

> Ah, right.  Thanks for tracking that down.  I forgot to factor out
> isapnp_to_pnpid() and pnpid32_to_pnpid() (and acpi_ex_eisa_id_to_string()
> for that matter, though that's buried in the ACPI CA)-- they're really
> doing the same thing and we should only need one copy (plus the CA
> one).

I'll wait for another round then, before reviewing this further.

> Hmmm...  that sounds harder.  I'll read over it again and see if I
> can figure anything out.

Actually, other than looking right past it a few dozen times, it's fairly 
evident. If I apply the attached, my soundcard's functional again.

Rene.

[-- Attachment #2: pnp_check_resource.diff --]
[-- Type: text/plain, Size: 1463 bytes --]

diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index 454290b..9ff76dc 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -261,7 +261,7 @@ int pnp_check_port(struct pnp_dev *dev, int idx)
 		if (tdev == dev)
 			continue;
 		for (i = 0;
-		     (tres = pnp_get_resource(dev, IORESOURCE_IO, i));
+		     (tres = pnp_get_resource(tdev, IORESOURCE_IO, i));
 		     i++) {
 			if (tres->flags & IORESOURCE_IO) {
 				if (cannot_compare(tres->flags))
@@ -325,7 +325,7 @@ int pnp_check_mem(struct pnp_dev *dev, int idx)
 		if (tdev == dev)
 			continue;
 		for (i = 0;
-		     (tres = pnp_get_resource(dev, IORESOURCE_MEM, i));
+		     (tres = pnp_get_resource(tdev, IORESOURCE_MEM, i));
 		     i++) {
 			if (tres->flags & IORESOURCE_MEM) {
 				if (cannot_compare(tres->flags))
@@ -408,7 +408,7 @@ int pnp_check_irq(struct pnp_dev *dev, int idx)
 		if (tdev == dev)
 			continue;
 		for (i = 0;
-		     (tres = pnp_get_resource(dev, IORESOURCE_IRQ, i));
+		     (tres = pnp_get_resource(tdev, IORESOURCE_IRQ, i));
 		     i++) {
 			if (tres->flags & IORESOURCE_IRQ) {
 				if (cannot_compare(tres->flags))
@@ -471,7 +471,7 @@ int pnp_check_dma(struct pnp_dev *dev, int idx)
 		if (tdev == dev)
 			continue;
 		for (i = 0;
-		     (tres = pnp_get_resource(dev, IORESOURCE_DMA, i));
+		     (tres = pnp_get_resource(tdev, IORESOURCE_DMA, i));
 		     i++) {
 			if (tres->flags & IORESOURCE_DMA) {
 				if (cannot_compare(tres->flags))

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* Re: [patch 00/37] PNP resource_table cleanups
  2008-03-31 21:38             ` Rene Herman
@ 2008-04-01 10:16               ` Rene Herman
  2008-04-01 14:52                 ` Bjorn Helgaas
  0 siblings, 1 reply; 50+ messages in thread
From: Rene Herman @ 2008-04-01 10:16 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Len Brown, linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: Type: text/plain, Size: 579 bytes --]

On 31-03-08 23:38, Rene Herman wrote:
> On 31-03-08 22:51, Bjorn Helgaas wrote:
> 
>> Ah, right.  Thanks for tracking that down.  I forgot to factor out
>> isapnp_to_pnpid() and pnpid32_to_pnpid() (and acpi_ex_eisa_id_to_string()
>> for that matter, though that's buried in the ACPI CA)-- they're really
>> doing the same thing and we should only need one copy (plus the CA
>> one).
> 
> I'll wait for another round then, before reviewing this further.

There's actually a hex_asc() helper in kernel.h, so before you overlook it 
as well, this is a somewhat nicer ID fix.

Rene.

[-- Attachment #2: isapnp_to_pnpid2.diff --]
[-- Type: text/plain, Size: 926 bytes --]

commit cfed76bc2a76f2094338bc43dae55aa814017b5f
Author: Rene Herman <rene.herman@gmail.com>
Date:   Tue Apr 1 12:03:15 2008 +0200

    [ISAPNP] fix isapnp_to_pnpid

diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index c4b95b5..9727050 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -406,11 +406,11 @@ static void isapnp_to_pnpid(unsigned short vendor, unsigned short device,
 	id[0] = 'A' + ((vendor >> 2) & 0x3f) - 1;
 	id[1] = 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1;
 	id[2] = 'A' + ((vendor >> 8) & 0x1f) - 1;
-	id[3] = '0' + ((device >> 4) & 0x0f);
-	id[4] = '0' + (device & 0x0f);
-	id[5] = '0' + ((device >> 12) & 0x0f);
-	id[6] = '0' + ((device >> 8) & 0x0f);
-	id[7] = '\0';
+	id[3] = hex_asc((device >> 4) & 0x0f);
+	id[4] = hex_asc(device & 0x0f);
+	id[5] = hex_asc((device >> 12) & 0x0f);
+	id[6] = hex_asc((device >> 8) & 0x0f);
+	id[7] = 0;
 }
 
 /*

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* Re: [patch 00/37] PNP resource_table cleanups
  2008-04-01 10:16               ` Rene Herman
@ 2008-04-01 14:52                 ` Bjorn Helgaas
  0 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-04-01 14:52 UTC (permalink / raw)
  To: Rene Herman
  Cc: Len Brown, linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Jaroslav Kysela,
	Andrew Morton

On Tuesday 01 April 2008 04:16:10 am Rene Herman wrote:
> On 31-03-08 23:38, Rene Herman wrote:
> > On 31-03-08 22:51, Bjorn Helgaas wrote:
> > 
> >> Ah, right.  Thanks for tracking that down.  I forgot to factor out
> >> isapnp_to_pnpid() and pnpid32_to_pnpid() (and acpi_ex_eisa_id_to_string()
> >> for that matter, though that's buried in the ACPI CA)-- they're really
> >> doing the same thing and we should only need one copy (plus the CA
> >> one).
> > 
> > I'll wait for another round then, before reviewing this further.
> 
> There's actually a hex_asc() helper in kernel.h, so before you overlook it 
> as well, this is a somewhat nicer ID fix.

Thanks, I didn't know about hex_asc()!  I'll post v2 of the series today.
And thanks a lot for finding those typos in resource.c.  I never would
have found those...

Bjorn

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [patch 03/37] PNP: make pnp_add_id() internal to PNP core
  2008-04-01 15:16 [patch 00/37] PNP resource_table cleanups, v2 Bjorn Helgaas
@ 2008-04-01 15:16 ` Bjorn Helgaas
  0 siblings, 0 replies; 50+ messages in thread
From: Bjorn Helgaas @ 2008-04-01 15:16 UTC (permalink / raw)
  To: Len Brown
  Cc: linux-acpi, linux-kernel, Adam Belay, Li Shaohua,
	Matthieu Castet, Thomas Renninger, Rene Herman, Jaroslav Kysela,
	Andrew Morton

[-- Attachment #1: pnp-make-pnp_add_id-internal-to-core --]
[-- Type: text/plain, Size: 2461 bytes --]

pnp_add_id() doesn't need to be exposed outside the PNP core, so
move the declaration to an internal header file.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work7/include/linux/pnp.h
===================================================================
--- work7.orig/include/linux/pnp.h	2008-03-21 13:31:06.000000000 -0600
+++ work7/include/linux/pnp.h	2008-03-21 13:31:08.000000000 -0600
@@ -403,7 +403,6 @@
 /* protocol helpers */
 int pnp_is_active(struct pnp_dev *dev);
 int compare_pnp_id(struct pnp_id *pos, const char *id);
-int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev);
 int pnp_register_driver(struct pnp_driver *drv);
 void pnp_unregister_driver(struct pnp_driver *drv);
 
@@ -450,7 +449,6 @@
 /* protocol helpers */
 static inline int pnp_is_active(struct pnp_dev *dev) { return 0; }
 static inline int compare_pnp_id(struct pnp_id *pos, const char *id) { return -ENODEV; }
-static inline int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev) { return -ENODEV; }
 static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; }
 static inline void pnp_unregister_driver(struct pnp_driver *drv) { }
 
Index: work7/drivers/pnp/base.h
===================================================================
--- work7.orig/drivers/pnp/base.h	2008-03-21 13:31:06.000000000 -0600
+++ work7/drivers/pnp/base.h	2008-03-21 13:31:39.000000000 -0600
@@ -1,5 +1,6 @@
 extern spinlock_t pnp_lock;
 void *pnp_alloc(long size);
+int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev);
 int pnp_interface_attach_device(struct pnp_dev *dev);
 void pnp_fixup_device(struct pnp_dev *dev);
 void pnp_free_option(struct pnp_option *option);
Index: work7/drivers/pnp/pnpacpi/core.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/core.c	2008-03-21 13:31:06.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/core.c	2008-03-21 13:31:08.000000000 -0600
@@ -25,6 +25,7 @@
 #include <acpi/acpi_bus.h>
 #include <acpi/actypes.h>
 
+#include "../base.h"
 #include "pnpacpi.h"
 
 static int num = 0;
Index: work7/drivers/pnp/pnpbios/core.c
===================================================================
--- work7.orig/drivers/pnp/pnpbios/core.c	2008-03-21 13:31:06.000000000 -0600
+++ work7/drivers/pnp/pnpbios/core.c	2008-03-21 13:31:08.000000000 -0600
@@ -69,6 +69,7 @@
 #include <asm/system.h>
 #include <asm/byteorder.h>
 
+#include "../base.h"
 #include "pnpbios.h"
 
 /*

-- 

^ permalink raw reply	[flat|nested] 50+ messages in thread

end of thread, other threads:[~2008-04-01 15:20 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
2008-03-26 17:10 ` [patch 01/37] ISAPNP: move config register addresses out of isapnp.h Bjorn Helgaas
2008-03-26 17:11 ` [patch 02/37] PNPACPI: continue after _CRS and _PRS errors Bjorn Helgaas
2008-03-26 17:11 ` [patch 03/37] PNP: make pnp_add_id() internal to PNP core Bjorn Helgaas
2008-03-26 17:11 ` [patch 04/37] PNP: change pnp_add_id() to allocate its own pnp_id structures Bjorn Helgaas
2008-03-26 17:11 ` [patch 05/37] ISAPNP: pull pnp_add_id() out of isapnp_parse_id() Bjorn Helgaas
2008-03-26 17:11 ` [patch 06/37] PNP: add pnp_alloc_dev() Bjorn Helgaas
2008-03-26 17:11 ` [patch 07/37] PNP: make pnp_add_card_id() internal to PNP core Bjorn Helgaas
2008-03-26 17:11 ` [patch 08/37] PNP: change pnp_add_card_id() to allocate its own pnp_id structures Bjorn Helgaas
2008-03-26 17:11 ` [patch 09/37] ISAPNP: pull pnp_add_card_id() out of isapnp_parse_card_id() Bjorn Helgaas
2008-03-26 17:11 ` [patch 10/37] PNP: add pnp_alloc_card() Bjorn Helgaas
2008-03-26 17:11 ` [patch 11/37] PNPACPI: pnpacpi_encode_ext_irq() wrongly set "irq" instead of "extended_irq" Bjorn Helgaas
2008-03-26 17:11 ` [patch 12/37] PNPACPI: use temporaries to reduce repetition Bjorn Helgaas
2008-03-26 17:11 ` [patch 13/37] PNPACPI: hoist dma_flags() out of pnpacpi_parse_allocated_dmaresource() Bjorn Helgaas
2008-03-26 17:11 ` [patch 14/37] PNPACPI: extend irq_flags() to set IORESOURCE_IRQ_SHAREABLE when appropriate Bjorn Helgaas
2008-03-26 17:11 ` [patch 15/37] PNPACPI: pass pnp_dev instead of acpi_handle Bjorn Helgaas
2008-03-26 17:11 ` [patch 16/37] PNP: remove pnp_resource_table from internal get/set interfaces Bjorn Helgaas
2008-03-26 17:11 ` [patch 17/37] PNP: remove more pnp_resource_table arguments Bjorn Helgaas
2008-03-26 17:11 ` [patch 18/37] PNP: add pnp_init_resources(struct pnp_dev *) interface Bjorn Helgaas
2008-03-26 17:11 ` [patch 19/37] PNP: remove pnp_resource_table from internal pnp_clean_resource_table interface Bjorn Helgaas
2008-03-26 17:11 ` [patch 20/37] PNP: make generic pnp_add_irq_resource() Bjorn Helgaas
2008-03-26 17:11 ` [patch 21/37] PNP: make generic pnp_add_dma_resource() Bjorn Helgaas
2008-03-26 17:11 ` [patch 22/37] PNP: make generic pnp_add_io_resource() Bjorn Helgaas
2008-03-26 17:11 ` [patch 23/37] PNP: make generic pnp_add_mem_resource() Bjorn Helgaas
2008-03-26 17:11 ` [patch 24/37] PNP: use dev_printk when possible Bjorn Helgaas
2008-03-26 17:11 ` [patch 25/37] PNPACPI: remove redundant warnings about _CRS/_PRS failures Bjorn Helgaas
2008-03-26 17:11 ` [patch 26/37] PNPACPI: remove some pnp_dbg calls Bjorn Helgaas
2008-03-26 17:11 ` [patch 27/37] PNP: use conventional "i" for loop indices Bjorn Helgaas
2008-03-26 17:11 ` [patch 28/37] PNP: add pnp_get_resource() interface Bjorn Helgaas
2008-03-26 23:15   ` Bjorn Helgaas
2008-03-26 17:11 ` [patch 29/37] PNP: convert encoders to use pnp_get_resource(), not pnp_resource_table Bjorn Helgaas
2008-03-26 17:11 ` [patch 30/37] PNP: convert resource accessors " Bjorn Helgaas
2008-03-26 17:11 ` [patch 31/37] PNP: convert resource checks " Bjorn Helgaas
2008-03-26 17:11 ` [patch 32/37] PNP: convert resource assign functions " Bjorn Helgaas
2008-03-26 17:11 ` [patch 33/37] PNP: remove PNP_MAX_* uses Bjorn Helgaas
2008-03-26 17:11 ` [patch 34/37] PNP: remove unused interfaces using pnp_resource_table Bjorn Helgaas
2008-03-26 17:11 ` [patch 35/37] rtc: dont reference pnp_resource_table directly Bjorn Helgaas
2008-03-26 17:11 ` [patch 36/37] PNP: make pnp_resource_table private to PNP core Bjorn Helgaas
2008-03-26 17:11 ` [patch 37/37] PNP: make interfaces private to the " Bjorn Helgaas
2008-03-26 22:42 ` [patch 00/37] PNP resource_table cleanups Len Brown
2008-03-26 23:13   ` Bjorn Helgaas
2008-03-27  0:30     ` Rene Herman
2008-03-27 17:50       ` Bjorn Helgaas
2008-03-31 19:40         ` Rene Herman
2008-03-31 19:48           ` Rene Herman
2008-03-31 20:51           ` Bjorn Helgaas
2008-03-31 21:38             ` Rene Herman
2008-04-01 10:16               ` Rene Herman
2008-04-01 14:52                 ` Bjorn Helgaas
2008-04-01 15:16 [patch 00/37] PNP resource_table cleanups, v2 Bjorn Helgaas
2008-04-01 15:16 ` [patch 03/37] PNP: make pnp_add_id() internal to PNP core Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).