From: Bjorn Helgaas <bjorn.helgaas@hp.com>
To: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
Adam Belay <ambx1@neo.rr.com>, Li Shaohua <shaohua.li@intel.com>,
Matthieu Castet <castet.matthieu@free.fr>,
Thomas Renninger <trenn@suse.de>,
Rene Herman <rene.herman@keyaccess.nl>,
Jaroslav Kysela <perex@perex.cz>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [patch 45/53] PNP: replace pnp_resource_table with dynamically allocated resources
Date: Fri, 18 Apr 2008 14:50:40 -0600 [thread overview]
Message-ID: <20080418205056.370787258@ldl.fc.hp.com> (raw)
In-Reply-To: 20080418204955.342963315@ldl.fc.hp.com
[-- Attachment #1: pnp-make-resources-dynamic --]
[-- Type: text/plain, Size: 10612 bytes --]
PNP used to have a fixed-size pnp_resource_table for tracking the
resources used by a device. This table often overflowed, so we've
had to increase the table size, which wastes memory because most
devices have very few resources.
This patch replaces the table with a linked list of resources where
the entries are allocated on demand.
This removes messages like these:
pnpacpi: exceeded the max number of IO resources
00:01: too many PORTs (max 40)
References:
http://bugzilla.kernel.org/show_bug.cgi?id=9535
http://bugzilla.kernel.org/show_bug.cgi?id=9740
http://lkml.org/lkml/2007/11/30/110
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
---
drivers/pnp/base.h | 13 --------
drivers/pnp/core.c | 20 +++++++-----
drivers/pnp/isapnp/core.c | 56 ++++++++++++++--------------------
drivers/pnp/manager.c | 33 +++++---------------
drivers/pnp/resource.c | 74 +++++++++++++---------------------------------
include/linux/pnp.h | 3 -
6 files changed, 68 insertions(+), 131 deletions(-)
Index: work8/drivers/pnp/base.h
===================================================================
--- work8.orig/drivers/pnp/base.h 2008-04-18 12:33:55.000000000 -0600
+++ work8/drivers/pnp/base.h 2008-04-18 12:33:56.000000000 -0600
@@ -20,23 +20,12 @@
void pnp_init_resource(struct resource *res);
int pnp_resource_type(struct resource *res);
-#define PNP_MAX_PORT 40
-#define PNP_MAX_MEM 24
-#define PNP_MAX_IRQ 2
-#define PNP_MAX_DMA 2
-
struct pnp_resource {
+ struct list_head list;
struct resource res;
unsigned int index; /* ISAPNP config register index */
};
-struct pnp_resource_table {
- struct pnp_resource port[PNP_MAX_PORT];
- struct pnp_resource mem[PNP_MAX_MEM];
- struct pnp_resource dma[PNP_MAX_DMA];
- struct pnp_resource irq[PNP_MAX_IRQ];
-};
-
struct pnp_resource *pnp_add_irq_resource(struct pnp_dev *dev, int irq,
int flags);
struct pnp_resource *pnp_add_dma_resource(struct pnp_dev *dev, int dma,
Index: work8/drivers/pnp/core.c
===================================================================
--- work8.orig/drivers/pnp/core.c 2008-04-18 12:27:14.000000000 -0600
+++ work8/drivers/pnp/core.c 2008-04-18 12:33:56.000000000 -0600
@@ -99,6 +99,16 @@
}
}
+static void pnp_free_resources(struct pnp_dev *dev)
+{
+ struct pnp_resource *pnp_res;
+
+ list_for_each_entry(pnp_res, &dev->resources, list) {
+ list_del(&pnp_res->list);
+ kfree(pnp_res);
+ }
+}
+
static void pnp_release_device(struct device *dmdev)
{
struct pnp_dev *dev = to_pnp_dev(dmdev);
@@ -106,7 +116,7 @@
pnp_free_option(dev->independent);
pnp_free_option(dev->dependent);
pnp_free_ids(dev);
- kfree(dev->res);
+ pnp_free_resources(dev);
kfree(dev);
}
@@ -119,12 +129,7 @@
if (!dev)
return NULL;
- dev->res = kzalloc(sizeof(struct pnp_resource_table), GFP_KERNEL);
- if (!dev->res) {
- kfree(dev);
- return NULL;
- }
-
+ INIT_LIST_HEAD(&dev->resources);
dev->protocol = protocol;
dev->number = id;
@@ -134,7 +139,6 @@
dev_id = pnp_add_id(dev, pnpid);
if (!dev_id) {
- kfree(dev->res);
kfree(dev);
return NULL;
}
Index: work8/drivers/pnp/isapnp/core.c
===================================================================
--- work8.orig/drivers/pnp/isapnp/core.c 2008-04-18 12:32:37.000000000 -0600
+++ work8/drivers/pnp/isapnp/core.c 2008-04-18 12:33:56.000000000 -0600
@@ -970,53 +970,45 @@
return 0;
}
+#define set(flags) ((flags & IORESOURCE_UNSET) == 0)
+
static int isapnp_set_resources(struct pnp_dev *dev)
{
struct pnp_resource *pnp_res;
struct resource *res;
- int tmp, index;
+ int index, irq;
isapnp_cfg_begin(dev->card->number, dev->number);
dev->active = 1;
- for (tmp = 0; tmp < ISAPNP_MAX_PORT; tmp++) {
- pnp_res = &dev->res->port[tmp];
- index = pnp_res->index;
+
+ list_for_each_entry(pnp_res, &dev->resources, list) {
res = &pnp_res->res;
- if ((res->flags & (IORESOURCE_IO | IORESOURCE_UNSET)) ==
- IORESOURCE_IO)
+ if (res->flags & IORESOURCE_UNSET)
+ continue;
+
+ index = pnp_res->index;
+ switch (pnp_resource_type(res)) {
+ case IORESOURCE_IO:
isapnp_write_word(ISAPNP_CFG_PORT + (index << 1),
res->start);
- }
- for (tmp = 0; tmp < ISAPNP_MAX_IRQ; tmp++) {
- pnp_res = &dev->res->irq[tmp];
- index = pnp_res->index;
- res = &pnp_res->res;
- if ((res->flags & (IORESOURCE_IRQ | IORESOURCE_UNSET)) ==
- IORESOURCE_IRQ) {
- int irq = res->start;
+ break;
+ case IORESOURCE_MEM:
+ /* FIXME: We aren't handling 32bit mems properly here */
+ isapnp_write_word(ISAPNP_CFG_MEM + (index << 3),
+ (res->start >> 8) & 0xffff);
+ break;
+ case IORESOURCE_IRQ:
+ irq = res->start;
if (irq == 2)
irq = 9;
isapnp_write_byte(ISAPNP_CFG_IRQ + (index << 1), irq);
- }
- }
- for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) {
- pnp_res = &dev->res->dma[tmp];
- index = pnp_res->index;
- res = &pnp_res->res;
- if ((res->flags & (IORESOURCE_DMA | IORESOURCE_UNSET)) ==
- IORESOURCE_DMA)
+ break;
+ case IORESOURCE_DMA:
isapnp_write_byte(ISAPNP_CFG_DMA + index, res->start);
+ break;
+ }
}
- for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) {
- pnp_res = &dev->res->mem[tmp];
- index = pnp_res->index;
- res = &pnp_res->res;
- if ((res->flags & (IORESOURCE_MEM | IORESOURCE_UNSET)) ==
- IORESOURCE_MEM)
- isapnp_write_word(ISAPNP_CFG_MEM + (index << 3),
- (res->start >> 8) & 0xffff);
- }
- /* FIXME: We aren't handling 32bit mems properly here */
+
isapnp_activate(dev->number);
isapnp_cfg_end();
return 0;
Index: work8/drivers/pnp/manager.c
===================================================================
--- work8.orig/drivers/pnp/manager.c 2008-04-18 12:27:14.000000000 -0600
+++ work8/drivers/pnp/manager.c 2008-04-18 12:33:56.000000000 -0600
@@ -228,45 +228,30 @@
/**
* pnp_init_resources - Resets a resource table to default values.
- * @table: pointer to the desired resource table
+ * @dev: pointer to the desired device
*/
void pnp_init_resources(struct pnp_dev *dev)
{
+ struct pnp_resource *pnp_res;
struct resource *res;
- int i;
- for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IRQ, i)); i++)
- pnp_init_resource(res);
- for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_DMA, i)); i++)
- pnp_init_resource(res);
- for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IO, i)); i++)
- pnp_init_resource(res);
- for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++)
+ list_for_each_entry(pnp_res, &dev->resources, list) {
+ res = &pnp_res->res;
pnp_init_resource(res);
+ }
}
/**
* pnp_clean_resources - clears resources that were not manually set
- * @res: the resources to clean
+ * @dev: pointer to the desired device
*/
static void pnp_clean_resource_table(struct pnp_dev *dev)
{
+ struct pnp_resource *pnp_res;
struct resource *res;
- int i;
- for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IRQ, i)); i++) {
- if (res->flags & IORESOURCE_AUTO)
- pnp_init_resource(res);
- }
- for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_DMA, i)); i++) {
- if (res->flags & IORESOURCE_AUTO)
- pnp_init_resource(res);
- }
- for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IO, i)); i++) {
- if (res->flags & IORESOURCE_AUTO)
- pnp_init_resource(res);
- }
- for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) {
+ list_for_each_entry(pnp_res, &dev->resources, list) {
+ res = &pnp_res->res;
if (res->flags & IORESOURCE_AUTO)
pnp_init_resource(res);
}
Index: work8/drivers/pnp/resource.c
===================================================================
--- work8.orig/drivers/pnp/resource.c 2008-04-18 12:33:55.000000000 -0600
+++ work8/drivers/pnp/resource.c 2008-04-18 12:33:56.000000000 -0600
@@ -498,25 +498,13 @@
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 *pnp_res;
+ struct resource *res;
- switch (type) {
- case IORESOURCE_IO:
- if (num >= PNP_MAX_PORT)
- return NULL;
- return &res->port[num].res;
- case IORESOURCE_MEM:
- if (num >= PNP_MAX_MEM)
- return NULL;
- return &res->mem[num].res;
- case IORESOURCE_IRQ:
- if (num >= PNP_MAX_IRQ)
- return NULL;
- return &res->irq[num].res;
- case IORESOURCE_DMA:
- if (num >= PNP_MAX_DMA)
- return NULL;
- return &res->dma[num].res;
+ list_for_each_entry(pnp_res, &dev->resources, list) {
+ res = &pnp_res->res;
+ if (pnp_resource_type(res) == type && num-- == 0)
+ return res;
}
return NULL;
}
@@ -526,43 +514,23 @@
{
struct pnp_resource *pnp_res;
struct resource *res;
- int i;
- switch (type) {
- case IORESOURCE_IO:
- for (i = 0; i < PNP_MAX_PORT; i++) {
- pnp_res = &dev->res->port[i];
- res = &pnp_res->res;
- if (res->flags & IORESOURCE_UNSET)
- return pnp_res;
- }
- break;
- case IORESOURCE_MEM:
- for (i = 0; i < PNP_MAX_MEM; i++) {
- pnp_res = &dev->res->mem[i];
- res = &pnp_res->res;
- if (res->flags & IORESOURCE_UNSET)
- return pnp_res;
- }
- break;
- case IORESOURCE_IRQ:
- for (i = 0; i < PNP_MAX_IRQ; i++) {
- pnp_res = &dev->res->irq[i];
- res = &pnp_res->res;
- if (res->flags & IORESOURCE_UNSET)
- return pnp_res;
- }
- break;
- case IORESOURCE_DMA:
- for (i = 0; i < PNP_MAX_DMA; i++) {
- pnp_res = &dev->res->dma[i];
- res = &pnp_res->res;
- if (res->flags & IORESOURCE_UNSET)
- return pnp_res;
- }
- break;
+ list_for_each_entry(pnp_res, &dev->resources, list) {
+ res = &pnp_res->res;
+ if (pnp_resource_type(res) == type &&
+ res->flags & IORESOURCE_UNSET)
+ return pnp_res;
}
- return NULL;
+
+ pnp_res = kzalloc(sizeof(struct pnp_resource), GFP_KERNEL);
+ if (!pnp_res)
+ return NULL;
+
+ res = &pnp_res->res;
+ res->flags = type;
+ pnp_init_resource(res);
+ list_add_tail(&pnp_res->list, &dev->resources);
+ return pnp_res;
}
struct pnp_resource *pnp_add_irq_resource(struct pnp_dev *dev, int irq,
Index: work8/include/linux/pnp.h
===================================================================
--- work8.orig/include/linux/pnp.h 2008-04-18 12:27:14.000000000 -0600
+++ work8/include/linux/pnp.h 2008-04-18 12:33:56.000000000 -0600
@@ -17,7 +17,6 @@
struct pnp_protocol;
struct pnp_dev;
-struct pnp_resource_table;
/*
* Resource Management
@@ -253,7 +252,7 @@
int capabilities;
struct pnp_option *independent;
struct pnp_option *dependent;
- struct pnp_resource_table *res;
+ struct list_head resources;
char name[PNP_NAME_LEN]; /* contains a human-readable name */
unsigned short regs; /* ISAPnP: supported registers */
--
WARNING: multiple messages have this Message-ID (diff)
From: Bjorn Helgaas <bjorn.helgaas@hp.com>
To: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Adam Belay <ambx1@neo.rr.com>
Cc: Li Shaohua <shaohua.li@intel.com>
Cc: Matthieu Castet <castet.matthieu@free.fr>
Cc: Thomas Renninger <trenn@suse.de>
Cc: Rene Herman <rene.herman@keyaccess.nl>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>
Subject: [patch 45/53] PNP: replace pnp_resource_table with dynamically allocated resources
Date: Fri, 18 Apr 2008 14:50:40 -0600 [thread overview]
Message-ID: <20080418205056.370787258@ldl.fc.hp.com> (raw)
In-Reply-To: 20080418204955.342963315@ldl.fc.hp.com
[-- Attachment #1: pnp-make-resources-dynamic --]
[-- Type: text/plain, Size: 10612 bytes --]
PNP used to have a fixed-size pnp_resource_table for tracking the
resources used by a device. This table often overflowed, so we've
had to increase the table size, which wastes memory because most
devices have very few resources.
This patch replaces the table with a linked list of resources where
the entries are allocated on demand.
This removes messages like these:
pnpacpi: exceeded the max number of IO resources
00:01: too many PORTs (max 40)
References:
http://bugzilla.kernel.org/show_bug.cgi?id=9535
http://bugzilla.kernel.org/show_bug.cgi?id=9740
http://lkml.org/lkml/2007/11/30/110
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
---
drivers/pnp/base.h | 13 --------
drivers/pnp/core.c | 20 +++++++-----
drivers/pnp/isapnp/core.c | 56 ++++++++++++++--------------------
drivers/pnp/manager.c | 33 +++++---------------
drivers/pnp/resource.c | 74 +++++++++++++---------------------------------
include/linux/pnp.h | 3 -
6 files changed, 68 insertions(+), 131 deletions(-)
Index: work8/drivers/pnp/base.h
===================================================================
--- work8.orig/drivers/pnp/base.h 2008-04-18 12:33:55.000000000 -0600
+++ work8/drivers/pnp/base.h 2008-04-18 12:33:56.000000000 -0600
@@ -20,23 +20,12 @@
void pnp_init_resource(struct resource *res);
int pnp_resource_type(struct resource *res);
-#define PNP_MAX_PORT 40
-#define PNP_MAX_MEM 24
-#define PNP_MAX_IRQ 2
-#define PNP_MAX_DMA 2
-
struct pnp_resource {
+ struct list_head list;
struct resource res;
unsigned int index; /* ISAPNP config register index */
};
-struct pnp_resource_table {
- struct pnp_resource port[PNP_MAX_PORT];
- struct pnp_resource mem[PNP_MAX_MEM];
- struct pnp_resource dma[PNP_MAX_DMA];
- struct pnp_resource irq[PNP_MAX_IRQ];
-};
-
struct pnp_resource *pnp_add_irq_resource(struct pnp_dev *dev, int irq,
int flags);
struct pnp_resource *pnp_add_dma_resource(struct pnp_dev *dev, int dma,
Index: work8/drivers/pnp/core.c
===================================================================
--- work8.orig/drivers/pnp/core.c 2008-04-18 12:27:14.000000000 -0600
+++ work8/drivers/pnp/core.c 2008-04-18 12:33:56.000000000 -0600
@@ -99,6 +99,16 @@
}
}
+static void pnp_free_resources(struct pnp_dev *dev)
+{
+ struct pnp_resource *pnp_res;
+
+ list_for_each_entry(pnp_res, &dev->resources, list) {
+ list_del(&pnp_res->list);
+ kfree(pnp_res);
+ }
+}
+
static void pnp_release_device(struct device *dmdev)
{
struct pnp_dev *dev = to_pnp_dev(dmdev);
@@ -106,7 +116,7 @@
pnp_free_option(dev->independent);
pnp_free_option(dev->dependent);
pnp_free_ids(dev);
- kfree(dev->res);
+ pnp_free_resources(dev);
kfree(dev);
}
@@ -119,12 +129,7 @@
if (!dev)
return NULL;
- dev->res = kzalloc(sizeof(struct pnp_resource_table), GFP_KERNEL);
- if (!dev->res) {
- kfree(dev);
- return NULL;
- }
-
+ INIT_LIST_HEAD(&dev->resources);
dev->protocol = protocol;
dev->number = id;
@@ -134,7 +139,6 @@
dev_id = pnp_add_id(dev, pnpid);
if (!dev_id) {
- kfree(dev->res);
kfree(dev);
return NULL;
}
Index: work8/drivers/pnp/isapnp/core.c
===================================================================
--- work8.orig/drivers/pnp/isapnp/core.c 2008-04-18 12:32:37.000000000 -0600
+++ work8/drivers/pnp/isapnp/core.c 2008-04-18 12:33:56.000000000 -0600
@@ -970,53 +970,45 @@
return 0;
}
+#define set(flags) ((flags & IORESOURCE_UNSET) == 0)
+
static int isapnp_set_resources(struct pnp_dev *dev)
{
struct pnp_resource *pnp_res;
struct resource *res;
- int tmp, index;
+ int index, irq;
isapnp_cfg_begin(dev->card->number, dev->number);
dev->active = 1;
- for (tmp = 0; tmp < ISAPNP_MAX_PORT; tmp++) {
- pnp_res = &dev->res->port[tmp];
- index = pnp_res->index;
+
+ list_for_each_entry(pnp_res, &dev->resources, list) {
res = &pnp_res->res;
- if ((res->flags & (IORESOURCE_IO | IORESOURCE_UNSET)) ==
- IORESOURCE_IO)
+ if (res->flags & IORESOURCE_UNSET)
+ continue;
+
+ index = pnp_res->index;
+ switch (pnp_resource_type(res)) {
+ case IORESOURCE_IO:
isapnp_write_word(ISAPNP_CFG_PORT + (index << 1),
res->start);
- }
- for (tmp = 0; tmp < ISAPNP_MAX_IRQ; tmp++) {
- pnp_res = &dev->res->irq[tmp];
- index = pnp_res->index;
- res = &pnp_res->res;
- if ((res->flags & (IORESOURCE_IRQ | IORESOURCE_UNSET)) ==
- IORESOURCE_IRQ) {
- int irq = res->start;
+ break;
+ case IORESOURCE_MEM:
+ /* FIXME: We aren't handling 32bit mems properly here */
+ isapnp_write_word(ISAPNP_CFG_MEM + (index << 3),
+ (res->start >> 8) & 0xffff);
+ break;
+ case IORESOURCE_IRQ:
+ irq = res->start;
if (irq == 2)
irq = 9;
isapnp_write_byte(ISAPNP_CFG_IRQ + (index << 1), irq);
- }
- }
- for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) {
- pnp_res = &dev->res->dma[tmp];
- index = pnp_res->index;
- res = &pnp_res->res;
- if ((res->flags & (IORESOURCE_DMA | IORESOURCE_UNSET)) ==
- IORESOURCE_DMA)
+ break;
+ case IORESOURCE_DMA:
isapnp_write_byte(ISAPNP_CFG_DMA + index, res->start);
+ break;
+ }
}
- for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) {
- pnp_res = &dev->res->mem[tmp];
- index = pnp_res->index;
- res = &pnp_res->res;
- if ((res->flags & (IORESOURCE_MEM | IORESOURCE_UNSET)) ==
- IORESOURCE_MEM)
- isapnp_write_word(ISAPNP_CFG_MEM + (index << 3),
- (res->start >> 8) & 0xffff);
- }
- /* FIXME: We aren't handling 32bit mems properly here */
+
isapnp_activate(dev->number);
isapnp_cfg_end();
return 0;
Index: work8/drivers/pnp/manager.c
===================================================================
--- work8.orig/drivers/pnp/manager.c 2008-04-18 12:27:14.000000000 -0600
+++ work8/drivers/pnp/manager.c 2008-04-18 12:33:56.000000000 -0600
@@ -228,45 +228,30 @@
/**
* pnp_init_resources - Resets a resource table to default values.
- * @table: pointer to the desired resource table
+ * @dev: pointer to the desired device
*/
void pnp_init_resources(struct pnp_dev *dev)
{
+ struct pnp_resource *pnp_res;
struct resource *res;
- int i;
- for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IRQ, i)); i++)
- pnp_init_resource(res);
- for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_DMA, i)); i++)
- pnp_init_resource(res);
- for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IO, i)); i++)
- pnp_init_resource(res);
- for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++)
+ list_for_each_entry(pnp_res, &dev->resources, list) {
+ res = &pnp_res->res;
pnp_init_resource(res);
+ }
}
/**
* pnp_clean_resources - clears resources that were not manually set
- * @res: the resources to clean
+ * @dev: pointer to the desired device
*/
static void pnp_clean_resource_table(struct pnp_dev *dev)
{
+ struct pnp_resource *pnp_res;
struct resource *res;
- int i;
- for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IRQ, i)); i++) {
- if (res->flags & IORESOURCE_AUTO)
- pnp_init_resource(res);
- }
- for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_DMA, i)); i++) {
- if (res->flags & IORESOURCE_AUTO)
- pnp_init_resource(res);
- }
- for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IO, i)); i++) {
- if (res->flags & IORESOURCE_AUTO)
- pnp_init_resource(res);
- }
- for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) {
+ list_for_each_entry(pnp_res, &dev->resources, list) {
+ res = &pnp_res->res;
if (res->flags & IORESOURCE_AUTO)
pnp_init_resource(res);
}
Index: work8/drivers/pnp/resource.c
===================================================================
--- work8.orig/drivers/pnp/resource.c 2008-04-18 12:33:55.000000000 -0600
+++ work8/drivers/pnp/resource.c 2008-04-18 12:33:56.000000000 -0600
@@ -498,25 +498,13 @@
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 *pnp_res;
+ struct resource *res;
- switch (type) {
- case IORESOURCE_IO:
- if (num >= PNP_MAX_PORT)
- return NULL;
- return &res->port[num].res;
- case IORESOURCE_MEM:
- if (num >= PNP_MAX_MEM)
- return NULL;
- return &res->mem[num].res;
- case IORESOURCE_IRQ:
- if (num >= PNP_MAX_IRQ)
- return NULL;
- return &res->irq[num].res;
- case IORESOURCE_DMA:
- if (num >= PNP_MAX_DMA)
- return NULL;
- return &res->dma[num].res;
+ list_for_each_entry(pnp_res, &dev->resources, list) {
+ res = &pnp_res->res;
+ if (pnp_resource_type(res) == type && num-- == 0)
+ return res;
}
return NULL;
}
@@ -526,43 +514,23 @@
{
struct pnp_resource *pnp_res;
struct resource *res;
- int i;
- switch (type) {
- case IORESOURCE_IO:
- for (i = 0; i < PNP_MAX_PORT; i++) {
- pnp_res = &dev->res->port[i];
- res = &pnp_res->res;
- if (res->flags & IORESOURCE_UNSET)
- return pnp_res;
- }
- break;
- case IORESOURCE_MEM:
- for (i = 0; i < PNP_MAX_MEM; i++) {
- pnp_res = &dev->res->mem[i];
- res = &pnp_res->res;
- if (res->flags & IORESOURCE_UNSET)
- return pnp_res;
- }
- break;
- case IORESOURCE_IRQ:
- for (i = 0; i < PNP_MAX_IRQ; i++) {
- pnp_res = &dev->res->irq[i];
- res = &pnp_res->res;
- if (res->flags & IORESOURCE_UNSET)
- return pnp_res;
- }
- break;
- case IORESOURCE_DMA:
- for (i = 0; i < PNP_MAX_DMA; i++) {
- pnp_res = &dev->res->dma[i];
- res = &pnp_res->res;
- if (res->flags & IORESOURCE_UNSET)
- return pnp_res;
- }
- break;
+ list_for_each_entry(pnp_res, &dev->resources, list) {
+ res = &pnp_res->res;
+ if (pnp_resource_type(res) == type &&
+ res->flags & IORESOURCE_UNSET)
+ return pnp_res;
}
- return NULL;
+
+ pnp_res = kzalloc(sizeof(struct pnp_resource), GFP_KERNEL);
+ if (!pnp_res)
+ return NULL;
+
+ res = &pnp_res->res;
+ res->flags = type;
+ pnp_init_resource(res);
+ list_add_tail(&pnp_res->list, &dev->resources);
+ return pnp_res;
}
struct pnp_resource *pnp_add_irq_resource(struct pnp_dev *dev, int irq,
Index: work8/include/linux/pnp.h
===================================================================
--- work8.orig/include/linux/pnp.h 2008-04-18 12:27:14.000000000 -0600
+++ work8/include/linux/pnp.h 2008-04-18 12:33:56.000000000 -0600
@@ -17,7 +17,6 @@
struct pnp_protocol;
struct pnp_dev;
-struct pnp_resource_table;
/*
* Resource Management
@@ -253,7 +252,7 @@
int capabilities;
struct pnp_option *independent;
struct pnp_option *dependent;
- struct pnp_resource_table *res;
+ struct list_head resources;
char name[PNP_NAME_LEN]; /* contains a human-readable name */
unsigned short regs; /* ISAPnP: supported registers */
--
next prev parent reply other threads:[~2008-04-18 20:50 UTC|newest]
Thread overview: 119+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-18 20:49 [patch 00/53] PNP cleanup and convert to dynamic resources, v3 Bjorn Helgaas
2008-04-18 20:49 ` Bjorn Helgaas
2008-04-18 20:49 ` [patch 01/53] ISAPNP: move config register addresses out of isapnp.h Bjorn Helgaas
2008-04-18 20:49 ` Bjorn Helgaas
2008-04-18 20:49 ` [patch 02/53] PNPACPI: continue after _CRS and _PRS errors Bjorn Helgaas
2008-04-18 20:49 ` Bjorn Helgaas
2008-04-18 20:49 ` [patch 03/53] PNP: make pnp_add_id() internal to PNP core Bjorn Helgaas
2008-04-18 20:49 ` Bjorn Helgaas
2008-04-18 20:49 ` [patch 04/53] PNP: change pnp_add_id() to allocate its own pnp_id structures Bjorn Helgaas
2008-04-18 20:49 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 05/53] PNP: add pnp_eisa_id_to_string() Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 06/53] PNP: add pnp_alloc_dev() Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 07/53] PNP: make pnp_add_card_id() internal to PNP core Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 08/53] PNP: change pnp_add_card_id() to allocate its own pnp_id structures Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 09/53] ISAPNP: pull pnp_add_card_id() out of isapnp_parse_card_id() Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 10/53] PNP: add pnp_alloc_card() Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 11/53] PNPACPI: pnpacpi_encode_ext_irq() wrongly set "irq" instead of "extended_irq" Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 12/53] PNPACPI: use temporaries to reduce repetition Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 13/53] PNPACPI: hoist dma_flags() out of pnpacpi_parse_allocated_dmaresource() Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 14/53] PNPACPI: extend irq_flags() to set IORESOURCE_IRQ_SHAREABLE when appropriate Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 15/53] PNPACPI: pass pnp_dev instead of acpi_handle Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 16/53] PNP: remove pnp_resource_table from internal get/set interfaces Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 17/53] PNP: remove more pnp_resource_table arguments Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 18/53] PNP: add pnp_init_resources(struct pnp_dev *) interface Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 19/53] PNP: remove pnp_resource_table from internal pnp_clean_resource_table interface Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 20/53] PNP: remove unused interfaces using pnp_resource_table Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 21/53] PNP: use dev_printk when possible Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 22/53] PNP: factor pnp_init_resource_table() and pnp_clean_resource_table() Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 22:29 ` Rene Herman
2008-04-19 3:57 ` Bjorn Helgaas
2008-04-19 4:43 ` Rene Herman
2008-04-19 4:46 ` Rene Herman
2008-04-21 18:41 ` Rene Herman
2008-04-21 23:10 ` Bjorn Helgaas
2008-04-22 21:01 ` Rene Herman
2008-04-23 23:08 ` Bjorn Helgaas
2008-04-24 1:26 ` Rene Herman
2008-04-24 1:39 ` Rene Herman
2008-04-24 22:45 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 23/53] PNP: add pnp_get_resource() interface Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 24/53] PNP: remove pnp_mem_flags() as an lvalue Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 25/53] PNP: convert resource accessors to use pnp_get_resource(), not pnp_resource_table Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 26/53] PNP: use conventional "i" for loop indices Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 27/53] PNP: convert resource checks to use pnp_get_resource(), not pnp_resource_table Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 28/53] PNP: convert resource assign functions " Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 29/53] PNP: convert sysfs interface " Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 30/53] PNP: convert resource initializers " Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 31/53] PNP: convert encoders " Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 32/53] PNP: remove PNP_MAX_* uses Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 33/53] rtc: dont reference pnp_resource_table directly Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 34/53] PNP: make pnp_resource_table private to PNP core Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 35/53] PNP: remove pnp_resource_table references from resource decoders Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 36/53] PNP: add struct pnp_resource Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 37/53] PNP: add pnp_resource index for ISAPNP Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 38/53] PNP: add pnp_new_resource() to find a new unset pnp_resource Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 39/53] PNP: make generic pnp_add_irq_resource() Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 40/53] PNP: make generic pnp_add_dma_resource() Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 41/53] PNP: make generic pnp_add_io_resource() Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 42/53] PNP: make generic pnp_add_mem_resource() Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 43/53] ISAPNP: fold isapnp_read_resources() back into isapnp_get_resources() Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 44/53] PNP: add pnp_resource_type() internal interface Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas [this message]
2008-04-18 20:50 ` [patch 45/53] PNP: replace pnp_resource_table with dynamically allocated resources Bjorn Helgaas
2008-04-18 20:50 ` [patch 46/53] PNP: remove ratelimit on add resource failures Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 47/53] PNPACPI: move _CRS/_PRS warnings closer to the action Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 48/53] PNPACPI: remove some pnp_dbg calls Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 49/53] PNP: make interfaces private to the PNP core Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 50/53] ISAPNP: remove unused pnp_dev->regs field Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 51/53] PNPBIOS: remove include/linux/pnpbios.h Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 52/53] PNP: fill in generic pnp_dev fields earlier Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
2008-04-18 20:50 ` [patch 53/53] PNP: dont sort by type in /sys/.../resources Bjorn Helgaas
2008-04-18 20:50 ` Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080418205056.370787258@ldl.fc.hp.com \
--to=bjorn.helgaas@hp.com \
--cc=akpm@linux-foundation.org \
--cc=ambx1@neo.rr.com \
--cc=castet.matthieu@free.fr \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=rene.herman@keyaccess.nl \
--cc=shaohua.li@intel.com \
--cc=trenn@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.