From 1bd17e63a068db6f464925a79b1cc4b27a8b1af9 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:33:48 -0600 Subject: PNP: turn on -DDEBUG when CONFIG_PNP_DEBUG is set Turn on -DDEBUG in CFLAGS when CONFIG_PNP_DEBUG=y. This makes dev_dbg() do what you expect. Signed-off-by: Bjorn Helgaas Acked-by: Rene Herman Signed-off-by: Len Brown --- drivers/pnp/isapnp/Makefile | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/isapnp/Makefile b/drivers/pnp/isapnp/Makefile index cac18bbfb817..3e38f06f8d78 100644 --- a/drivers/pnp/isapnp/Makefile +++ b/drivers/pnp/isapnp/Makefile @@ -5,3 +5,7 @@ isapnp-proc-$(CONFIG_PROC_FS) = proc.o obj-y := core.o compat.o $(isapnp-proc-y) + +ifeq ($(CONFIG_PNP_DEBUG),y) +EXTRA_CFLAGS += -DDEBUG +endif -- cgit v1.2.3 From ca0e8b6fd29819891c874b86ff286987c5bfdc21 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:33:49 -0600 Subject: ISAPNP: move config register addresses out of isapnp.h These are used only in drivers/pnp/isapnp/core.c, so no need to expose them to the world. Signed-off-by: Bjorn Helgaas Acked-By: Rene Herman Signed-off-by: Len Brown --- drivers/pnp/isapnp/core.c | 8 ++++++++ include/linux/isapnp.h | 10 ---------- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 257f5d827d83..dd67752a5828 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -88,6 +88,14 @@ MODULE_LICENSE("GPL"); #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. diff --git a/include/linux/isapnp.h b/include/linux/isapnp.h index 1e8728a9ee8a..cd5a269fdb5e 100644 --- a/include/linux/isapnp.h +++ b/include/linux/isapnp.h @@ -25,16 +25,6 @@ #include #include -/* - * 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 */ - /* * */ -- cgit v1.2.3 From 772defc6292bae8b6db298476d1dabd22a99492b Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:33:52 -0600 Subject: PNP: change pnp_add_id() to allocate its own pnp_id structures This moves some of the pnp_id knowledge out of the backends and into the PNP core. Signed-off-by: Bjorn Helgaas Acked-By: Rene Herman Signed-off-by: Len Brown --- drivers/pnp/base.h | 2 +- drivers/pnp/driver.c | 28 +++++++++++++++++++++------- drivers/pnp/isapnp/core.c | 14 ++++++-------- drivers/pnp/pnpacpi/core.c | 25 ++----------------------- drivers/pnp/pnpbios/core.c | 6 ++---- drivers/pnp/pnpbios/rsparser.c | 9 ++++----- 6 files changed, 36 insertions(+), 48 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index abefcc351521..ba55b0623f7e 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h @@ -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); diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c index e85cbf116db1..d3f869ee1d92 100644 --- a/drivers/pnp/driver.c +++ b/drivers/pnp/driver.c @@ -226,22 +226,36 @@ void pnp_unregister_driver(struct pnp_driver *drv) /** * 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); diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index dd67752a5828..10cade831433 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -44,6 +44,8 @@ #include #include +#include "../base.h" + #if 0 #define ISAPNP_REGION_OK #endif @@ -401,20 +403,16 @@ static void __init isapnp_skip_bytes(int count) 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", + 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); - pnp_add_id(id, dev); + + pnp_add_id(dev, id); } /* diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 4807d76f8a04..86aea1ebfee7 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c @@ -73,18 +73,6 @@ static int __init ispnpidacpi(char *id) 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 @@ static int __init pnpacpi_add_device(struct acpi_device *device) 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 @@ static int __init pnpacpi_add_device(struct acpi_device *device) } } - /* 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 @@ static int __init pnpacpi_add_device(struct acpi_device *device) 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); } } diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c index 2a5353bceb24..2d592aea0aa7 100644 --- a/drivers/pnp/pnpbios/core.c +++ b/drivers/pnp/pnpbios/core.c @@ -332,16 +332,14 @@ static int __init insert_device(struct pnp_bios_node *node) 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; diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index caade3531416..dbc88412c12e 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c @@ -16,6 +16,7 @@ inline void pcibios_penalize_isa_irq(int irq, int active) } #endif /* CONFIG_PCI */ +#include "../base.h" #include "pnpbios.h" /* standard resource tags */ @@ -548,13 +549,11 @@ static unsigned char *pnpbios_parse_compatible_ids(unsigned char *p, 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: -- cgit v1.2.3 From 25eb846189d20db4114cebf14fee96d69bef4667 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:33:53 -0600 Subject: PNP: add pnp_eisa_id_to_string() Converting the EISA ID to a string is messy and error-prone, and we might as well use the same code for ISAPNP and PNPBIOS. PNPACPI uses the conversion done by the ACPI core with acpi_ex_eisa_id_to_string(). Signed-off-by: Bjorn Helgaas Acked-By: Rene Herman Signed-off-by: Len Brown --- drivers/pnp/base.h | 2 ++ drivers/pnp/isapnp/core.c | 32 +++++++++++--------------------- drivers/pnp/pnpbios/core.c | 2 +- drivers/pnp/pnpbios/rsparser.c | 26 +++----------------------- drivers/pnp/support.c | 26 ++++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 45 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index ba55b0623f7e..9af0a6c7dd41 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h @@ -1,5 +1,7 @@ extern spinlock_t pnp_lock; void *pnp_alloc(long size); +#define PNP_EISA_ID_MASK 0x7fffffff +void pnp_eisa_id_to_string(u32 id, char *str); 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); diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 10cade831433..ccb04190044b 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -397,24 +397,6 @@ static void __init isapnp_skip_bytes(int count) isapnp_peek(NULL, count); } -/* - * Parse EISA id. - */ -static void isapnp_parse_id(struct pnp_dev *dev, unsigned short vendor, - unsigned short device) -{ - char id[8]; - - 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); - - pnp_add_id(dev, id); -} - /* * Parse logical device tag. */ @@ -423,13 +405,17 @@ static struct pnp_dev *__init isapnp_parse_device(struct pnp_card *card, { unsigned char tmp[6]; struct pnp_dev *dev; + u32 eisa_id; + char id[8]; isapnp_peek(tmp, size); dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); if (!dev) return NULL; dev->number = number; - isapnp_parse_id(dev, (tmp[1] << 8) | tmp[0], (tmp[3] << 8) | tmp[2]); + eisa_id = tmp[0] | tmp[1] << 8 | tmp[2] << 16 | tmp[3] << 24; + pnp_eisa_id_to_string(eisa_id, id); + pnp_add_id(dev, id); dev->regs = tmp[4]; dev->card = card; if (size > 5) @@ -619,6 +605,8 @@ static int __init isapnp_create_device(struct pnp_card *card, unsigned char type, tmp[17]; struct pnp_option *option; struct pnp_dev *dev; + u32 eisa_id; + char id[8]; if ((dev = isapnp_parse_device(card, size, number++)) == NULL) return 1; @@ -658,8 +646,10 @@ static int __init isapnp_create_device(struct pnp_card *card, 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]); + eisa_id = tmp[0] | tmp[1] << 8 | + tmp[2] << 16 | tmp[3] << 24; + pnp_eisa_id_to_string(eisa_id, id); + pnp_add_id(dev, id); compat++; size = 0; } diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c index 2d592aea0aa7..3ee5ed437385 100644 --- a/drivers/pnp/pnpbios/core.c +++ b/drivers/pnp/pnpbios/core.c @@ -332,7 +332,7 @@ static int __init insert_device(struct pnp_bios_node *node) if (!dev) return -1; - pnpid32_to_pnpid(node->eisa_id, id); + pnp_eisa_id_to_string(node->eisa_id & PNP_EISA_ID_MASK, id); dev_id = pnp_add_id(dev, id); if (!dev_id) { kfree(dev); diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index dbc88412c12e..948a661280d7 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c @@ -494,32 +494,12 @@ len_err: * Compatible Device IDs */ -#define HEX(id,a) hex[((id)>>a) & 15] -#define CHAR(id,a) (0x40 + (((id)>>a) & 31)) - -void pnpid32_to_pnpid(u32 id, char *str) -{ - const char *hex = "0123456789abcdef"; - - id = be32_to_cpu(id); - str[0] = CHAR(id, 26); - str[1] = CHAR(id, 21); - str[2] = CHAR(id, 16); - str[3] = HEX(id, 12); - str[4] = HEX(id, 8); - str[5] = HEX(id, 4); - str[6] = HEX(id, 0); - str[7] = '\0'; -} - -#undef CHAR -#undef HEX - static unsigned char *pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_dev *dev) { int len, tag; + u32 eisa_id; char id[8]; struct pnp_id *dev_id; @@ -549,8 +529,8 @@ static unsigned char *pnpbios_parse_compatible_ids(unsigned char *p, case SMALL_TAG_COMPATDEVID: /* compatible ID */ if (len != 4) goto len_err; - pnpid32_to_pnpid(p[1] | p[2] << 8 | p[3] << 16 | p[4] << - 24, id); + eisa_id = p[1] | p[2] << 8 | p[3] << 16 | p[4] << 24; + pnp_eisa_id_to_string(eisa_id & PNP_EISA_ID_MASK, id); dev_id = pnp_add_id(dev, id); if (!dev_id) return NULL; diff --git a/drivers/pnp/support.c b/drivers/pnp/support.c index 13c608f5fb30..e848b794e312 100644 --- a/drivers/pnp/support.c +++ b/drivers/pnp/support.c @@ -25,3 +25,29 @@ int pnp_is_active(struct pnp_dev *dev) } EXPORT_SYMBOL(pnp_is_active); + +/* + * Functionally similar to acpi_ex_eisa_id_to_string(), but that's + * buried in the ACPI CA, and we can't depend on it being present. + */ +void pnp_eisa_id_to_string(u32 id, char *str) +{ + id = be32_to_cpu(id); + + /* + * According to the specs, the first three characters are five-bit + * compressed ASCII, and the left-over high order bit should be zero. + * However, the Linux ISAPNP code historically used six bits for the + * first character, and there seem to be IDs that depend on that, + * e.g., "nEC8241" in the Linux 8250_pnp serial driver and the + * FreeBSD sys/pc98/cbus/sio_cbus.c driver. + */ + str[0] = 'A' + ((id >> 26) & 0x3f) - 1; + str[1] = 'A' + ((id >> 21) & 0x1f) - 1; + str[2] = 'A' + ((id >> 16) & 0x1f) - 1; + str[3] = hex_asc((id >> 12) & 0xf); + str[4] = hex_asc((id >> 8) & 0xf); + str[5] = hex_asc((id >> 4) & 0xf); + str[6] = hex_asc((id >> 0) & 0xf); + str[7] = '\0'; +} -- cgit v1.2.3 From bda1e4e5a3d976046378cd495a63e1ee0847deec Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:33:54 -0600 Subject: PNP: add pnp_alloc_dev() 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 Acked-By: Rene Herman Signed-off-by: Len Brown --- drivers/pnp/base.h | 1 + drivers/pnp/core.c | 38 +++++++++++++++++++++++++++++++------- drivers/pnp/isapnp/core.c | 11 +++++------ drivers/pnp/pnpacpi/core.c | 19 +++---------------- drivers/pnp/pnpbios/core.c | 13 ++----------- 5 files changed, 42 insertions(+), 40 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index 9af0a6c7dd41..ff435bd1ca18 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h @@ -2,6 +2,7 @@ extern spinlock_t pnp_lock; void *pnp_alloc(long size); #define PNP_EISA_ID_MASK 0x7fffffff void pnp_eisa_id_to_string(u32 id, char *str); +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); diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c index 7d366ca672d3..cf37701a4f9e 100644 --- a/drivers/pnp/core.c +++ b/drivers/pnp/core.c @@ -109,15 +109,42 @@ static void pnp_release_device(struct device *dmdev) kfree(dev); } -int __pnp_add_device(struct pnp_dev *dev) +struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid) { - int ret; + struct pnp_dev *dev; + struct pnp_id *dev_id; - pnp_fixup_device(dev); + dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); + if (!dev) + return NULL; + + dev->protocol = protocol; + dev->number = id; + dev->dma_mask = DMA_24BIT_MASK; + + dev->dev.parent = &dev->protocol->dev; dev->dev.bus = &pnp_bus_type; dev->dev.dma_mask = &dev->dma_mask; - dev->dma_mask = dev->dev.coherent_dma_mask = DMA_24BIT_MASK; + dev->dev.coherent_dma_mask = dev->dma_mask; dev->dev.release = &pnp_release_device; + + 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; + + pnp_fixup_device(dev); dev->status = PNP_READY; spin_lock(&pnp_lock); list_add_tail(&dev->global_list, &pnp_global); @@ -145,9 +172,6 @@ int pnp_add_device(struct pnp_dev *dev) 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; diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index ccb04190044b..727936a6befb 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -409,18 +409,17 @@ static struct pnp_dev *__init isapnp_parse_device(struct pnp_card *card, char id[8]; isapnp_peek(tmp, size); - dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); - if (!dev) - return NULL; - dev->number = number; eisa_id = tmp[0] | tmp[1] << 8 | tmp[2] << 16 | tmp[3] << 24; pnp_eisa_id_to_string(eisa_id, id); - pnp_add_id(dev, id); + + dev = pnp_alloc_dev(&isapnp_protocol, number, id); + if (!dev) + return NULL; + 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; diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 86aea1ebfee7..fd3fca6dddd3 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c @@ -152,7 +152,6 @@ static int __init pnpacpi_add_device(struct acpi_device *device) { 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 @@ static int __init pnpacpi_add_device(struct acpi_device *device) 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 @@ static int __init pnpacpi_add_device(struct acpi_device *device) 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 @@ static int __init pnpacpi_add_device(struct acpi_device *device) num++; return AE_OK; -err: - kfree(dev); - return -EINVAL; } static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c index 3ee5ed437385..6af2be2c1d67 100644 --- a/drivers/pnp/pnpbios/core.c +++ b/drivers/pnp/pnpbios/core.c @@ -318,7 +318,6 @@ static int __init insert_device(struct pnp_bios_node *node) { 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,11 @@ static int __init insert_device(struct pnp_bios_node *node) return -1; } - dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); - if (!dev) - return -1; - pnp_eisa_id_to_string(node->eisa_id & PNP_EISA_ID_MASK, id); - dev_id = pnp_add_id(dev, id); - if (!dev_id) { - kfree(dev); + dev = pnp_alloc_dev(&pnpbios_protocol, node->handle, id); + if (!dev) return -1; - } - dev->number = node->handle; pnpbios_parse_data_stream(dev, node); dev->active = pnp_is_active(dev); dev->flags = node->flags; @@ -352,7 +344,6 @@ static int __init insert_device(struct pnp_bios_node *node) 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) -- cgit v1.2.3 From e436675f2a09ea389c1844507658f304924a2eca Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:33:56 -0600 Subject: PNP: change pnp_add_card_id() to allocate its own pnp_id structures This moves some of the pnp_id knowledge out of the backends and into the PNP core. Signed-off-by: Bjorn Helgaas Acked-By: Rene Herman Signed-off-by: Len Brown --- drivers/pnp/base.h | 2 +- drivers/pnp/card.c | 27 +++++++++++++++++++++------ drivers/pnp/isapnp/core.c | 21 +++++++++++---------- 3 files changed, 33 insertions(+), 17 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index b492569bcdf4..37f7d85fc4bc 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h @@ -4,7 +4,7 @@ void *pnp_alloc(long size); void pnp_eisa_id_to_string(u32 id, char *str); 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); diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c index da1c9909eb44..d606a163b1d7 100644 --- a/drivers/pnp/card.c +++ b/drivers/pnp/card.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include "base.h" @@ -100,19 +101,33 @@ static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv) * @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) diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 727936a6befb..1949c18a7365 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -822,17 +822,18 @@ static unsigned char __init isapnp_checksum(unsigned char *data) 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] = 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'; + + pnp_add_card_id(card, id); } /* -- cgit v1.2.3 From 068076d5517009654376ceda75ff44af0feb9b1d Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:33:57 -0600 Subject: ISAPNP: pull pnp_add_card_id() out of isapnp_parse_card_id() 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 Acked-By: Rene Herman Signed-off-by: Len Brown --- drivers/pnp/isapnp/core.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 1949c18a7365..3a326f9305f6 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -816,26 +816,6 @@ static unsigned char __init isapnp_checksum(unsigned char *data) return checksum; } -/* - * 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] = 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'; - - pnp_add_card_id(card, id); -} - /* * Build device list for all present ISA PnP devices. */ @@ -844,6 +824,8 @@ static int __init isapnp_build_device_list(void) int csn; unsigned char header[9], checksum; struct pnp_card *card; + u32 eisa_id; + char id[8]; isapnp_wait(); isapnp_key(); @@ -864,8 +846,10 @@ static int __init isapnp_build_device_list(void) card->number = csn; INIT_LIST_HEAD(&card->devices); - isapnp_parse_card_id(card, (header[1] << 8) | header[0], - (header[3] << 8) | header[2]); + eisa_id = header[0] | header[1] << 8 | + header[2] << 16 | header[3] << 24; + pnp_eisa_id_to_string(eisa_id, id); + pnp_add_card_id(card, id); card->serial = (header[7] << 24) | (header[6] << 16) | (header[5] << 8) | header[4]; -- cgit v1.2.3 From 6bf2aab24a5dc26bf8274c4b9dbbed8ca99ae82c Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:33:58 -0600 Subject: PNP: add pnp_alloc_card() 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 Acked-By: Rene Herman Signed-off-by: Len Brown --- drivers/pnp/base.h | 1 + drivers/pnp/card.c | 28 +++++++++++++++++++++++++--- drivers/pnp/isapnp/core.c | 13 +++++-------- 3 files changed, 31 insertions(+), 11 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index 37f7d85fc4bc..a83cdcfee165 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h @@ -3,6 +3,7 @@ void *pnp_alloc(long size); #define PNP_EISA_ID_MASK 0x7fffffff void pnp_eisa_id_to_string(u32 id, char *str); 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); diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c index d606a163b1d7..a762a4176736 100644 --- a/drivers/pnp/card.c +++ b/drivers/pnp/card.c @@ -151,6 +151,31 @@ static void pnp_release_card(struct device *dmdev) 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 pnp_add_card(struct pnp_card *card) 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); diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 3a326f9305f6..883577a93d6a 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -840,16 +840,14 @@ static int __init isapnp_build_device_list(void) 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) - continue; - - card->number = csn; - INIT_LIST_HEAD(&card->devices); eisa_id = header[0] | header[1] << 8 | header[2] << 16 | header[3] << 24; pnp_eisa_id_to_string(eisa_id, id); - pnp_add_card_id(card, id); + card = pnp_alloc_card(&isapnp_protocol, csn, id); + if (!card) + continue; + + INIT_LIST_HEAD(&card->devices); card->serial = (header[7] << 24) | (header[6] << 16) | (header[5] << 8) | header[4]; @@ -860,7 +858,6 @@ static int __init isapnp_build_device_list(void) "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); } -- cgit v1.2.3 From c1caf06ccfd3a4efd4b489f89bcdabd2362f31d0 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:04 -0600 Subject: PNP: add debug output to option registration Add debug output to resource option registration functions (enabled by CONFIG_PNP_DEBUG). This uses dev_printk, so I had to add pnp_dev arguments at the same time. Signed-off-by: Bjorn Helgaas Acked-By: Rene Herman Signed-off-by: Len Brown --- drivers/pnp/isapnp/core.c | 50 ++++++++++++++++++------------- drivers/pnp/pnpacpi/rsparser.c | 68 +++++++++++++++++++++++++----------------- drivers/pnp/pnpbios/rsparser.c | 54 +++++++++++++++++++-------------- drivers/pnp/resource.c | 34 ++++++++++++++++++--- include/linux/pnp.h | 19 +++++++----- 5 files changed, 141 insertions(+), 84 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 883577a93d6a..38ff64dce9c0 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -431,7 +431,8 @@ static struct pnp_dev *__init isapnp_parse_device(struct pnp_card *card, /* * Add IRQ resource to resources list. */ -static void __init isapnp_parse_irq_resource(struct pnp_option *option, +static void __init isapnp_parse_irq_resource(struct pnp_dev *dev, + struct pnp_option *option, int size) { unsigned char tmp[3]; @@ -448,13 +449,14 @@ static void __init isapnp_parse_irq_resource(struct pnp_option *option, irq->flags = tmp[2]; else irq->flags = IORESOURCE_IRQ_HIGHEDGE; - pnp_register_irq_resource(option, irq); + pnp_register_irq_resource(dev, option, irq); } /* * Add DMA resource to resources list. */ -static void __init isapnp_parse_dma_resource(struct pnp_option *option, +static void __init isapnp_parse_dma_resource(struct pnp_dev *dev, + struct pnp_option *option, int size) { unsigned char tmp[2]; @@ -466,13 +468,14 @@ static void __init isapnp_parse_dma_resource(struct pnp_option *option, return; dma->map = tmp[0]; dma->flags = tmp[1]; - pnp_register_dma_resource(option, dma); + pnp_register_dma_resource(dev, option, dma); } /* * Add port resource to resources list. */ -static void __init isapnp_parse_port_resource(struct pnp_option *option, +static void __init isapnp_parse_port_resource(struct pnp_dev *dev, + struct pnp_option *option, int size) { unsigned char tmp[7]; @@ -487,13 +490,14 @@ static void __init isapnp_parse_port_resource(struct pnp_option *option, port->align = tmp[5]; port->size = tmp[6]; port->flags = tmp[0] ? PNP_PORT_FLAG_16BITADDR : 0; - pnp_register_port_resource(option, port); + pnp_register_port_resource(dev, option, port); } /* * Add fixed port resource to resources list. */ -static void __init isapnp_parse_fixed_port_resource(struct pnp_option *option, +static void __init isapnp_parse_fixed_port_resource(struct pnp_dev *dev, + struct pnp_option *option, int size) { unsigned char tmp[3]; @@ -507,13 +511,14 @@ static void __init isapnp_parse_fixed_port_resource(struct pnp_option *option, port->size = tmp[2]; port->align = 0; port->flags = PNP_PORT_FLAG_FIXED; - pnp_register_port_resource(option, port); + pnp_register_port_resource(dev, option, port); } /* * Add memory resource to resources list. */ -static void __init isapnp_parse_mem_resource(struct pnp_option *option, +static void __init isapnp_parse_mem_resource(struct pnp_dev *dev, + struct pnp_option *option, int size) { unsigned char tmp[9]; @@ -528,13 +533,14 @@ static void __init isapnp_parse_mem_resource(struct pnp_option *option, mem->align = (tmp[6] << 8) | tmp[5]; mem->size = ((tmp[8] << 8) | tmp[7]) << 8; mem->flags = tmp[0]; - pnp_register_mem_resource(option, mem); + pnp_register_mem_resource(dev, option, mem); } /* * Add 32-bit memory resource to resources list. */ -static void __init isapnp_parse_mem32_resource(struct pnp_option *option, +static void __init isapnp_parse_mem32_resource(struct pnp_dev *dev, + struct pnp_option *option, int size) { unsigned char tmp[17]; @@ -551,13 +557,14 @@ static void __init isapnp_parse_mem32_resource(struct pnp_option *option, mem->size = (tmp[16] << 24) | (tmp[15] << 16) | (tmp[14] << 8) | tmp[13]; mem->flags = tmp[0]; - pnp_register_mem_resource(option, mem); + pnp_register_mem_resource(dev, option, mem); } /* * Add 32-bit fixed memory resource to resources list. */ -static void __init isapnp_parse_fixed_mem32_resource(struct pnp_option *option, +static void __init isapnp_parse_fixed_mem32_resource(struct pnp_dev *dev, + struct pnp_option *option, int size) { unsigned char tmp[9]; @@ -572,7 +579,7 @@ static void __init isapnp_parse_fixed_mem32_resource(struct pnp_option *option, mem->size = (tmp[8] << 24) | (tmp[7] << 16) | (tmp[6] << 8) | tmp[5]; mem->align = 0; mem->flags = tmp[0]; - pnp_register_mem_resource(option, mem); + pnp_register_mem_resource(dev, option, mem); } /* @@ -656,13 +663,13 @@ static int __init isapnp_create_device(struct pnp_card *card, case _STAG_IRQ: if (size < 2 || size > 3) goto __skip; - isapnp_parse_irq_resource(option, size); + isapnp_parse_irq_resource(dev, option, size); size = 0; break; case _STAG_DMA: if (size != 2) goto __skip; - isapnp_parse_dma_resource(option, size); + isapnp_parse_dma_resource(dev, option, size); size = 0; break; case _STAG_STARTDEP: @@ -682,17 +689,18 @@ static int __init isapnp_create_device(struct pnp_card *card, if (size != 0) goto __skip; priority = 0; + dev_dbg(&dev->dev, "end dependent options\n"); break; case _STAG_IOPORT: if (size != 7) goto __skip; - isapnp_parse_port_resource(option, size); + isapnp_parse_port_resource(dev, option, size); size = 0; break; case _STAG_FIXEDIO: if (size != 3) goto __skip; - isapnp_parse_fixed_port_resource(option, size); + isapnp_parse_fixed_port_resource(dev, option, size); size = 0; break; case _STAG_VENDOR: @@ -700,7 +708,7 @@ static int __init isapnp_create_device(struct pnp_card *card, case _LTAG_MEMRANGE: if (size != 9) goto __skip; - isapnp_parse_mem_resource(option, size); + isapnp_parse_mem_resource(dev, option, size); size = 0; break; case _LTAG_ANSISTR: @@ -715,13 +723,13 @@ static int __init isapnp_create_device(struct pnp_card *card, case _LTAG_MEM32RANGE: if (size != 17) goto __skip; - isapnp_parse_mem32_resource(option, size); + isapnp_parse_mem32_resource(dev, option, size); size = 0; break; case _LTAG_FIXEDMEM32RANGE: if (size != 9) goto __skip; - isapnp_parse_fixed_mem32_resource(option, size); + isapnp_parse_fixed_mem32_resource(dev, option, size); size = 0; break; case _STAG_END: diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index baaf60212779..32454aa07ebc 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -410,7 +410,8 @@ acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle, pnpacpi_allocated_resource, res); } -static __init void pnpacpi_parse_dma_option(struct pnp_option *option, +static __init void pnpacpi_parse_dma_option(struct pnp_dev *dev, + struct pnp_option *option, struct acpi_resource_dma *p) { int i; @@ -427,10 +428,11 @@ static __init void pnpacpi_parse_dma_option(struct pnp_option *option, dma->flags = dma_flags(p->type, p->bus_master, p->transfer); - pnp_register_dma_resource(option, dma); + pnp_register_dma_resource(dev, option, dma); } -static __init void pnpacpi_parse_irq_option(struct pnp_option *option, +static __init void pnpacpi_parse_irq_option(struct pnp_dev *dev, + struct pnp_option *option, struct acpi_resource_irq *p) { int i; @@ -447,10 +449,11 @@ static __init void pnpacpi_parse_irq_option(struct pnp_option *option, __set_bit(p->interrupts[i], irq->map); irq->flags = irq_flags(p->triggering, p->polarity, p->sharable); - pnp_register_irq_resource(option, irq); + pnp_register_irq_resource(dev, option, irq); } -static __init void pnpacpi_parse_ext_irq_option(struct pnp_option *option, +static __init void pnpacpi_parse_ext_irq_option(struct pnp_dev *dev, + struct pnp_option *option, struct acpi_resource_extended_irq *p) { int i; @@ -467,10 +470,11 @@ static __init void pnpacpi_parse_ext_irq_option(struct pnp_option *option, __set_bit(p->interrupts[i], irq->map); irq->flags = irq_flags(p->triggering, p->polarity, p->sharable); - pnp_register_irq_resource(option, irq); + pnp_register_irq_resource(dev, option, irq); } -static __init void pnpacpi_parse_port_option(struct pnp_option *option, +static __init void pnpacpi_parse_port_option(struct pnp_dev *dev, + struct pnp_option *option, struct acpi_resource_io *io) { struct pnp_port *port; @@ -486,10 +490,11 @@ static __init void pnpacpi_parse_port_option(struct pnp_option *option, port->size = io->address_length; port->flags = ACPI_DECODE_16 == io->io_decode ? PNP_PORT_FLAG_16BITADDR : 0; - pnp_register_port_resource(option, port); + pnp_register_port_resource(dev, option, port); } -static __init void pnpacpi_parse_fixed_port_option(struct pnp_option *option, +static __init void pnpacpi_parse_fixed_port_option(struct pnp_dev *dev, + struct pnp_option *option, struct acpi_resource_fixed_io *io) { struct pnp_port *port; @@ -503,10 +508,11 @@ static __init void pnpacpi_parse_fixed_port_option(struct pnp_option *option, port->size = io->address_length; port->align = 0; port->flags = PNP_PORT_FLAG_FIXED; - pnp_register_port_resource(option, port); + pnp_register_port_resource(dev, option, port); } -static __init void pnpacpi_parse_mem24_option(struct pnp_option *option, +static __init void pnpacpi_parse_mem24_option(struct pnp_dev *dev, + struct pnp_option *option, struct acpi_resource_memory24 *p) { struct pnp_mem *mem; @@ -524,10 +530,11 @@ static __init void pnpacpi_parse_mem24_option(struct pnp_option *option, mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? IORESOURCE_MEM_WRITEABLE : 0; - pnp_register_mem_resource(option, mem); + pnp_register_mem_resource(dev, option, mem); } -static __init void pnpacpi_parse_mem32_option(struct pnp_option *option, +static __init void pnpacpi_parse_mem32_option(struct pnp_dev *dev, + struct pnp_option *option, struct acpi_resource_memory32 *p) { struct pnp_mem *mem; @@ -545,10 +552,11 @@ static __init void pnpacpi_parse_mem32_option(struct pnp_option *option, mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? IORESOURCE_MEM_WRITEABLE : 0; - pnp_register_mem_resource(option, mem); + pnp_register_mem_resource(dev, option, mem); } -static __init void pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, +static __init void pnpacpi_parse_fixed_mem32_option(struct pnp_dev *dev, + struct pnp_option *option, struct acpi_resource_fixed_memory32 *p) { struct pnp_mem *mem; @@ -565,10 +573,11 @@ static __init void pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? IORESOURCE_MEM_WRITEABLE : 0; - pnp_register_mem_resource(option, mem); + pnp_register_mem_resource(dev, option, mem); } -static __init void pnpacpi_parse_address_option(struct pnp_option *option, +static __init void pnpacpi_parse_address_option(struct pnp_dev *dev, + struct pnp_option *option, struct acpi_resource *r) { struct acpi_resource_address64 addr, *p = &addr; @@ -596,7 +605,7 @@ static __init void pnpacpi_parse_address_option(struct pnp_option *option, mem->flags = (p->info.mem.write_protect == ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0; - pnp_register_mem_resource(option, mem); + pnp_register_mem_resource(dev, option, mem); } else if (p->resource_type == ACPI_IO_RANGE) { port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); if (!port) @@ -605,7 +614,7 @@ static __init void pnpacpi_parse_address_option(struct pnp_option *option, port->size = p->address_length; port->align = 0; port->flags = PNP_PORT_FLAG_FIXED; - pnp_register_port_resource(option, port); + pnp_register_port_resource(dev, option, port); } } @@ -625,11 +634,11 @@ static __init acpi_status pnpacpi_option_resource(struct acpi_resource *res, switch (res->type) { case ACPI_RESOURCE_TYPE_IRQ: - pnpacpi_parse_irq_option(option, &res->data.irq); + pnpacpi_parse_irq_option(dev, option, &res->data.irq); break; case ACPI_RESOURCE_TYPE_DMA: - pnpacpi_parse_dma_option(option, &res->data.dma); + pnpacpi_parse_dma_option(dev, option, &res->data.dma); break; case ACPI_RESOURCE_TYPE_START_DEPENDENT: @@ -664,14 +673,16 @@ static __init acpi_status pnpacpi_option_resource(struct acpi_resource *res, } parse_data->option = parse_data->option_independent; parse_data->option_independent = NULL; + dev_dbg(&dev->dev, "end dependent options\n"); break; case ACPI_RESOURCE_TYPE_IO: - pnpacpi_parse_port_option(option, &res->data.io); + pnpacpi_parse_port_option(dev, option, &res->data.io); break; case ACPI_RESOURCE_TYPE_FIXED_IO: - pnpacpi_parse_fixed_port_option(option, &res->data.fixed_io); + pnpacpi_parse_fixed_port_option(dev, option, + &res->data.fixed_io); break; case ACPI_RESOURCE_TYPE_VENDOR: @@ -679,29 +690,30 @@ static __init acpi_status pnpacpi_option_resource(struct acpi_resource *res, break; case ACPI_RESOURCE_TYPE_MEMORY24: - pnpacpi_parse_mem24_option(option, &res->data.memory24); + pnpacpi_parse_mem24_option(dev, option, &res->data.memory24); break; case ACPI_RESOURCE_TYPE_MEMORY32: - pnpacpi_parse_mem32_option(option, &res->data.memory32); + pnpacpi_parse_mem32_option(dev, option, &res->data.memory32); break; case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: - pnpacpi_parse_fixed_mem32_option(option, + pnpacpi_parse_fixed_mem32_option(dev, option, &res->data.fixed_memory32); break; case ACPI_RESOURCE_TYPE_ADDRESS16: case ACPI_RESOURCE_TYPE_ADDRESS32: case ACPI_RESOURCE_TYPE_ADDRESS64: - pnpacpi_parse_address_option(option, res); + pnpacpi_parse_address_option(dev, option, res); break; case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: break; case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: - pnpacpi_parse_ext_irq_option(option, &res->data.extended_irq); + pnpacpi_parse_ext_irq_option(dev, option, + &res->data.extended_irq); break; case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index 948a661280d7..70aa559b3f8c 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c @@ -263,7 +263,8 @@ len_err: * Resource Configuration Options */ -static __init void pnpbios_parse_mem_option(unsigned char *p, int size, +static __init void pnpbios_parse_mem_option(struct pnp_dev *dev, + unsigned char *p, int size, struct pnp_option *option) { struct pnp_mem *mem; @@ -276,10 +277,11 @@ static __init void pnpbios_parse_mem_option(unsigned char *p, int size, mem->align = (p[9] << 8) | p[8]; mem->size = ((p[11] << 8) | p[10]) << 8; mem->flags = p[3]; - pnp_register_mem_resource(option, mem); + pnp_register_mem_resource(dev, option, mem); } -static __init void pnpbios_parse_mem32_option(unsigned char *p, int size, +static __init void pnpbios_parse_mem32_option(struct pnp_dev *dev, + unsigned char *p, int size, struct pnp_option *option) { struct pnp_mem *mem; @@ -292,10 +294,11 @@ static __init void pnpbios_parse_mem32_option(unsigned char *p, int size, mem->align = (p[15] << 24) | (p[14] << 16) | (p[13] << 8) | p[12]; mem->size = (p[19] << 24) | (p[18] << 16) | (p[17] << 8) | p[16]; mem->flags = p[3]; - pnp_register_mem_resource(option, mem); + pnp_register_mem_resource(dev, option, mem); } -static __init void pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, +static __init void pnpbios_parse_fixed_mem32_option(struct pnp_dev *dev, + unsigned char *p, int size, struct pnp_option *option) { struct pnp_mem *mem; @@ -307,11 +310,12 @@ static __init void pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, mem->size = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8]; mem->align = 0; mem->flags = p[3]; - pnp_register_mem_resource(option, mem); + pnp_register_mem_resource(dev, option, mem); } -static __init void pnpbios_parse_irq_option(unsigned char *p, int size, - struct pnp_option *option) +static __init void pnpbios_parse_irq_option(struct pnp_dev *dev, + unsigned char *p, int size, + struct pnp_option *option) { struct pnp_irq *irq; unsigned long bits; @@ -325,11 +329,12 @@ static __init void pnpbios_parse_irq_option(unsigned char *p, int size, irq->flags = p[3]; else irq->flags = IORESOURCE_IRQ_HIGHEDGE; - pnp_register_irq_resource(option, irq); + pnp_register_irq_resource(dev, option, irq); } -static __init void pnpbios_parse_dma_option(unsigned char *p, int size, - struct pnp_option *option) +static __init void pnpbios_parse_dma_option(struct pnp_dev *dev, + unsigned char *p, int size, + struct pnp_option *option) { struct pnp_dma *dma; @@ -338,10 +343,11 @@ static __init void pnpbios_parse_dma_option(unsigned char *p, int size, return; dma->map = p[1]; dma->flags = p[2]; - pnp_register_dma_resource(option, dma); + pnp_register_dma_resource(dev, option, dma); } -static __init void pnpbios_parse_port_option(unsigned char *p, int size, +static __init void pnpbios_parse_port_option(struct pnp_dev *dev, + unsigned char *p, int size, struct pnp_option *option) { struct pnp_port *port; @@ -354,10 +360,11 @@ static __init void pnpbios_parse_port_option(unsigned char *p, int size, port->align = p[6]; port->size = p[7]; port->flags = p[1] ? PNP_PORT_FLAG_16BITADDR : 0; - pnp_register_port_resource(option, port); + pnp_register_port_resource(dev, option, port); } -static __init void pnpbios_parse_fixed_port_option(unsigned char *p, int size, +static __init void pnpbios_parse_fixed_port_option(struct pnp_dev *dev, + unsigned char *p, int size, struct pnp_option *option) { struct pnp_port *port; @@ -369,7 +376,7 @@ static __init void pnpbios_parse_fixed_port_option(unsigned char *p, int size, port->size = p[3]; port->align = 0; port->flags = PNP_PORT_FLAG_FIXED; - pnp_register_port_resource(option, port); + pnp_register_port_resource(dev, option, port); } static __init unsigned char * @@ -403,37 +410,37 @@ pnpbios_parse_resource_option_data(unsigned char *p, unsigned char *end, case LARGE_TAG_MEM: if (len != 9) goto len_err; - pnpbios_parse_mem_option(p, len, option); + pnpbios_parse_mem_option(dev, p, len, option); break; case LARGE_TAG_MEM32: if (len != 17) goto len_err; - pnpbios_parse_mem32_option(p, len, option); + pnpbios_parse_mem32_option(dev, p, len, option); break; case LARGE_TAG_FIXEDMEM32: if (len != 9) goto len_err; - pnpbios_parse_fixed_mem32_option(p, len, option); + pnpbios_parse_fixed_mem32_option(dev, p, len, option); break; case SMALL_TAG_IRQ: if (len < 2 || len > 3) goto len_err; - pnpbios_parse_irq_option(p, len, option); + pnpbios_parse_irq_option(dev, p, len, option); break; case SMALL_TAG_DMA: if (len != 2) goto len_err; - pnpbios_parse_dma_option(p, len, option); + pnpbios_parse_dma_option(dev, p, len, option); break; case SMALL_TAG_PORT: if (len != 7) goto len_err; - pnpbios_parse_port_option(p, len, option); + pnpbios_parse_port_option(dev, p, len, option); break; case SMALL_TAG_VENDOR: @@ -443,7 +450,7 @@ pnpbios_parse_resource_option_data(unsigned char *p, unsigned char *end, case SMALL_TAG_FIXEDPORT: if (len != 3) goto len_err; - pnpbios_parse_fixed_port_option(p, len, option); + pnpbios_parse_fixed_port_option(dev, p, len, option); break; case SMALL_TAG_STARTDEP: @@ -464,6 +471,7 @@ pnpbios_parse_resource_option_data(unsigned char *p, unsigned char *end, printk(KERN_WARNING "PnPBIOS: Missing SMALL_TAG_STARTDEP tag\n"); option = option_independent; + dev_dbg(&dev->dev, "end dependent options\n"); break; case SMALL_TAG_END: diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c index e50ebcffb962..eee6d8eddcb4 100644 --- a/drivers/pnp/resource.c +++ b/drivers/pnp/resource.c @@ -53,6 +53,8 @@ struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev) if (dev->independent) dev_err(&dev->dev, "independent resource already registered\n"); dev->independent = option; + + dev_dbg(&dev->dev, "new independent option\n"); return option; } @@ -70,12 +72,18 @@ struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev, parent->next = option; } else dev->dependent = option; + + dev_dbg(&dev->dev, "new dependent option (priority %#x)\n", priority); return option; } -int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data) +int pnp_register_irq_resource(struct pnp_dev *dev, struct pnp_option *option, + struct pnp_irq *data) { struct pnp_irq *ptr; +#ifdef DEBUG + char buf[PNP_IRQ_NR]; /* hex-encoded, so this is overkill but safe */ +#endif ptr = option->irq; while (ptr && ptr->next) @@ -94,10 +102,17 @@ int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data) pcibios_penalize_isa_irq(i, 0); } #endif + +#ifdef DEBUG + bitmap_scnprintf(buf, sizeof(buf), data->map, PNP_IRQ_NR); + dev_dbg(&dev->dev, " irq bitmask %s flags %#x\n", buf, + data->flags); +#endif return 0; } -int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data) +int pnp_register_dma_resource(struct pnp_dev *dev, struct pnp_option *option, + struct pnp_dma *data) { struct pnp_dma *ptr; @@ -109,10 +124,13 @@ int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data) else option->dma = data; + dev_dbg(&dev->dev, " dma bitmask %#x flags %#x\n", data->map, + data->flags); return 0; } -int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data) +int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option, + struct pnp_port *data) { struct pnp_port *ptr; @@ -124,10 +142,14 @@ int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data) else option->port = data; + dev_dbg(&dev->dev, " io " + "min %#x max %#x align %d size %d flags %#x\n", + data->min, data->max, data->align, data->size, data->flags); return 0; } -int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data) +int pnp_register_mem_resource(struct pnp_dev *dev, struct pnp_option *option, + struct pnp_mem *data) { struct pnp_mem *ptr; @@ -138,6 +160,10 @@ int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data) ptr->next = data; else option->mem = data; + + dev_dbg(&dev->dev, " mem " + "min %#x max %#x align %d size %d flags %#x\n", + data->min, data->max, data->align, data->size, data->flags); return 0; } diff --git a/include/linux/pnp.h b/include/linux/pnp.h index 7639db83ce3f..a4c2bf361596 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -382,11 +382,14 @@ extern struct list_head pnp_cards; 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, +int pnp_register_irq_resource(struct pnp_dev *dev, struct pnp_option *option, + struct pnp_irq *data); +int pnp_register_dma_resource(struct pnp_dev *dev, struct pnp_option *option, + struct pnp_dma *data); +int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option, struct pnp_port *data); -int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data); +int pnp_register_mem_resource(struct pnp_dev *dev, struct pnp_option *option, + struct pnp_mem *data); void pnp_init_resource_table(struct pnp_resource_table *table); int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res, int mode); @@ -430,10 +433,10 @@ 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 int pnp_register_irq_resource(struct pnp_dev *dev, struct pnp_option *option, struct pnp_irq *data) { return -ENODEV; } +static inline int pnp_register_dma_resource(struct pnp_dev *dev, struct pnp_option *option, struct pnp_dma *data) { return -ENODEV; } +static inline int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option, struct pnp_port *data) { return -ENODEV; } +static inline int pnp_register_mem_resource(struct pnp_dev *dev, struct pnp_option *option, struct pnp_mem *data) { return -ENODEV; } static inline void pnp_init_resource_table(struct pnp_resource_table *table) { } 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; } -- cgit v1.2.3 From 59284cb4099411bc6f4915a5a4cb76414440c447 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:05 -0600 Subject: PNP: remove pnp_resource_table from internal get/set interfaces 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 Acked-By: Rene Herman Signed-off-by: Len Brown --- drivers/pnp/interface.c | 2 +- drivers/pnp/isapnp/core.c | 11 +++++------ drivers/pnp/manager.c | 2 +- drivers/pnp/pnpacpi/core.c | 8 +++----- drivers/pnp/pnpbios/core.c | 10 ++++------ include/linux/pnp.h | 4 ++-- 6 files changed, 16 insertions(+), 21 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index 982658477a58..e882896bdbd7 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c @@ -364,7 +364,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, 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; } diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 38ff64dce9c0..1ae3d8996156 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -976,21 +976,20 @@ static int isapnp_read_resources(struct pnp_dev *dev, 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); diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c index c28caf272c11..6a1f0b0b24b3 100644 --- a/drivers/pnp/manager.c +++ b/drivers/pnp/manager.c @@ -473,7 +473,7 @@ int pnp_start_dev(struct pnp_dev *dev) 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; } diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 27546873880c..590fbcb0ee89 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c @@ -73,8 +73,7 @@ static int __init ispnpidacpi(char *id) 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 @@ static int pnpacpi_get_resources(struct pnp_dev *dev, 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 @@ static int pnpacpi_set_resources(struct pnp_dev *dev, 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; diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c index 6af2be2c1d67..9852755b5590 100644 --- a/drivers/pnp/pnpbios/core.c +++ b/drivers/pnp/pnpbios/core.c @@ -204,8 +204,7 @@ static int pnp_dock_thread(void *unused) #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 @@ static int pnpbios_get_resources(struct pnp_dev *dev, 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 @@ static int pnpbios_set_resources(struct pnp_dev *dev, 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; } diff --git a/include/linux/pnp.h b/include/linux/pnp.h index a4c2bf361596..8d7c9bc2fdbb 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -328,8 +328,8 @@ struct pnp_protocol { 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 */ -- cgit v1.2.3 From 4ab55d8d4f7b910c4c60e0f8ff70d0dfdd484f02 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:06 -0600 Subject: PNP: remove more pnp_resource_table arguments 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 Acked-By: Rene Herman Signed-off-by: Len Brown --- 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(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 1ae3d8996156..b8e639f4f227 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -932,9 +932,9 @@ EXPORT_SYMBOL(isapnp_cfg_begin); 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); @@ -982,7 +982,7 @@ static int isapnp_get_resources(struct pnp_dev *dev) 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; } diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 590fbcb0ee89..3fd2416d6795 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c @@ -77,8 +77,7 @@ static int pnpacpi_get_resources(struct pnp_dev *dev) { 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 @@ static int pnpacpi_set_resources(struct pnp_dev *dev) 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 @@ static int __init pnpacpi_add_device(struct acpi_device *device) 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 @@ static int __init pnpacpi_add_device(struct acpi_device *device) } 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)); diff --git a/drivers/pnp/pnpacpi/pnpacpi.h b/drivers/pnp/pnpacpi/pnpacpi.h index 116c591d8634..db0c4f25c2a3 100644 --- a/drivers/pnp/pnpacpi/pnpacpi.h +++ b/drivers/pnp/pnpacpi/pnpacpi.h @@ -5,8 +5,8 @@ #include #include -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 diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 32454aa07ebc..8a0617687723 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -76,10 +76,11 @@ static void decode_irq_flags(int flag, int *triggering, int *polarity) } } -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; @@ -172,9 +173,10 @@ static int dma_flags(int type, int bus_master, int transfer) 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; @@ -197,9 +199,10 @@ static void pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, } } -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; @@ -223,10 +226,11 @@ static void pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res, } } -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; @@ -251,7 +255,7 @@ static void pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res, } } -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; @@ -268,11 +272,11 @@ static void pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res 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); @@ -281,7 +285,7 @@ static void pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res 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; @@ -300,7 +304,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, */ 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, @@ -311,7 +315,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, 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)); @@ -319,7 +323,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, 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); @@ -331,7 +335,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, 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); @@ -345,21 +349,21 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, 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); @@ -367,7 +371,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, 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: @@ -381,7 +385,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, 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, @@ -400,14 +404,15 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, 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_dev *dev, @@ -727,9 +732,9 @@ static __init acpi_status pnpacpi_option_resource(struct acpi_resource *res, 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; @@ -959,9 +964,9 @@ static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, 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; diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c index 9852755b5590..1711e7f29613 100644 --- a/drivers/pnp/pnpbios/core.c +++ b/drivers/pnp/pnpbios/core.c @@ -219,7 +219,7 @@ static int pnpbios_get_resources(struct pnp_dev *dev) 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 @@ static int pnpbios_set_resources(struct pnp_dev *dev) 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; } diff --git a/drivers/pnp/pnpbios/pnpbios.h b/drivers/pnp/pnpbios/pnpbios.h index d8cb2fd1f127..42343fc753ba 100644 --- a/drivers/pnp/pnpbios/pnpbios.h +++ b/drivers/pnp/pnpbios/pnpbios.h @@ -28,8 +28,8 @@ extern int pnp_bios_present(void); 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); diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index 70aa559b3f8c..1b8f30ff192a 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c @@ -54,9 +54,9 @@ inline void pcibios_penalize_isa_irq(int irq, int active) * 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_irqresource(struct pnp_resource_table *res, } } -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_dmaresource(struct pnp_resource_table *res, } } -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_ioresource(struct pnp_resource_table *res, } } -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 void pnpbios_parse_allocated_memresource(struct pnp_resource_table *res, } } -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 @@ static unsigned char *pnpbios_parse_allocated_resource_data(unsigned char *p, 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 @@ static unsigned char *pnpbios_parse_allocated_resource_data(unsigned char *p, 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 @@ static unsigned char *pnpbios_parse_allocated_resource_data(unsigned char *p, 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 @@ static unsigned char *pnpbios_parse_allocated_resource_data(unsigned char *p, 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 @@ static unsigned char *pnpbios_parse_allocated_resource_data(unsigned char *p, 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 @@ static unsigned char *pnpbios_parse_allocated_resource_data(unsigned char *p, 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 @@ static unsigned char *pnpbios_parse_allocated_resource_data(unsigned char *p, 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 @@ static unsigned char *pnpbios_parse_allocated_resource_data(unsigned char *p, 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: @@ -660,12 +660,12 @@ static void pnpbios_encode_fixed_port(unsigned char *p, struct resource *res) 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; @@ -774,7 +774,7 @@ int __init pnpbios_parse_data_stream(struct pnp_dev *dev, 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); @@ -786,25 +786,25 @@ int __init pnpbios_parse_data_stream(struct pnp_dev *dev, 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; -- cgit v1.2.3 From 72dcc883d8e5b59105e75ee5265442e458740575 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:07 -0600 Subject: PNP: add debug output to encoders Add debug output to encoders (enabled by CONFIG_PNP_DEBUG). This uses dev_printk, so I had to add pnp_dev arguments at the same time. Signed-off-by: Bjorn Helgaas Acked-By: Rene Herman Signed-off-by: Len Brown --- drivers/pnp/isapnp/core.c | 18 +++++++-- drivers/pnp/pnpacpi/core.c | 2 + drivers/pnp/pnpacpi/rsparser.c | 90 ++++++++++++++++++++++++++++++------------ drivers/pnp/pnpbios/core.c | 2 + drivers/pnp/pnpbios/rsparser.c | 58 ++++++++++++++++++++------- 5 files changed, 127 insertions(+), 43 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index b8e639f4f227..6740016437d9 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -980,6 +980,7 @@ static int isapnp_get_resources(struct pnp_dev *dev) { int ret; + dev_dbg(&dev->dev, "get resources\n"); pnp_init_resource_table(&dev->res); isapnp_cfg_begin(dev->card->number, dev->number); ret = isapnp_read_resources(dev); @@ -992,15 +993,19 @@ static int isapnp_set_resources(struct pnp_dev *dev) struct pnp_resource_table *res = &dev->res; int tmp; + dev_dbg(&dev->dev, "set resources\n"); 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++) + tmp++) { + dev_dbg(&dev->dev, " set io %d to %#llx\n", + tmp, (unsigned long long) res->port_resource[tmp].start); isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1), res->port_resource[tmp].start); + } for (tmp = 0; tmp < ISAPNP_MAX_IRQ && (res->irq_resource[tmp]. @@ -1009,22 +1014,29 @@ static int isapnp_set_resources(struct pnp_dev *dev) int irq = res->irq_resource[tmp].start; if (irq == 2) irq = 9; + dev_dbg(&dev->dev, " set irq %d to %d\n", tmp, irq); 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++) + tmp++) { + dev_dbg(&dev->dev, " set dma %d to %lld\n", + tmp, (unsigned long long) res->dma_resource[tmp].start); 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++) + tmp++) { + dev_dbg(&dev->dev, " set mem %d to %#llx\n", + tmp, (unsigned long long) res->mem_resource[tmp].start); isapnp_write_word(ISAPNP_CFG_MEM + (tmp << 3), (res->mem_resource[tmp].start >> 8) & 0xffff); + } /* FIXME: We aren't handling 32bit mems properly here */ isapnp_activate(dev->number); isapnp_cfg_end(); diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 3fd2416d6795..1ac894d2df5a 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c @@ -77,6 +77,7 @@ static int pnpacpi_get_resources(struct pnp_dev *dev) { acpi_status status; + dev_dbg(&dev->dev, "get resources\n"); status = pnpacpi_parse_allocated_resource(dev); return ACPI_FAILURE(status) ? -ENODEV : 0; } @@ -88,6 +89,7 @@ static int pnpacpi_set_resources(struct pnp_dev *dev) int ret; acpi_status status; + dev_dbg(&dev->dev, "set resources\n"); ret = pnpacpi_build_resource_template(dev, &buffer); if (ret) return ret; diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 8a0617687723..c5adf7631ac2 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -408,6 +408,8 @@ acpi_status pnpacpi_parse_allocated_resource(struct pnp_dev *dev) { acpi_handle handle = dev->data; + dev_dbg(&dev->dev, "parse allocated resources\n"); + /* Blank the resource table values */ pnp_init_resource_table(&dev->res); @@ -738,6 +740,8 @@ acpi_status __init pnpacpi_parse_resource_option_data(struct pnp_dev *dev) acpi_status status; struct acpipnp_parse_option_s parse_data; + dev_dbg(&dev->dev, "parse resource options\n"); + parse_data.option = pnp_register_independent_option(dev); if (!parse_data.option) return AE_ERROR; @@ -814,7 +818,7 @@ int pnpacpi_build_resource_template(struct pnp_dev *dev, 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); @@ -829,7 +833,8 @@ int pnpacpi_build_resource_template(struct pnp_dev *dev, return 0; } -static void pnpacpi_encode_irq(struct acpi_resource *resource, +static void pnpacpi_encode_irq(struct pnp_dev *dev, + struct acpi_resource *resource, struct resource *p) { struct acpi_resource_irq *irq = &resource->data.irq; @@ -844,9 +849,15 @@ static void pnpacpi_encode_irq(struct acpi_resource *resource, irq->sharable = ACPI_SHARED; irq->interrupt_count = 1; irq->interrupts[0] = p->start; + + dev_dbg(&dev->dev, " encode irq %d %s %s %s\n", (int) p->start, + triggering == ACPI_LEVEL_SENSITIVE ? "level" : "edge", + polarity == ACPI_ACTIVE_LOW ? "low" : "high", + irq->sharable == ACPI_SHARED ? "shared" : "exclusive"); } -static void pnpacpi_encode_ext_irq(struct acpi_resource *resource, +static void pnpacpi_encode_ext_irq(struct pnp_dev *dev, + struct acpi_resource *resource, struct resource *p) { struct acpi_resource_extended_irq *extended_irq = &resource->data.extended_irq; @@ -862,9 +873,15 @@ static void pnpacpi_encode_ext_irq(struct acpi_resource *resource, extended_irq->sharable = ACPI_SHARED; extended_irq->interrupt_count = 1; extended_irq->interrupts[0] = p->start; + + dev_dbg(&dev->dev, " encode irq %d %s %s %s\n", (int) p->start, + triggering == ACPI_LEVEL_SENSITIVE ? "level" : "edge", + polarity == ACPI_ACTIVE_LOW ? "low" : "high", + extended_irq->sharable == ACPI_SHARED ? "shared" : "exclusive"); } -static void pnpacpi_encode_dma(struct acpi_resource *resource, +static void pnpacpi_encode_dma(struct pnp_dev *dev, + struct acpi_resource *resource, struct resource *p) { struct acpi_resource_dma *dma = &resource->data.dma; @@ -898,9 +915,14 @@ static void pnpacpi_encode_dma(struct acpi_resource *resource, dma->bus_master = !!(p->flags & IORESOURCE_DMA_MASTER); dma->channel_count = 1; dma->channels[0] = p->start; + + dev_dbg(&dev->dev, " encode dma %d " + "type %#x transfer %#x master %d\n", + (int) p->start, dma->type, dma->transfer, dma->bus_master); } -static void pnpacpi_encode_io(struct acpi_resource *resource, +static void pnpacpi_encode_io(struct pnp_dev *dev, + struct acpi_resource *resource, struct resource *p) { struct acpi_resource_io *io = &resource->data.io; @@ -912,18 +934,27 @@ static void pnpacpi_encode_io(struct acpi_resource *resource, io->maximum = p->end; io->alignment = 0; /* Correct? */ io->address_length = p->end - p->start + 1; + + dev_dbg(&dev->dev, " encode io %#llx-%#llx decode %#x\n", + (unsigned long long) p->start, (unsigned long long) p->end, + io->io_decode); } -static void pnpacpi_encode_fixed_io(struct acpi_resource *resource, +static void pnpacpi_encode_fixed_io(struct pnp_dev *dev, + struct acpi_resource *resource, struct resource *p) { 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; + + dev_dbg(&dev->dev, " encode fixed_io %#llx-%#llx\n", + (unsigned long long) p->start, (unsigned long long) p->end); } -static void pnpacpi_encode_mem24(struct acpi_resource *resource, +static void pnpacpi_encode_mem24(struct pnp_dev *dev, + struct acpi_resource *resource, struct resource *p) { struct acpi_resource_memory24 *memory24 = &resource->data.memory24; @@ -936,9 +967,14 @@ static void pnpacpi_encode_mem24(struct acpi_resource *resource, memory24->maximum = p->end; memory24->alignment = 0; memory24->address_length = p->end - p->start + 1; + + dev_dbg(&dev->dev, " encode mem24 %#llx-%#llx write_protect %#x\n", + (unsigned long long) p->start, (unsigned long long) p->end, + memory24->write_protect); } -static void pnpacpi_encode_mem32(struct acpi_resource *resource, +static void pnpacpi_encode_mem32(struct pnp_dev *dev, + struct acpi_resource *resource, struct resource *p) { struct acpi_resource_memory32 *memory32 = &resource->data.memory32; @@ -950,9 +986,14 @@ static void pnpacpi_encode_mem32(struct acpi_resource *resource, memory32->maximum = p->end; memory32->alignment = 0; memory32->address_length = p->end - p->start + 1; + + dev_dbg(&dev->dev, " encode mem32 %#llx-%#llx write_protect %#x\n", + (unsigned long long) p->start, (unsigned long long) p->end, + memory32->write_protect); } -static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, +static void pnpacpi_encode_fixed_mem32(struct pnp_dev *dev, + struct acpi_resource *resource, struct resource *p) { struct acpi_resource_fixed_memory32 *fixed_memory32 = &resource->data.fixed_memory32; @@ -962,6 +1003,11 @@ static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; fixed_memory32->address = p->start; fixed_memory32->address_length = p->end - p->start + 1; + + dev_dbg(&dev->dev, " encode fixed_mem32 %#llx-%#llx " + "write_protect %#x\n", + (unsigned long long) p->start, (unsigned long long) p->end, + fixed_memory32->write_protect); } int pnpacpi_encode_resources(struct pnp_dev *dev, struct acpi_buffer *buffer) @@ -973,57 +1019,49 @@ int pnpacpi_encode_resources(struct pnp_dev *dev, struct acpi_buffer *buffer) struct acpi_resource *resource = buffer->pointer; int port = 0, irq = 0, dma = 0, mem = 0; - pnp_dbg("res cnt %d", res_cnt); + dev_dbg(&dev->dev, "encode %d resources\n", res_cnt); while (i < res_cnt) { switch (resource->type) { case ACPI_RESOURCE_TYPE_IRQ: - pnp_dbg("Encode irq"); - pnpacpi_encode_irq(resource, + pnpacpi_encode_irq(dev, resource, &res_table->irq_resource[irq]); irq++; break; case ACPI_RESOURCE_TYPE_DMA: - pnp_dbg("Encode dma"); - pnpacpi_encode_dma(resource, + pnpacpi_encode_dma(dev, resource, &res_table->dma_resource[dma]); dma++; break; case ACPI_RESOURCE_TYPE_IO: - pnp_dbg("Encode io"); - pnpacpi_encode_io(resource, + pnpacpi_encode_io(dev, resource, &res_table->port_resource[port]); port++; break; case ACPI_RESOURCE_TYPE_FIXED_IO: - pnp_dbg("Encode fixed io"); - pnpacpi_encode_fixed_io(resource, + pnpacpi_encode_fixed_io(dev, resource, &res_table-> port_resource[port]); port++; break; case ACPI_RESOURCE_TYPE_MEMORY24: - pnp_dbg("Encode mem24"); - pnpacpi_encode_mem24(resource, + pnpacpi_encode_mem24(dev, resource, &res_table->mem_resource[mem]); mem++; break; case ACPI_RESOURCE_TYPE_MEMORY32: - pnp_dbg("Encode mem32"); - pnpacpi_encode_mem32(resource, + pnpacpi_encode_mem32(dev, resource, &res_table->mem_resource[mem]); mem++; break; case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: - pnp_dbg("Encode fixed mem32"); - pnpacpi_encode_fixed_mem32(resource, + pnpacpi_encode_fixed_mem32(dev, resource, &res_table-> mem_resource[mem]); mem++; break; case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: - pnp_dbg("Encode ext irq"); - pnpacpi_encode_ext_irq(resource, + pnpacpi_encode_ext_irq(dev, resource, &res_table->irq_resource[irq]); irq++; break; diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c index 1711e7f29613..76d398531da6 100644 --- a/drivers/pnp/pnpbios/core.c +++ b/drivers/pnp/pnpbios/core.c @@ -212,6 +212,7 @@ static int pnpbios_get_resources(struct pnp_dev *dev) if (!pnpbios_is_dynamic(dev)) return -EPERM; + dev_dbg(&dev->dev, "get resources\n"); node = kzalloc(node_info.max_node_size, GFP_KERNEL); if (!node) return -1; @@ -234,6 +235,7 @@ static int pnpbios_set_resources(struct pnp_dev *dev) if (!pnpbios_is_dynamic(dev)) return -EPERM; + dev_dbg(&dev->dev, "set resources\n"); node = kzalloc(node_info.max_node_size, GFP_KERNEL); if (!node) return -1; diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index 1b8f30ff192a..7428f62db4d2 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c @@ -143,6 +143,8 @@ static unsigned char *pnpbios_parse_allocated_resource_data(struct pnp_dev *dev, if (!p) return NULL; + dev_dbg(&dev->dev, "parse allocated resources\n"); + /* Blank the resource table values */ pnp_init_resource_table(&dev->res); @@ -390,6 +392,8 @@ pnpbios_parse_resource_option_data(unsigned char *p, unsigned char *end, if (!p) return NULL; + dev_dbg(&dev->dev, "parse resource options\n"); + option_independent = option = pnp_register_independent_option(dev); if (!option) return NULL; @@ -574,7 +578,8 @@ len_err: * Allocated Resource Encoding */ -static void pnpbios_encode_mem(unsigned char *p, struct resource *res) +static void pnpbios_encode_mem(struct pnp_dev *dev, unsigned char *p, + struct resource *res) { unsigned long base = res->start; unsigned long len = res->end - res->start + 1; @@ -585,9 +590,13 @@ static void pnpbios_encode_mem(unsigned char *p, struct resource *res) p[7] = ((base >> 8) >> 8) & 0xff; p[10] = (len >> 8) & 0xff; p[11] = ((len >> 8) >> 8) & 0xff; + + dev_dbg(&dev->dev, " encode mem %#llx-%#llx\n", + (unsigned long long) res->start, (unsigned long long) res->end); } -static void pnpbios_encode_mem32(unsigned char *p, struct resource *res) +static void pnpbios_encode_mem32(struct pnp_dev *dev, unsigned char *p, + struct resource *res) { unsigned long base = res->start; unsigned long len = res->end - res->start + 1; @@ -604,9 +613,13 @@ static void pnpbios_encode_mem32(unsigned char *p, struct resource *res) p[17] = (len >> 8) & 0xff; p[18] = (len >> 16) & 0xff; p[19] = (len >> 24) & 0xff; + + dev_dbg(&dev->dev, " encode mem32 %#llx-%#llx\n", + (unsigned long long) res->start, (unsigned long long) res->end); } -static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource *res) +static void pnpbios_encode_fixed_mem32(struct pnp_dev *dev, unsigned char *p, + struct resource *res) { unsigned long base = res->start; unsigned long len = res->end - res->start + 1; @@ -619,26 +632,36 @@ static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource *res) p[9] = (len >> 8) & 0xff; p[10] = (len >> 16) & 0xff; p[11] = (len >> 24) & 0xff; + + dev_dbg(&dev->dev, " encode fixed_mem32 %#llx-%#llx\n", + (unsigned long long) res->start, (unsigned long long) res->end); } -static void pnpbios_encode_irq(unsigned char *p, struct resource *res) +static void pnpbios_encode_irq(struct pnp_dev *dev, unsigned char *p, + struct resource *res) { unsigned long map = 0; map = 1 << res->start; p[1] = map & 0xff; p[2] = (map >> 8) & 0xff; + + dev_dbg(&dev->dev, " encode irq %d\n", res->start); } -static void pnpbios_encode_dma(unsigned char *p, struct resource *res) +static void pnpbios_encode_dma(struct pnp_dev *dev, unsigned char *p, + struct resource *res) { unsigned long map = 0; map = 1 << res->start; p[1] = map & 0xff; + + dev_dbg(&dev->dev, " encode dma %d\n", res->start); } -static void pnpbios_encode_port(unsigned char *p, struct resource *res) +static void pnpbios_encode_port(struct pnp_dev *dev, unsigned char *p, + struct resource *res) { unsigned long base = res->start; unsigned long len = res->end - res->start + 1; @@ -648,9 +671,13 @@ static void pnpbios_encode_port(unsigned char *p, struct resource *res) p[4] = base & 0xff; p[5] = (base >> 8) & 0xff; p[7] = len & 0xff; + + dev_dbg(&dev->dev, " encode io %#llx-%#llx\n", + (unsigned long long) res->start, (unsigned long long) res->end); } -static void pnpbios_encode_fixed_port(unsigned char *p, struct resource *res) +static void pnpbios_encode_fixed_port(struct pnp_dev *dev, unsigned char *p, + struct resource *res) { unsigned long base = res->start; unsigned long len = res->end - res->start + 1; @@ -658,6 +685,9 @@ static void pnpbios_encode_fixed_port(unsigned char *p, struct resource *res) p[1] = base & 0xff; p[2] = (base >> 8) & 0xff; p[3] = len & 0xff; + + dev_dbg(&dev->dev, " encode fixed_io %#llx-%#llx\n", + (unsigned long long) res->start, (unsigned long long) res->end); } static unsigned char *pnpbios_encode_allocated_resource_data(struct pnp_dev @@ -688,42 +718,42 @@ static unsigned char *pnpbios_encode_allocated_resource_data(struct pnp_dev case LARGE_TAG_MEM: if (len != 9) goto len_err; - pnpbios_encode_mem(p, &res->mem_resource[mem]); + pnpbios_encode_mem(dev, p, &res->mem_resource[mem]); mem++; break; case LARGE_TAG_MEM32: if (len != 17) goto len_err; - pnpbios_encode_mem32(p, &res->mem_resource[mem]); + pnpbios_encode_mem32(dev, p, &res->mem_resource[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(dev, p, &res->mem_resource[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(dev, p, &res->irq_resource[irq]); irq++; break; case SMALL_TAG_DMA: if (len != 2) goto len_err; - pnpbios_encode_dma(p, &res->dma_resource[dma]); + pnpbios_encode_dma(dev, p, &res->dma_resource[dma]); dma++; break; case SMALL_TAG_PORT: if (len != 7) goto len_err; - pnpbios_encode_port(p, &res->port_resource[port]); + pnpbios_encode_port(dev, p, &res->port_resource[port]); port++; break; @@ -734,7 +764,7 @@ static unsigned char *pnpbios_encode_allocated_resource_data(struct pnp_dev case SMALL_TAG_FIXEDPORT: if (len != 3) goto len_err; - pnpbios_encode_fixed_port(p, &res->port_resource[port]); + pnpbios_encode_fixed_port(dev, p, &res->port_resource[port]); port++; break; -- cgit v1.2.3 From f44900020926b2cb06b87f0f52643d6285514fc3 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:09 -0600 Subject: PNP: add pnp_init_resources(struct pnp_dev *) interface Add pnp_init_resources(struct pnp_dev *) to 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 Acked-By: Rene Herman Signed-off-by: Len Brown --- 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(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index e882896bdbd7..cdc3ecfde6ef 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c @@ -351,14 +351,14 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, 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 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, 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)) diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 6740016437d9..6f1007548c93 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -424,7 +424,7 @@ static struct pnp_dev *__init isapnp_parse_device(struct pnp_card *card, dev->capabilities |= PNP_READ; dev->capabilities |= PNP_WRITE; dev->capabilities |= PNP_DISABLE; - pnp_init_resource_table(&dev->res); + pnp_init_resources(dev); return dev; } @@ -981,7 +981,7 @@ static int isapnp_get_resources(struct pnp_dev *dev) int ret; dev_dbg(&dev->dev, "get resources\n"); - 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(); diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c index 945c6201719d..c9af87a8fb16 100644 --- a/drivers/pnp/manager.c +++ b/drivers/pnp/manager.c @@ -272,6 +272,11 @@ void pnp_init_resource_table(struct pnp_resource_table *table) } } +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 diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 1ac894d2df5a..7e4512a60f58 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c @@ -212,7 +212,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) /* clear out the damaged flags */ if (!dev->active) - pnp_init_resource_table(&dev->res); + pnp_init_resources(dev); pnp_add_device(dev); num++; diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index c5adf7631ac2..33dbf3644f2b 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -410,8 +410,7 @@ acpi_status pnpacpi_parse_allocated_resource(struct pnp_dev *dev) dev_dbg(&dev->dev, "parse allocated resources\n"); - /* 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); diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c index 76d398531da6..f5477ca85956 100644 --- a/drivers/pnp/pnpbios/core.c +++ b/drivers/pnp/pnpbios/core.c @@ -347,7 +347,7 @@ static int __init insert_device(struct pnp_bios_node *node) /* 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); diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index 7428f62db4d2..e90a3d4360b2 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c @@ -145,8 +145,7 @@ static unsigned char *pnpbios_parse_allocated_resource_data(struct pnp_dev *dev, dev_dbg(&dev->dev, "parse allocated resources\n"); - /* Blank the resource table values */ - pnp_init_resource_table(&dev->res); + pnp_init_resources(dev); while ((char *)p < (char *)end) { diff --git a/include/linux/pnp.h b/include/linux/pnp.h index 8d7c9bc2fdbb..1737f071787a 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -391,6 +391,7 @@ int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option, int pnp_register_mem_resource(struct pnp_dev *dev, 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); @@ -438,6 +439,7 @@ static inline int pnp_register_dma_resource(struct pnp_dev *dev, struct pnp_opti static inline int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option, struct pnp_port *data) { return -ENODEV; } static inline int pnp_register_mem_resource(struct pnp_dev *dev, 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; } -- cgit v1.2.3 From af11cb2d521f9d7e10c565bafe8f2358772baa65 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:12 -0600 Subject: PNP: use dev_printk when possible Use dev_printk() when possible for more informative error messages. Signed-off-by: Bjorn Helgaas Acked-By: Rene Herman Signed-off-by: Len Brown --- drivers/pnp/isapnp/core.c | 37 +++++++++++++++++-------------------- drivers/pnp/pnpacpi/rsparser.c | 20 ++++++++++++-------- drivers/pnp/pnpbios/rsparser.c | 36 ++++++++++++++---------------------- 3 files changed, 43 insertions(+), 50 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 6f1007548c93..990d8cd6295c 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -737,9 +737,8 @@ static int __init isapnp_create_device(struct pnp_card *card, 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 %#x (card %i), " + "ignored\n", type, card->number); } __skip: if (size > 0) @@ -792,9 +791,8 @@ static void __init isapnp_parse_resource_map(struct pnp_card *card) 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 %#x, ignored\n", + type); } __skip: if (size > 0) @@ -841,13 +839,6 @@ static int __init isapnp_build_device_list(void) 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 eisa_id = header[0] | header[1] << 8 | header[2] << 16 | header[3] << 24; pnp_eisa_id_to_string(eisa_id, id); @@ -855,6 +846,13 @@ static int __init isapnp_build_device_list(void) 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 = %#x\n", checksum); +#endif INIT_LIST_HEAD(&card->devices); card->serial = (header[7] << 24) | (header[6] << 16) | (header[5] << 8) | @@ -862,9 +860,8 @@ static int __init isapnp_build_device_list(void) 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 %#x\n", + isapnp_checksum_value); card->checksum = isapnp_checksum_value; pnp_add_card(card); @@ -1134,13 +1131,13 @@ static int __init isapnp_init(void) 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"); } } } diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 33dbf3644f2b..bd41e4d4270c 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -110,7 +110,7 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_dev *dev, 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; @@ -263,7 +263,7 @@ static void pnpacpi_parse_allocated_address_space(struct pnp_dev *dev, 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; } @@ -397,7 +397,8 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, 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; } @@ -674,7 +675,8 @@ static __init acpi_status pnpacpi_option_resource(struct acpi_resource *res, 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; @@ -726,7 +728,8 @@ static __init acpi_status pnpacpi_option_resource(struct acpi_resource *res, 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; } @@ -808,7 +811,7 @@ int pnpacpi_build_resource_template(struct pnp_dev *dev, 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) @@ -823,7 +826,7 @@ int pnpacpi_build_resource_template(struct pnp_dev *dev, 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 */ @@ -1074,7 +1077,8 @@ int pnpacpi_encode_resources(struct pnp_dev *dev, struct acpi_buffer *buffer) 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++; diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index e90a3d4360b2..4390e3b41df0 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c @@ -241,9 +241,8 @@ static unsigned char *pnpbios_parse_allocated_resource_data(struct pnp_dev *dev, 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 %#x length %d\n", + tag, len); break; } @@ -254,8 +253,7 @@ len_err: 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; } @@ -471,8 +469,8 @@ pnpbios_parse_resource_option_data(unsigned char *p, unsigned char *end, 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; dev_dbg(&dev->dev, "end dependent options\n"); break; @@ -482,9 +480,8 @@ pnpbios_parse_resource_option_data(unsigned char *p, unsigned char *end, 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 %#x length %d\n", + tag, len); break; } @@ -495,8 +492,7 @@ len_err: 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; } @@ -554,9 +550,8 @@ static unsigned char *pnpbios_parse_compatible_ids(unsigned char *p, 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 %#x length %d\n", + tag, len); break; } @@ -567,8 +562,7 @@ len_err: 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; } @@ -774,9 +768,8 @@ static unsigned char *pnpbios_encode_allocated_resource_data(struct pnp_dev 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 %#x length %d\n", + tag, len); break; } @@ -787,8 +780,7 @@ len_err: 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; } -- cgit v1.2.3 From 02d83b5da3efa3c278ce87db2637f3dd6837166d Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:28 -0600 Subject: PNP: make pnp_resource_table private to PNP core 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 Signed-off-by: Len Brown --- drivers/pnp/base.h | 12 ++++++++++++ drivers/pnp/core.c | 8 ++++++++ drivers/pnp/isapnp/core.c | 4 ++-- drivers/pnp/manager.c | 16 ++++++++-------- drivers/pnp/pnpacpi/rsparser.c | 10 ++++++---- drivers/pnp/pnpbios/rsparser.c | 8 ++++---- drivers/pnp/resource.c | 2 +- include/linux/pnp.h | 14 ++------------ 8 files changed, 43 insertions(+), 31 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index e739d4bba423..b888a5fb6b7f 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h @@ -20,3 +20,15 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res); void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc); void pnp_init_resource(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_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]; +}; diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c index cf37701a4f9e..20771b7d4482 100644 --- a/drivers/pnp/core.c +++ b/drivers/pnp/core.c @@ -106,6 +106,7 @@ static void pnp_release_device(struct device *dmdev) pnp_free_option(dev->independent); pnp_free_option(dev->dependent); pnp_free_ids(dev); + kfree(dev->res); kfree(dev); } @@ -118,6 +119,12 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid 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; dev->dma_mask = DMA_24BIT_MASK; @@ -133,6 +140,7 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid dev_id = pnp_add_id(dev, pnpid); if (!dev_id) { + kfree(dev->res); kfree(dev); return NULL; } diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 990d8cd6295c..4407e844b5ea 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -931,7 +931,7 @@ EXPORT_SYMBOL(isapnp_write_byte); static int isapnp_read_resources(struct pnp_dev *dev) { - struct pnp_resource_table *res = &dev->res; + struct pnp_resource_table *res = dev->res; int tmp, ret; dev->active = isapnp_read_byte(ISAPNP_CFG_ACTIVATE); @@ -987,7 +987,7 @@ static int isapnp_get_resources(struct pnp_dev *dev) static int isapnp_set_resources(struct pnp_dev *dev) { - struct pnp_resource_table *res = &dev->res; + struct pnp_resource_table *res = dev->res; int tmp; dev_dbg(&dev->dev, "set resources\n"); diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c index 7c5ebddfc6af..46a5e0e90d9a 100644 --- a/drivers/pnp/manager.c +++ b/drivers/pnp/manager.c @@ -247,22 +247,22 @@ void pnp_init_resources(struct pnp_dev *dev) int idx; for (idx = 0; idx < PNP_MAX_IRQ; idx++) { - res = &dev->res.irq_resource[idx]; + res = &dev->res->irq_resource[idx]; res->flags = IORESOURCE_IRQ; pnp_init_resource(res); } for (idx = 0; idx < PNP_MAX_DMA; idx++) { - res = &dev->res.dma_resource[idx]; + res = &dev->res->dma_resource[idx]; res->flags = IORESOURCE_DMA; pnp_init_resource(res); } for (idx = 0; idx < PNP_MAX_PORT; idx++) { - res = &dev->res.port_resource[idx]; + res = &dev->res->port_resource[idx]; res->flags = IORESOURCE_IO; pnp_init_resource(res); } for (idx = 0; idx < PNP_MAX_MEM; idx++) { - res = &dev->res.mem_resource[idx]; + res = &dev->res->mem_resource[idx]; res->flags = IORESOURCE_MEM; pnp_init_resource(res); } @@ -278,28 +278,28 @@ static void pnp_clean_resource_table(struct pnp_dev *dev) int idx; for (idx = 0; idx < PNP_MAX_IRQ; idx++) { - res = &dev->res.irq_resource[idx]; + res = &dev->res->irq_resource[idx]; if (res->flags & IORESOURCE_AUTO) { res->flags = IORESOURCE_IRQ; pnp_init_resource(res); } } for (idx = 0; idx < PNP_MAX_DMA; idx++) { - res = &dev->res.dma_resource[idx]; + res = &dev->res->dma_resource[idx]; if (res->flags & IORESOURCE_AUTO) { res->flags = IORESOURCE_DMA; pnp_init_resource(res); } } for (idx = 0; idx < PNP_MAX_PORT; idx++) { - res = &dev->res.port_resource[idx]; + res = &dev->res->port_resource[idx]; if (res->flags & IORESOURCE_AUTO) { res->flags = IORESOURCE_IO; pnp_init_resource(res); } } for (idx = 0; idx < PNP_MAX_MEM; idx++) { - res = &dev->res.mem_resource[idx]; + res = &dev->res->mem_resource[idx]; if (res->flags & IORESOURCE_AUTO) { res->flags = IORESOURCE_MEM; pnp_init_resource(res); diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 000a1b39f0b6..2669518b4795 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include "../base.h" #include "pnpacpi.h" #ifdef CONFIG_IA64 @@ -80,7 +82,7 @@ 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; + struct pnp_resource_table *res = dev->res; int i = 0; int irq; int p, t; @@ -176,7 +178,7 @@ static int dma_flags(int type, int bus_master, int transfer) static void pnpacpi_parse_allocated_dmaresource(struct pnp_dev *dev, u32 dma, int flags) { - struct pnp_resource_table *res = &dev->res; + struct pnp_resource_table *res = dev->res; int i = 0; static unsigned char warned; @@ -202,7 +204,7 @@ static void pnpacpi_parse_allocated_dmaresource(struct pnp_dev *dev, static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev, u64 io, u64 len, int io_decode) { - struct pnp_resource_table *res = &dev->res; + struct pnp_resource_table *res = dev->res; int i = 0; static unsigned char warned; @@ -230,7 +232,7 @@ static void pnpacpi_parse_allocated_memresource(struct pnp_dev *dev, u64 mem, u64 len, int write_protect) { - struct pnp_resource_table *res = &dev->res; + struct pnp_resource_table *res = dev->res; int i = 0; static unsigned char warned; diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index c1f9e162d2c5..9f0538af0321 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c @@ -56,7 +56,7 @@ inline void pcibios_penalize_isa_irq(int irq, int active) static void pnpbios_parse_allocated_irqresource(struct pnp_dev *dev, int irq) { - struct pnp_resource_table *res = &dev->res; + struct pnp_resource_table *res = dev->res; int i = 0; while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) @@ -76,7 +76,7 @@ static void pnpbios_parse_allocated_irqresource(struct pnp_dev *dev, int irq) static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma) { - struct pnp_resource_table *res = &dev->res; + struct pnp_resource_table *res = dev->res; int i = 0; while (i < PNP_MAX_DMA && @@ -96,7 +96,7 @@ static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma) static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev, int io, int len) { - struct pnp_resource_table *res = &dev->res; + struct pnp_resource_table *res = dev->res; int i = 0; while (!(res->port_resource[i].flags & IORESOURCE_UNSET) @@ -116,7 +116,7 @@ static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev, static void pnpbios_parse_allocated_memresource(struct pnp_dev *dev, int mem, int len) { - struct pnp_resource_table *res = &dev->res; + struct pnp_resource_table *res = dev->res; int i = 0; while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c index 84362818fa8b..f7adc7eefbf8 100644 --- a/drivers/pnp/resource.c +++ b/drivers/pnp/resource.c @@ -502,7 +502,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res) 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: diff --git a/include/linux/pnp.h b/include/linux/pnp.h index 1640562f3ebc..a5487b6a4e57 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -13,14 +13,11 @@ #include #include -#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 @@ -184,13 +181,6 @@ struct pnp_option { 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 */ @@ -260,7 +250,7 @@ struct pnp_dev { 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 */ -- cgit v1.2.3 From 06cb58a6eb0b689f95a6c055cfc400fd30c500c6 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:29 -0600 Subject: PNP: remove pnp_resource_table references from resource decoders This removes a few more references to the pnp_resource_table. No functional change. Signed-off-by: Bjorn Helgaas Signed-off-by: Len Brown --- drivers/pnp/isapnp/core.c | 95 ++++++++++++++++++++---------------------- drivers/pnp/pnpacpi/rsparser.c | 88 ++++++++++++++++++++------------------ drivers/pnp/pnpbios/rsparser.c | 82 ++++++++++++++++++++---------------- 3 files changed, 140 insertions(+), 125 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 4407e844b5ea..a62ecc6f13bd 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -931,7 +931,7 @@ EXPORT_SYMBOL(isapnp_write_byte); static int isapnp_read_resources(struct pnp_dev *dev) { - struct pnp_resource_table *res = dev->res; + struct resource *res; int tmp, ret; dev->active = isapnp_read_byte(ISAPNP_CFG_ACTIVATE); @@ -940,16 +940,18 @@ static int isapnp_read_resources(struct pnp_dev *dev) 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; + res = pnp_get_resource(dev, IORESOURCE_IO, tmp); + res->start = ret; + res->flags = IORESOURCE_IO; } for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) { ret = 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; + res = pnp_get_resource(dev, IORESOURCE_MEM, tmp); + res->start = ret; + res->flags = IORESOURCE_MEM; } for (tmp = 0; tmp < ISAPNP_MAX_IRQ; tmp++) { ret = @@ -957,17 +959,17 @@ static int isapnp_read_resources(struct pnp_dev *dev) 8); if (!ret) continue; - res->irq_resource[tmp].start = - res->irq_resource[tmp].end = ret; - res->irq_resource[tmp].flags = IORESOURCE_IRQ; + res = pnp_get_resource(dev, IORESOURCE_IRQ, tmp); + res->start = res->end = ret; + res->flags = IORESOURCE_IRQ; } for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) { 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; + res = pnp_get_resource(dev, IORESOURCE_DMA, tmp); + res->start = res->end = ret; + res->flags = IORESOURCE_DMA; } } return 0; @@ -987,52 +989,47 @@ static int isapnp_get_resources(struct pnp_dev *dev) static int isapnp_set_resources(struct pnp_dev *dev) { - struct pnp_resource_table *res = dev->res; + struct resource *res; int tmp; dev_dbg(&dev->dev, "set resources\n"); 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++) { - dev_dbg(&dev->dev, " set io %d to %#llx\n", - tmp, (unsigned long long) res->port_resource[tmp].start); - isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1), - res->port_resource[tmp].start); + for (tmp = 0; tmp < ISAPNP_MAX_PORT; tmp++) { + res = pnp_get_resource(dev, IORESOURCE_IO, tmp); + if (pnp_resource_valid(res)) { + dev_dbg(&dev->dev, " set io %d to %#llx\n", + tmp, (unsigned long long) res->start); + isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1), + res->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; - dev_dbg(&dev->dev, " set irq %d to %d\n", tmp, irq); - isapnp_write_byte(ISAPNP_CFG_IRQ + (tmp << 1), irq); + for (tmp = 0; tmp < ISAPNP_MAX_IRQ; tmp++) { + res = pnp_get_resource(dev, IORESOURCE_IRQ, tmp); + if (pnp_resource_valid(res)) { + int irq = res->start; + if (irq == 2) + irq = 9; + dev_dbg(&dev->dev, " set irq %d to %d\n", tmp, irq); + 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++) { - dev_dbg(&dev->dev, " set dma %d to %lld\n", - tmp, (unsigned long long) res->dma_resource[tmp].start); - isapnp_write_byte(ISAPNP_CFG_DMA + tmp, - res->dma_resource[tmp].start); + for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) { + res = pnp_get_resource(dev, IORESOURCE_DMA, tmp); + if (pnp_resource_valid(res)) { + dev_dbg(&dev->dev, " set dma %d to %lld\n", + tmp, (unsigned long long) res->start); + isapnp_write_byte(ISAPNP_CFG_DMA + tmp, res->start); + } } - for (tmp = 0; - tmp < ISAPNP_MAX_MEM - && (res->mem_resource[tmp]. - flags & (IORESOURCE_MEM | IORESOURCE_UNSET)) == IORESOURCE_MEM; - tmp++) { - dev_dbg(&dev->dev, " set mem %d to %#llx\n", - tmp, (unsigned long long) res->mem_resource[tmp].start); - isapnp_write_word(ISAPNP_CFG_MEM + (tmp << 3), - (res->mem_resource[tmp].start >> 8) & 0xffff); + for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) { + res = pnp_get_resource(dev, IORESOURCE_MEM, tmp); + if (pnp_resource_valid(res)) { + dev_dbg(&dev->dev, " set mem %d to %#llx\n", + tmp, (unsigned long long) res->start); + isapnp_write_word(ISAPNP_CFG_MEM + (tmp << 3), + (res->start >> 8) & 0xffff); + } } /* FIXME: We aren't handling 32bit mems properly here */ isapnp_activate(dev->number); diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 2669518b4795..3634f2f3f745 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -82,8 +82,8 @@ 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; + struct resource *res; + int i; int irq; int p, t; static unsigned char warned; @@ -91,9 +91,11 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_dev *dev, if (!valid_IRQ(gsi)) return; - while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) && - i < PNP_MAX_IRQ) - i++; + for (i = 0; i < PNP_MAX_IRQ; i++) { + res = pnp_get_resource(dev, IORESOURCE_IRQ, i); + if (!pnp_resource_valid(res)) + break; + } if (i >= PNP_MAX_IRQ) { if (!warned) { printk(KERN_WARNING "pnpacpi: exceeded the max number" @@ -119,16 +121,16 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_dev *dev, } } - res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag - res->irq_resource[i].flags |= irq_flags(triggering, polarity, shareable); + res->flags = IORESOURCE_IRQ; // Also clears _UNSET flag + res->flags |= irq_flags(triggering, polarity, shareable); irq = acpi_register_gsi(gsi, triggering, polarity); if (irq < 0) { - res->irq_resource[i].flags |= IORESOURCE_DISABLED; + res->flags |= IORESOURCE_DISABLED; return; } - res->irq_resource[i].start = irq; - res->irq_resource[i].end = irq; + res->start = irq; + res->end = irq; pcibios_penalize_isa_irq(irq, 1); } @@ -178,22 +180,24 @@ static int dma_flags(int type, int bus_master, int transfer) static void pnpacpi_parse_allocated_dmaresource(struct pnp_dev *dev, u32 dma, int flags) { - struct pnp_resource_table *res = dev->res; - int i = 0; + struct resource *res; + int i; static unsigned char warned; - while (i < PNP_MAX_DMA && - !(res->dma_resource[i].flags & IORESOURCE_UNSET)) - i++; + for (i = 0; i < PNP_MAX_DMA; i++) { + res = pnp_get_resource(dev, IORESOURCE_DMA, i); + if (!pnp_resource_valid(res)) + break; + } if (i < PNP_MAX_DMA) { - res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag - res->dma_resource[i].flags |= flags; + res->flags = IORESOURCE_DMA; // Also clears _UNSET flag + res->flags |= flags; if (dma == -1) { - res->dma_resource[i].flags |= IORESOURCE_DISABLED; + res->flags |= IORESOURCE_DISABLED; return; } - res->dma_resource[i].start = dma; - res->dma_resource[i].end = dma; + res->start = dma; + res->end = dma; } else if (!warned) { printk(KERN_WARNING "pnpacpi: exceeded the max number of DMA " "resources: %d \n", PNP_MAX_DMA); @@ -204,23 +208,25 @@ static void pnpacpi_parse_allocated_dmaresource(struct pnp_dev *dev, 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; + struct resource *res; + int i; static unsigned char warned; - while (!(res->port_resource[i].flags & IORESOURCE_UNSET) && - i < PNP_MAX_PORT) - i++; + for (i = 0; i < PNP_MAX_PORT; i++) { + res = pnp_get_resource(dev, IORESOURCE_IO, i); + if (!pnp_resource_valid(res)) + break; + } if (i < PNP_MAX_PORT) { - res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag + res->flags = IORESOURCE_IO; // Also clears _UNSET flag if (io_decode == ACPI_DECODE_16) - res->port_resource[i].flags |= PNP_PORT_FLAG_16BITADDR; + res->flags |= PNP_PORT_FLAG_16BITADDR; if (len <= 0 || (io + len - 1) >= 0x10003) { - res->port_resource[i].flags |= IORESOURCE_DISABLED; + res->flags |= IORESOURCE_DISABLED; return; } - res->port_resource[i].start = io; - res->port_resource[i].end = io + len - 1; + res->start = io; + res->end = io + len - 1; } else if (!warned) { printk(KERN_WARNING "pnpacpi: exceeded the max number of IO " "resources: %d \n", PNP_MAX_PORT); @@ -232,24 +238,26 @@ 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; + struct resource *res; + int i; static unsigned char warned; - while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) && - (i < PNP_MAX_MEM)) - i++; + for (i = 0; i < PNP_MAX_MEM; i++) { + res = pnp_get_resource(dev, IORESOURCE_MEM, i); + if (!pnp_resource_valid(res)) + break; + } if (i < PNP_MAX_MEM) { - res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag + res->flags = IORESOURCE_MEM; // Also clears _UNSET flag if (len <= 0) { - res->mem_resource[i].flags |= IORESOURCE_DISABLED; + res->flags |= IORESOURCE_DISABLED; return; } if (write_protect == ACPI_READ_WRITE_MEMORY) - res->mem_resource[i].flags |= IORESOURCE_MEM_WRITEABLE; + res->flags |= IORESOURCE_MEM_WRITEABLE; - res->mem_resource[i].start = mem; - res->mem_resource[i].end = mem + len - 1; + res->start = mem; + res->end = mem + len - 1; } else if (!warned) { printk(KERN_WARNING "pnpacpi: exceeded the max number of mem " "resources: %d\n", PNP_MAX_MEM); diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index 9f0538af0321..d3b0a4e53692 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c @@ -56,80 +56,90 @@ inline void pcibios_penalize_isa_irq(int irq, int active) static void pnpbios_parse_allocated_irqresource(struct pnp_dev *dev, int irq) { - struct pnp_resource_table *res = dev->res; - int i = 0; + struct resource *res; + int i; + + for (i = 0; i < PNP_MAX_IRQ; i++) { + res = pnp_get_resource(dev, IORESOURCE_IRQ, i); + if (!pnp_resource_valid(res)) + break; + } - 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 + res->flags = IORESOURCE_IRQ; // Also clears _UNSET flag if (irq == -1) { - res->irq_resource[i].flags |= IORESOURCE_DISABLED; + res->flags |= IORESOURCE_DISABLED; return; } - res->irq_resource[i].start = - res->irq_resource[i].end = (unsigned long)irq; + res->start = res->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; - int i = 0; + struct resource *res; + int i; + + for (i = 0; i < PNP_MAX_DMA; i++) { + res = pnp_get_resource(dev, IORESOURCE_DMA, i); + if (!pnp_resource_valid(res)) + break; + } - 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->flags = IORESOURCE_DMA; // Also clears _UNSET flag if (dma == -1) { - res->dma_resource[i].flags |= IORESOURCE_DISABLED; + res->flags |= IORESOURCE_DISABLED; return; } - res->dma_resource[i].start = - res->dma_resource[i].end = (unsigned long)dma; + res->start = res->end = (unsigned long)dma; } } static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev, int io, int len) { - struct pnp_resource_table *res = dev->res; - int i = 0; + struct resource *res; + int i; + + for (i = 0; i < PNP_MAX_PORT; i++) { + res = pnp_get_resource(dev, IORESOURCE_IO, i); + if (!pnp_resource_valid(res)) + break; + } - 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 + res->flags = IORESOURCE_IO; // Also clears _UNSET flag if (len <= 0 || (io + len - 1) >= 0x10003) { - res->port_resource[i].flags |= IORESOURCE_DISABLED; + res->flags |= IORESOURCE_DISABLED; return; } - res->port_resource[i].start = (unsigned long)io; - res->port_resource[i].end = (unsigned long)(io + len - 1); + res->start = (unsigned long)io; + res->end = (unsigned long)(io + len - 1); } } static void pnpbios_parse_allocated_memresource(struct pnp_dev *dev, int mem, int len) { - struct pnp_resource_table *res = dev->res; - int i = 0; + struct resource *res; + int i; + + for (i = 0; i < PNP_MAX_MEM; i++) { + res = pnp_get_resource(dev, IORESOURCE_MEM, i); + if (!pnp_resource_valid(res)) + break; + } - 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 + res->flags = IORESOURCE_MEM; // Also clears _UNSET flag if (len <= 0) { - res->mem_resource[i].flags |= IORESOURCE_DISABLED; + res->flags |= IORESOURCE_DISABLED; return; } - res->mem_resource[i].start = (unsigned long)mem; - res->mem_resource[i].end = (unsigned long)(mem + len - 1); + res->start = (unsigned long)mem; + res->end = (unsigned long)(mem + len - 1); } } -- cgit v1.2.3 From 21855d69d1e3ace3efdb8159a4a7ab1ab98a6f19 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:32 -0600 Subject: PNP: add pnp_resource index for ISAPNP Save the ISAPNP config register index in the struct pnp_resource. We need this because it is important to write ISAPNP configuration back to the same registers we read it from. For example, if we read valid regions from memory descriptors 0, 1, and 3, we'd better write them back to the same registers, without compressing them to descriptors 0, 1, and 2. This was previously guaranteed by using the index into the pnp_resource_table array as the ISAPNP config register index. However, I am removing those fixed-size arrays, so we need to save the ISAPNP register index elsewhere. Signed-off-by: Bjorn Helgaas Signed-off-by: Len Brown --- drivers/pnp/base.h | 1 + drivers/pnp/interface.c | 33 ++++++++++++++++--------- drivers/pnp/isapnp/core.c | 63 ++++++++++++++++++++++++++++++++++------------- drivers/pnp/manager.c | 32 ++++++++++++++++++------ 4 files changed, 92 insertions(+), 37 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index 49b4138f3476..786735770684 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h @@ -31,6 +31,7 @@ struct pnp_resource *pnp_get_pnp_resource(struct pnp_dev *dev, struct pnp_resource { struct resource res; + unsigned int index; /* ISAPNP config register index */ }; struct pnp_resource_table { diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index e9e66ed4fa31..ead151242a64 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c @@ -320,6 +320,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, const char *ubuf, size_t count) { struct pnp_dev *dev = to_pnp_dev(dmdev); + struct pnp_resource *pnp_res; struct resource *res; char *buf = (void *)ubuf; int retval = 0; @@ -380,10 +381,12 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 2; while (isspace(*buf)) ++buf; - res = pnp_get_resource(dev, IORESOURCE_IO, - nport); - if (!res) + pnp_res = pnp_get_pnp_resource(dev, + IORESOURCE_IO, nport); + if (!pnp_res) break; + pnp_res->index = nport; + res = &pnp_res->res; res->start = simple_strtoul(buf, &buf, 0); while (isspace(*buf)) ++buf; @@ -402,10 +405,12 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 3; while (isspace(*buf)) ++buf; - res = pnp_get_resource(dev, IORESOURCE_MEM, - nmem); - if (!res) + pnp_res = pnp_get_pnp_resource(dev, + IORESOURCE_MEM, nmem); + if (!pnp_res) break; + pnp_res->index = nmem; + res = &pnp_res->res; res->start = simple_strtoul(buf, &buf, 0); while (isspace(*buf)) ++buf; @@ -424,10 +429,12 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 3; while (isspace(*buf)) ++buf; - res = pnp_get_resource(dev, IORESOURCE_IRQ, - nirq); - if (!res) + pnp_res = pnp_get_pnp_resource(dev, + IORESOURCE_IRQ, nirq); + if (!pnp_res) break; + pnp_res->index = nirq; + res = &pnp_res->res; res->start = res->end = simple_strtoul(buf, &buf, 0); res->flags = IORESOURCE_IRQ; @@ -438,10 +445,12 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 3; while (isspace(*buf)) ++buf; - res = pnp_get_resource(dev, IORESOURCE_DMA, - ndma); - if (!res) + pnp_res = pnp_get_pnp_resource(dev, + IORESOURCE_DMA, ndma); + if (!pnp_res) break; + pnp_res->index = ndma; + res = &pnp_res->res; res->start = res->end = simple_strtoul(buf, &buf, 0); res->flags = IORESOURCE_DMA; diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index a62ecc6f13bd..f949a538ccde 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -931,6 +931,7 @@ EXPORT_SYMBOL(isapnp_write_byte); static int isapnp_read_resources(struct pnp_dev *dev) { + struct pnp_resource *pnp_res; struct resource *res; int tmp, ret; @@ -940,7 +941,9 @@ static int isapnp_read_resources(struct pnp_dev *dev) ret = isapnp_read_word(ISAPNP_CFG_PORT + (tmp << 1)); if (!ret) continue; - res = pnp_get_resource(dev, IORESOURCE_IO, tmp); + pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IO, tmp); + pnp_res->index = tmp; + res = &pnp_res->res; res->start = ret; res->flags = IORESOURCE_IO; } @@ -949,7 +952,10 @@ static int isapnp_read_resources(struct pnp_dev *dev) isapnp_read_word(ISAPNP_CFG_MEM + (tmp << 3)) << 8; if (!ret) continue; - res = pnp_get_resource(dev, IORESOURCE_MEM, tmp); + pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_MEM, + tmp); + pnp_res->index = tmp; + res = &pnp_res->res; res->start = ret; res->flags = IORESOURCE_MEM; } @@ -959,7 +965,10 @@ static int isapnp_read_resources(struct pnp_dev *dev) 8); if (!ret) continue; - res = pnp_get_resource(dev, IORESOURCE_IRQ, tmp); + pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IRQ, + tmp); + pnp_res->index = tmp; + res = &pnp_res->res; res->start = res->end = ret; res->flags = IORESOURCE_IRQ; } @@ -967,7 +976,10 @@ static int isapnp_read_resources(struct pnp_dev *dev) ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp); if (ret == 4) continue; - res = pnp_get_resource(dev, IORESOURCE_DMA, tmp); + pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_DMA, + tmp); + pnp_res->index = tmp; + res = &pnp_res->res; res->start = res->end = ret; res->flags = IORESOURCE_DMA; } @@ -989,45 +1001,62 @@ static int isapnp_get_resources(struct pnp_dev *dev) static int isapnp_set_resources(struct pnp_dev *dev) { + struct pnp_resource *pnp_res; struct resource *res; - int tmp; + int tmp, index; dev_dbg(&dev->dev, "set resources\n"); isapnp_cfg_begin(dev->card->number, dev->number); dev->active = 1; for (tmp = 0; tmp < ISAPNP_MAX_PORT; tmp++) { - res = pnp_get_resource(dev, IORESOURCE_IO, tmp); + pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IO, tmp); + if (!pnp_res) + continue; + res = &pnp_res->res; if (pnp_resource_valid(res)) { + index = pnp_res->index; dev_dbg(&dev->dev, " set io %d to %#llx\n", - tmp, (unsigned long long) res->start); - isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1), + index, (unsigned long long) res->start); + isapnp_write_word(ISAPNP_CFG_PORT + (index << 1), res->start); } } for (tmp = 0; tmp < ISAPNP_MAX_IRQ; tmp++) { - res = pnp_get_resource(dev, IORESOURCE_IRQ, tmp); + pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IRQ, tmp); + if (!pnp_res) + continue; + res = &pnp_res->res; if (pnp_resource_valid(res)) { int irq = res->start; if (irq == 2) irq = 9; - dev_dbg(&dev->dev, " set irq %d to %d\n", tmp, irq); - isapnp_write_byte(ISAPNP_CFG_IRQ + (tmp << 1), irq); + index = pnp_res->index; + dev_dbg(&dev->dev, " set irq %d to %d\n", index, irq); + isapnp_write_byte(ISAPNP_CFG_IRQ + (index << 1), irq); } } for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) { - res = pnp_get_resource(dev, IORESOURCE_DMA, tmp); + pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_DMA, tmp); + if (!pnp_res) + continue; + res = &pnp_res->res; if (pnp_resource_valid(res)) { + index = pnp_res->index; dev_dbg(&dev->dev, " set dma %d to %lld\n", - tmp, (unsigned long long) res->start); - isapnp_write_byte(ISAPNP_CFG_DMA + tmp, res->start); + index, (unsigned long long) res->start); + isapnp_write_byte(ISAPNP_CFG_DMA + index, res->start); } } for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) { - res = pnp_get_resource(dev, IORESOURCE_MEM, tmp); + pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_MEM, tmp); + if (!pnp_res) + continue; + res = &pnp_res->res; if (pnp_resource_valid(res)) { + index = pnp_res->index; dev_dbg(&dev->dev, " set mem %d to %#llx\n", - tmp, (unsigned long long) res->start); - isapnp_write_word(ISAPNP_CFG_MEM + (tmp << 3), + index, (unsigned long long) res->start); + isapnp_write_word(ISAPNP_CFG_MEM + (index << 3), (res->start >> 8) & 0xffff); } } diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c index 4823da27e640..bea0914ff947 100644 --- a/drivers/pnp/manager.c +++ b/drivers/pnp/manager.c @@ -19,15 +19,18 @@ DEFINE_MUTEX(pnp_res_mutex); static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx) { + struct pnp_resource *pnp_res; struct resource *res; - res = pnp_get_resource(dev, IORESOURCE_IO, idx); - if (!res) { + pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IO, idx); + if (!pnp_res) { dev_err(&dev->dev, "too many I/O port resources\n"); /* pretend we were successful so at least the manager won't try again */ return 1; } + res = &pnp_res->res; + /* check if this resource has been manually set, if so skip */ if (!(res->flags & IORESOURCE_AUTO)) { dev_dbg(&dev->dev, " io %d already set to %#llx-%#llx " @@ -37,6 +40,7 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx) } /* set the initial values */ + pnp_res->index = idx; res->flags |= rule->flags | IORESOURCE_IO; res->flags &= ~IORESOURCE_UNSET; @@ -65,15 +69,18 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx) static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx) { + struct pnp_resource *pnp_res; struct resource *res; - res = pnp_get_resource(dev, IORESOURCE_MEM, idx); - if (!res) { + pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_MEM, idx); + if (!pnp_res) { dev_err(&dev->dev, "too many memory resources\n"); /* pretend we were successful so at least the manager won't try again */ return 1; } + res = &pnp_res->res; + /* check if this resource has been manually set, if so skip */ if (!(res->flags & IORESOURCE_AUTO)) { dev_dbg(&dev->dev, " mem %d already set to %#llx-%#llx " @@ -83,6 +90,7 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx) } /* set the initial values */ + pnp_res->index = idx; res->flags |= rule->flags | IORESOURCE_MEM; res->flags &= ~IORESOURCE_UNSET; @@ -121,6 +129,7 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx) static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx) { + struct pnp_resource *pnp_res; struct resource *res; int i; @@ -129,13 +138,15 @@ static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx) 5, 10, 11, 12, 9, 14, 15, 7, 3, 4, 13, 0, 1, 6, 8, 2 }; - res = pnp_get_resource(dev, IORESOURCE_IRQ, idx); - if (!res) { + pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IRQ, idx); + if (!pnp_res) { dev_err(&dev->dev, "too many IRQ resources\n"); /* pretend we were successful so at least the manager won't try again */ return 1; } + res = &pnp_res->res; + /* check if this resource has been manually set, if so skip */ if (!(res->flags & IORESOURCE_AUTO)) { dev_dbg(&dev->dev, " irq %d already set to %d flags %#lx\n", @@ -144,6 +155,7 @@ static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx) } /* set the initial values */ + pnp_res->index = idx; res->flags |= rule->flags | IORESOURCE_IRQ; res->flags &= ~IORESOURCE_UNSET; @@ -177,6 +189,7 @@ static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx) static void pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) { + struct pnp_resource *pnp_res; struct resource *res; int i; @@ -185,12 +198,14 @@ static void pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) 1, 3, 5, 6, 7, 0, 2, 4 }; - res = pnp_get_resource(dev, IORESOURCE_DMA, idx); - if (!res) { + pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_DMA, idx); + if (!pnp_res) { dev_err(&dev->dev, "too many DMA resources\n"); return; } + res = &pnp_res->res; + /* check if this resource has been manually set, if so skip */ if (!(res->flags & IORESOURCE_AUTO)) { dev_dbg(&dev->dev, " dma %d already set to %d flags %#lx\n", @@ -199,6 +214,7 @@ static void pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) } /* set the initial values */ + pnp_res->index = idx; res->flags |= rule->flags | IORESOURCE_DMA; res->flags &= ~IORESOURCE_UNSET; -- cgit v1.2.3 From dbddd0383c59d588f8db5e773b062756e39117ec Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:34 -0600 Subject: PNP: make generic pnp_add_irq_resource() 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 Signed-off-by: Len Brown --- drivers/pnp/base.h | 3 +++ drivers/pnp/interface.c | 15 +++++---------- drivers/pnp/isapnp/core.c | 9 +++------ drivers/pnp/pnpacpi/rsparser.c | 33 +++++++-------------------------- drivers/pnp/pnpbios/rsparser.c | 31 +++++++------------------------ drivers/pnp/resource.c | 26 ++++++++++++++++++++++++++ 6 files changed, 51 insertions(+), 66 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index 786735770684..3dd5d849c30f 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h @@ -40,3 +40,6 @@ struct pnp_resource_table { 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); diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index ead151242a64..e8134c286207 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c @@ -324,6 +324,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, struct resource *res; char *buf = (void *)ubuf; int retval = 0; + resource_size_t start; if (dev->status & PNP_ATTACHED) { retval = -EBUSY; @@ -429,16 +430,10 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 3; while (isspace(*buf)) ++buf; - pnp_res = pnp_get_pnp_resource(dev, - IORESOURCE_IRQ, nirq); - if (!pnp_res) - break; - pnp_res->index = nirq; - res = &pnp_res->res; - res->start = res->end = - simple_strtoul(buf, &buf, 0); - res->flags = IORESOURCE_IRQ; - nirq++; + start = simple_strtoul(buf, &buf, 0); + pnp_res = pnp_add_irq_resource(dev, start, 0); + if (pnp_res) + nirq++; continue; } if (!strnicmp(buf, "dma", 3)) { diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index f949a538ccde..2cf750f077a4 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -965,12 +965,9 @@ static int isapnp_read_resources(struct pnp_dev *dev) 8); if (!ret) continue; - pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IRQ, - tmp); - pnp_res->index = tmp; - res = &pnp_res->res; - res->start = res->end = ret; - res->flags = IORESOURCE_IRQ; + pnp_res = pnp_add_irq_resource(dev, ret, 0); + if (pnp_res) + pnp_res->index = tmp; } for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) { ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp); diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 3634f2f3f745..0b67dff1e7c3 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -82,28 +82,12 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_dev *dev, u32 gsi, int triggering, int polarity, int shareable) { - struct resource *res; - int i; - int irq; + int irq, flags; int p, t; - static unsigned char warned; if (!valid_IRQ(gsi)) return; - for (i = 0; i < PNP_MAX_IRQ; i++) { - res = pnp_get_resource(dev, IORESOURCE_IRQ, i); - if (!pnp_resource_valid(res)) - break; - } - if (i >= PNP_MAX_IRQ) { - if (!warned) { - printk(KERN_WARNING "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 @@ -121,17 +105,14 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_dev *dev, } } - res->flags = IORESOURCE_IRQ; // Also clears _UNSET flag - res->flags |= irq_flags(triggering, polarity, shareable); + flags = irq_flags(triggering, polarity, shareable); irq = acpi_register_gsi(gsi, triggering, polarity); - if (irq < 0) { - res->flags |= IORESOURCE_DISABLED; - return; - } + if (irq >= 0) + pcibios_penalize_isa_irq(irq, 1); + else + flags |= IORESOURCE_DISABLED; - res->start = irq; - res->end = irq; - pcibios_penalize_isa_irq(irq, 1); + pnp_add_irq_resource(dev, irq, flags); } static int dma_flags(int type, int bus_master, int transfer) diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index d3b0a4e53692..845730c57edc 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c @@ -54,28 +54,6 @@ inline void pcibios_penalize_isa_irq(int irq, int active) * Allocated Resources */ -static void pnpbios_parse_allocated_irqresource(struct pnp_dev *dev, int irq) -{ - struct resource *res; - int i; - - for (i = 0; i < PNP_MAX_IRQ; i++) { - res = pnp_get_resource(dev, IORESOURCE_IRQ, i); - if (!pnp_resource_valid(res)) - break; - } - - if (i < PNP_MAX_IRQ) { - res->flags = IORESOURCE_IRQ; // Also clears _UNSET flag - if (irq == -1) { - res->flags |= IORESOURCE_DISABLED; - return; - } - res->start = res->end = (unsigned long)irq; - pcibios_penalize_isa_irq(irq, 1); - } -} - static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma) { struct resource *res; @@ -148,7 +126,7 @@ static unsigned char *pnpbios_parse_allocated_resource_data(struct pnp_dev *dev, unsigned char *end) { unsigned int len, tag; - int io, size, mask, i; + int io, size, mask, i, flags; if (!p) return NULL; @@ -205,12 +183,17 @@ static unsigned char *pnpbios_parse_allocated_resource_data(struct pnp_dev *dev, case SMALL_TAG_IRQ: if (len < 2 || len > 3) goto len_err; + flags = 0; io = -1; mask = p[1] + p[2] * 256; for (i = 0; i < 16; i++, mask = mask >> 1) if (mask & 0x01) io = i; - pnpbios_parse_allocated_irqresource(dev, io); + if (io != -1) + pcibios_penalize_isa_irq(io, 1); + else + flags = IORESOURCE_DISABLED; + pnp_add_irq_resource(dev, io, flags); break; case SMALL_TAG_DMA: diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c index 1f4134eea7b7..082a556b9dcc 100644 --- a/drivers/pnp/resource.c +++ b/drivers/pnp/resource.c @@ -576,6 +576,32 @@ static struct pnp_resource *pnp_new_resource(struct pnp_dev *dev, int type) return NULL; } +struct pnp_resource *pnp_add_irq_resource(struct pnp_dev *dev, int irq, + int flags) +{ + struct pnp_resource *pnp_res; + struct resource *res; + static unsigned char warned; + + pnp_res = pnp_new_resource(dev, IORESOURCE_IRQ); + if (!pnp_res) { + if (!warned) { + dev_err(&dev->dev, "can't add resource for IRQ %d\n", + irq); + warned = 1; + } + return NULL; + } + + res = &pnp_res->res; + res->flags = IORESOURCE_IRQ | flags; + res->start = irq; + res->end = irq; + + dev_dbg(&dev->dev, " add irq %d flags %#x\n", irq, flags); + return pnp_res; +} + /* format is: pnp_reserve_irq=irq1[,irq2] .... */ static int __init pnp_setup_reserve_irq(char *str) { -- cgit v1.2.3 From dc16f5f2ede8cc2acf8ac22857a7fecf3a4296c2 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:35 -0600 Subject: PNP: make generic pnp_add_dma_resource() 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 Signed-off-by: Len Brown --- drivers/pnp/base.h | 2 ++ drivers/pnp/interface.c | 14 ++++---------- drivers/pnp/isapnp/core.c | 9 +++------ drivers/pnp/pnpacpi/rsparser.c | 42 ++++++++---------------------------------- drivers/pnp/pnpbios/rsparser.c | 26 ++++---------------------- drivers/pnp/resource.c | 26 ++++++++++++++++++++++++++ 6 files changed, 47 insertions(+), 72 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index 3dd5d849c30f..b6719b384347 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h @@ -43,3 +43,5 @@ struct pnp_resource_table { 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, + int flags); diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index e8134c286207..00c8a970a97e 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c @@ -440,16 +440,10 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 3; while (isspace(*buf)) ++buf; - pnp_res = pnp_get_pnp_resource(dev, - IORESOURCE_DMA, ndma); - if (!pnp_res) - break; - pnp_res->index = ndma; - res = &pnp_res->res; - res->start = res->end = - simple_strtoul(buf, &buf, 0); - res->flags = IORESOURCE_DMA; - ndma++; + start = simple_strtoul(buf, &buf, 0); + pnp_res = pnp_add_dma_resource(dev, start, 0); + if (pnp_res) + pnp_res->index = ndma++; continue; } break; diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 2cf750f077a4..2e5e58c777dd 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -973,12 +973,9 @@ static int isapnp_read_resources(struct pnp_dev *dev) ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp); if (ret == 4) continue; - pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_DMA, - tmp); - pnp_res->index = tmp; - res = &pnp_res->res; - res->start = res->end = ret; - res->flags = IORESOURCE_DMA; + pnp_res = pnp_add_dma_resource(dev, ret, 0); + if (pnp_res) + pnp_res->index = tmp; } } return 0; diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index 0b67dff1e7c3..fc7cf73b7a7e 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -158,34 +158,6 @@ static int dma_flags(int type, int bus_master, int transfer) return flags; } -static void pnpacpi_parse_allocated_dmaresource(struct pnp_dev *dev, - u32 dma, int flags) -{ - struct resource *res; - int i; - static unsigned char warned; - - for (i = 0; i < PNP_MAX_DMA; i++) { - res = pnp_get_resource(dev, IORESOURCE_DMA, i); - if (!pnp_resource_valid(res)) - break; - } - if (i < PNP_MAX_DMA) { - res->flags = IORESOURCE_DMA; // Also clears _UNSET flag - res->flags |= flags; - if (dma == -1) { - res->flags |= IORESOURCE_DISABLED; - return; - } - res->start = dma; - res->end = dma; - } else if (!warned) { - printk(KERN_WARNING "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) { @@ -285,7 +257,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, struct acpi_resource_memory32 *memory32; struct acpi_resource_fixed_memory32 *fixed_memory32; struct acpi_resource_extended_irq *extended_irq; - int i; + int i, flags; switch (res->type) { case ACPI_RESOURCE_TYPE_IRQ: @@ -305,11 +277,13 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, 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)); + if (dma->channel_count > 0) { + flags = dma_flags(dma->type, dma->bus_master, + dma->transfer); + if (dma->channels[0] == (u8) -1) + flags |= IORESOURCE_DISABLED; + pnp_add_dma_resource(dev, dma->channels[0], flags); + } break; case ACPI_RESOURCE_TYPE_IO: diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index 845730c57edc..7f8d65728599 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c @@ -54,27 +54,6 @@ inline void pcibios_penalize_isa_irq(int irq, int active) * Allocated Resources */ -static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma) -{ - struct resource *res; - int i; - - for (i = 0; i < PNP_MAX_DMA; i++) { - res = pnp_get_resource(dev, IORESOURCE_DMA, i); - if (!pnp_resource_valid(res)) - break; - } - - if (i < PNP_MAX_DMA) { - res->flags = IORESOURCE_DMA; // Also clears _UNSET flag - if (dma == -1) { - res->flags |= IORESOURCE_DISABLED; - return; - } - res->start = res->end = (unsigned long)dma; - } -} - static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev, int io, int len) { @@ -199,12 +178,15 @@ static unsigned char *pnpbios_parse_allocated_resource_data(struct pnp_dev *dev, case SMALL_TAG_DMA: if (len != 2) goto len_err; + flags = 0; io = -1; mask = p[1]; for (i = 0; i < 8; i++, mask = mask >> 1) if (mask & 0x01) io = i; - pnpbios_parse_allocated_dmaresource(dev, io); + if (io == -1) + flags = IORESOURCE_DISABLED; + pnp_add_dma_resource(dev, io, flags); break; case SMALL_TAG_PORT: diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c index 082a556b9dcc..2a8612e31ab7 100644 --- a/drivers/pnp/resource.c +++ b/drivers/pnp/resource.c @@ -602,6 +602,32 @@ struct pnp_resource *pnp_add_irq_resource(struct pnp_dev *dev, int irq, return pnp_res; } +struct pnp_resource *pnp_add_dma_resource(struct pnp_dev *dev, int dma, + int flags) +{ + struct pnp_resource *pnp_res; + struct resource *res; + static unsigned char warned; + + pnp_res = pnp_new_resource(dev, IORESOURCE_DMA); + if (!pnp_res) { + if (!warned) { + dev_err(&dev->dev, "can't add resource for DMA %d\n", + dma); + warned = 1; + } + return NULL; + } + + res = &pnp_res->res; + res->flags = IORESOURCE_DMA | flags; + res->start = dma; + res->end = dma; + + dev_dbg(&dev->dev, " add dma %d flags %#x\n", dma, flags); + return pnp_res; +} + /* format is: pnp_reserve_irq=irq1[,irq2] .... */ static int __init pnp_setup_reserve_irq(char *str) { -- cgit v1.2.3 From cc8c2e308194f0997c718c7c735550ff06754d20 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:36 -0600 Subject: PNP: make generic pnp_add_io_resource() 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 Signed-off-by: Len Brown --- drivers/pnp/base.h | 3 +++ drivers/pnp/interface.c | 20 ++++++++------------ drivers/pnp/isapnp/core.c | 8 +++----- drivers/pnp/pnpacpi/rsparser.c | 35 ++++++++++------------------------- drivers/pnp/pnpbios/rsparser.c | 23 ++++++----------------- drivers/pnp/resource.c | 29 +++++++++++++++++++++++++++++ 6 files changed, 59 insertions(+), 59 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index b6719b384347..bfb08abc311b 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h @@ -45,3 +45,6 @@ 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, int flags); +struct pnp_resource *pnp_add_io_resource(struct pnp_dev *dev, + resource_size_t start, + resource_size_t end, int flags); diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index 00c8a970a97e..77d8bf01b485 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c @@ -324,7 +324,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, struct resource *res; char *buf = (void *)ubuf; int retval = 0; - resource_size_t start; + resource_size_t start, end; if (dev->status & PNP_ATTACHED) { retval = -EBUSY; @@ -382,24 +382,20 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 2; while (isspace(*buf)) ++buf; - pnp_res = pnp_get_pnp_resource(dev, - IORESOURCE_IO, nport); - if (!pnp_res) - break; - pnp_res->index = nport; - res = &pnp_res->res; - res->start = simple_strtoul(buf, &buf, 0); + start = simple_strtoul(buf, &buf, 0); while (isspace(*buf)) ++buf; if (*buf == '-') { buf += 1; while (isspace(*buf)) ++buf; - res->end = simple_strtoul(buf, &buf, 0); + end = simple_strtoul(buf, &buf, 0); } else - res->end = res->start; - res->flags = IORESOURCE_IO; - nport++; + end = start; + pnp_res = pnp_add_io_resource(dev, start, end, + 0); + if (pnp_res) + pnp_res->index = nport++; continue; } if (!strnicmp(buf, "mem", 3)) { diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 2e5e58c777dd..bdd8508090da 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -941,11 +941,9 @@ static int isapnp_read_resources(struct pnp_dev *dev) ret = isapnp_read_word(ISAPNP_CFG_PORT + (tmp << 1)); if (!ret) continue; - pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IO, tmp); - pnp_res->index = tmp; - res = &pnp_res->res; - res->start = ret; - res->flags = IORESOURCE_IO; + pnp_res = pnp_add_io_resource(dev, ret, ret, 0); + if (pnp_res) + pnp_res->index = tmp; } for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) { ret = diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index fc7cf73b7a7e..d3ca8e035c19 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -158,33 +158,18 @@ static int dma_flags(int type, int bus_master, int transfer) return flags; } -static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev, - u64 io, u64 len, int io_decode) +static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev, u64 start, + u64 len, int io_decode) { - struct resource *res; - int i; - static unsigned char warned; + int flags = 0; + u64 end = start + len - 1; - for (i = 0; i < PNP_MAX_PORT; i++) { - res = pnp_get_resource(dev, IORESOURCE_IO, i); - if (!pnp_resource_valid(res)) - break; - } - if (i < PNP_MAX_PORT) { - res->flags = IORESOURCE_IO; // Also clears _UNSET flag - if (io_decode == ACPI_DECODE_16) - res->flags |= PNP_PORT_FLAG_16BITADDR; - if (len <= 0 || (io + len - 1) >= 0x10003) { - res->flags |= IORESOURCE_DISABLED; - return; - } - res->start = io; - res->end = io + len - 1; - } else if (!warned) { - printk(KERN_WARNING "pnpacpi: exceeded the max number of IO " - "resources: %d \n", PNP_MAX_PORT); - warned = 1; - } + if (io_decode == ACPI_DECODE_16) + flags |= PNP_PORT_FLAG_16BITADDR; + if (len == 0 || end >= 0x10003) + flags |= IORESOURCE_DISABLED; + + pnp_add_io_resource(dev, start, end, flags); } static void pnpacpi_parse_allocated_memresource(struct pnp_dev *dev, diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index 7f8d65728599..8c83bc16a9be 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c @@ -55,26 +55,15 @@ inline void pcibios_penalize_isa_irq(int irq, int active) */ static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev, - int io, int len) + int start, int len) { - struct resource *res; - int i; + int flags = 0; + int end = start + len - 1; - for (i = 0; i < PNP_MAX_PORT; i++) { - res = pnp_get_resource(dev, IORESOURCE_IO, i); - if (!pnp_resource_valid(res)) - break; - } + if (len <= 0 || end >= 0x10003) + flags |= IORESOURCE_DISABLED; - if (i < PNP_MAX_PORT) { - res->flags = IORESOURCE_IO; // Also clears _UNSET flag - if (len <= 0 || (io + len - 1) >= 0x10003) { - res->flags |= IORESOURCE_DISABLED; - return; - } - res->start = (unsigned long)io; - res->end = (unsigned long)(io + len - 1); - } + pnp_add_io_resource(dev, start, end, flags); } static void pnpbios_parse_allocated_memresource(struct pnp_dev *dev, diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c index 2a8612e31ab7..64387b70026a 100644 --- a/drivers/pnp/resource.c +++ b/drivers/pnp/resource.c @@ -628,6 +628,35 @@ struct pnp_resource *pnp_add_dma_resource(struct pnp_dev *dev, int dma, return pnp_res; } +struct pnp_resource *pnp_add_io_resource(struct pnp_dev *dev, + resource_size_t start, + resource_size_t end, int flags) +{ + struct pnp_resource *pnp_res; + struct resource *res; + static unsigned char warned; + + pnp_res = pnp_new_resource(dev, IORESOURCE_IO); + if (!pnp_res) { + if (!warned) { + dev_err(&dev->dev, "can't add resource for IO " + "%#llx-%#llx\n",(unsigned long long) start, + (unsigned long long) end); + warned = 1; + } + return NULL; + } + + res = &pnp_res->res; + res->flags = IORESOURCE_IO | flags; + res->start = start; + res->end = end; + + dev_dbg(&dev->dev, " add io %#llx-%#llx flags %#x\n", + (unsigned long long) start, (unsigned long long) end, flags); + return pnp_res; +} + /* format is: pnp_reserve_irq=irq1[,irq2] .... */ static int __init pnp_setup_reserve_irq(char *str) { -- cgit v1.2.3 From d6180f36617953990bf90d4c1ff85b77e9995cd1 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:37 -0600 Subject: PNP: make generic pnp_add_mem_resource() 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 Signed-off-by: Len Brown --- drivers/pnp/base.h | 3 +++ drivers/pnp/interface.c | 19 +++++++------------ drivers/pnp/isapnp/core.c | 10 +++------- drivers/pnp/pnpacpi/rsparser.c | 34 +++++++++------------------------- drivers/pnp/pnpbios/rsparser.c | 23 ++++++----------------- drivers/pnp/resource.c | 29 +++++++++++++++++++++++++++++ 6 files changed, 57 insertions(+), 61 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index bfb08abc311b..9b7bb62c98b1 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h @@ -48,3 +48,6 @@ struct pnp_resource *pnp_add_dma_resource(struct pnp_dev *dev, int dma, struct pnp_resource *pnp_add_io_resource(struct pnp_dev *dev, resource_size_t start, resource_size_t end, int flags); +struct pnp_resource *pnp_add_mem_resource(struct pnp_dev *dev, + resource_size_t start, + resource_size_t end, int flags); diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index 77d8bf01b485..5d9301de1778 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c @@ -321,7 +321,6 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, { struct pnp_dev *dev = to_pnp_dev(dmdev); struct pnp_resource *pnp_res; - struct resource *res; char *buf = (void *)ubuf; int retval = 0; resource_size_t start, end; @@ -402,24 +401,20 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 3; while (isspace(*buf)) ++buf; - pnp_res = pnp_get_pnp_resource(dev, - IORESOURCE_MEM, nmem); - if (!pnp_res) - break; - pnp_res->index = nmem; - res = &pnp_res->res; - res->start = simple_strtoul(buf, &buf, 0); + start = simple_strtoul(buf, &buf, 0); while (isspace(*buf)) ++buf; if (*buf == '-') { buf += 1; while (isspace(*buf)) ++buf; - res->end = simple_strtoul(buf, &buf, 0); + end = simple_strtoul(buf, &buf, 0); } else - res->end = res->start; - res->flags = IORESOURCE_MEM; - nmem++; + end = start; + pnp_res = pnp_add_mem_resource(dev, start, end, + 0); + if (pnp_res) + pnp_res->index = nmem++; continue; } if (!strnicmp(buf, "irq", 3)) { diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index bdd8508090da..f08399497e4c 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -932,7 +932,6 @@ EXPORT_SYMBOL(isapnp_write_byte); static int isapnp_read_resources(struct pnp_dev *dev) { struct pnp_resource *pnp_res; - struct resource *res; int tmp, ret; dev->active = isapnp_read_byte(ISAPNP_CFG_ACTIVATE); @@ -950,12 +949,9 @@ static int isapnp_read_resources(struct pnp_dev *dev) isapnp_read_word(ISAPNP_CFG_MEM + (tmp << 3)) << 8; if (!ret) continue; - pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_MEM, - tmp); - pnp_res->index = tmp; - res = &pnp_res->res; - res->start = ret; - res->flags = IORESOURCE_MEM; + pnp_res = pnp_add_mem_resource(dev, ret, ret, 0); + if (pnp_res) + pnp_res->index = tmp; } for (tmp = 0; tmp < ISAPNP_MAX_IRQ; tmp++) { ret = diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index d3ca8e035c19..a512908bf4e3 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c @@ -173,34 +173,18 @@ static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev, u64 start, } static void pnpacpi_parse_allocated_memresource(struct pnp_dev *dev, - u64 mem, u64 len, + u64 start, u64 len, int write_protect) { - struct resource *res; - int i; - static unsigned char warned; + int flags = 0; + u64 end = start + len - 1; - for (i = 0; i < PNP_MAX_MEM; i++) { - res = pnp_get_resource(dev, IORESOURCE_MEM, i); - if (!pnp_resource_valid(res)) - break; - } - if (i < PNP_MAX_MEM) { - res->flags = IORESOURCE_MEM; // Also clears _UNSET flag - if (len <= 0) { - res->flags |= IORESOURCE_DISABLED; - return; - } - if (write_protect == ACPI_READ_WRITE_MEMORY) - res->flags |= IORESOURCE_MEM_WRITEABLE; - - res->start = mem; - res->end = mem + len - 1; - } else if (!warned) { - printk(KERN_WARNING "pnpacpi: exceeded the max number of mem " - "resources: %d\n", PNP_MAX_MEM); - warned = 1; - } + if (len == 0) + flags |= IORESOURCE_DISABLED; + if (write_protect == ACPI_READ_WRITE_MEMORY) + flags |= IORESOURCE_MEM_WRITEABLE; + + pnp_add_mem_resource(dev, start, end, flags); } static void pnpacpi_parse_allocated_address_space(struct pnp_dev *dev, diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index 8c83bc16a9be..ed63ecd9bf40 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c @@ -67,26 +67,15 @@ static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev, } static void pnpbios_parse_allocated_memresource(struct pnp_dev *dev, - int mem, int len) + int start, int len) { - struct resource *res; - int i; + int flags = 0; + int end = start + len - 1; - for (i = 0; i < PNP_MAX_MEM; i++) { - res = pnp_get_resource(dev, IORESOURCE_MEM, i); - if (!pnp_resource_valid(res)) - break; - } + if (len <= 0) + flags |= IORESOURCE_DISABLED; - if (i < PNP_MAX_MEM) { - res->flags = IORESOURCE_MEM; // Also clears _UNSET flag - if (len <= 0) { - res->flags |= IORESOURCE_DISABLED; - return; - } - res->start = (unsigned long)mem; - res->end = (unsigned long)(mem + len - 1); - } + pnp_add_mem_resource(dev, start, end, flags); } static unsigned char *pnpbios_parse_allocated_resource_data(struct pnp_dev *dev, diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c index 64387b70026a..2041620d5682 100644 --- a/drivers/pnp/resource.c +++ b/drivers/pnp/resource.c @@ -657,6 +657,35 @@ struct pnp_resource *pnp_add_io_resource(struct pnp_dev *dev, return pnp_res; } +struct pnp_resource *pnp_add_mem_resource(struct pnp_dev *dev, + resource_size_t start, + resource_size_t end, int flags) +{ + struct pnp_resource *pnp_res; + struct resource *res; + static unsigned char warned; + + pnp_res = pnp_new_resource(dev, IORESOURCE_MEM); + if (!pnp_res) { + if (!warned) { + dev_err(&dev->dev, "can't add resource for MEM " + "%#llx-%#llx\n",(unsigned long long) start, + (unsigned long long) end); + warned = 1; + } + return NULL; + } + + res = &pnp_res->res; + res->flags = IORESOURCE_MEM | flags; + res->start = start; + res->end = end; + + dev_dbg(&dev->dev, " add mem %#llx-%#llx flags %#x\n", + (unsigned long long) start, (unsigned long long) end, flags); + return pnp_res; +} + /* format is: pnp_reserve_irq=irq1[,irq2] .... */ static int __init pnp_setup_reserve_irq(char *str) { -- cgit v1.2.3 From 01115e7d41c4eaeffa064d818b4abbd3efa94f80 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:38 -0600 Subject: ISAPNP: fold isapnp_read_resources() back into isapnp_get_resources() isapnp_get_resources() does very little besides call isapnp_read_resources(), so just fold them back together. Based on a patch by Rene Herman Signed-off-by: Bjorn Helgaas Signed-off-by: Len Brown --- drivers/pnp/isapnp/core.c | 66 +++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 37 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index f08399497e4c..a3f1566ccea5 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -929,62 +929,54 @@ EXPORT_SYMBOL(isapnp_cfg_begin); EXPORT_SYMBOL(isapnp_cfg_end); EXPORT_SYMBOL(isapnp_write_byte); -static int isapnp_read_resources(struct pnp_dev *dev) +static int isapnp_get_resources(struct pnp_dev *dev) { struct pnp_resource *pnp_res; - int tmp, ret; + int i, ret; + dev_dbg(&dev->dev, "get resources\n"); + pnp_init_resources(dev); + isapnp_cfg_begin(dev->card->number, dev->number); dev->active = isapnp_read_byte(ISAPNP_CFG_ACTIVATE); - if (dev->active) { - for (tmp = 0; tmp < ISAPNP_MAX_PORT; tmp++) { - ret = isapnp_read_word(ISAPNP_CFG_PORT + (tmp << 1)); - if (!ret) - continue; + if (!dev->active) + goto __end; + + for (i = 0; i < ISAPNP_MAX_PORT; i++) { + ret = isapnp_read_word(ISAPNP_CFG_PORT + (i << 1)); + if (ret) { pnp_res = pnp_add_io_resource(dev, ret, ret, 0); if (pnp_res) - pnp_res->index = tmp; + pnp_res->index = i; } - for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) { - ret = - isapnp_read_word(ISAPNP_CFG_MEM + (tmp << 3)) << 8; - if (!ret) - continue; + } + for (i = 0; i < ISAPNP_MAX_MEM; i++) { + ret = isapnp_read_word(ISAPNP_CFG_MEM + (i << 3)) << 8; + if (ret) { pnp_res = pnp_add_mem_resource(dev, ret, ret, 0); if (pnp_res) - pnp_res->index = tmp; + pnp_res->index = i; } - for (tmp = 0; tmp < ISAPNP_MAX_IRQ; tmp++) { - ret = - (isapnp_read_word(ISAPNP_CFG_IRQ + (tmp << 1)) >> - 8); - if (!ret) - continue; + } + for (i = 0; i < ISAPNP_MAX_IRQ; i++) { + ret = isapnp_read_word(ISAPNP_CFG_IRQ + (i << 1)) >> 8; + if (ret) { pnp_res = pnp_add_irq_resource(dev, ret, 0); if (pnp_res) - pnp_res->index = tmp; + pnp_res->index = i; } - for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) { - ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp); - if (ret == 4) - continue; + } + for (i = 0; i < ISAPNP_MAX_DMA; i++) { + ret = isapnp_read_byte(ISAPNP_CFG_DMA + i); + if (ret != 4) { pnp_res = pnp_add_dma_resource(dev, ret, 0); if (pnp_res) - pnp_res->index = tmp; + pnp_res->index = i; } } - return 0; -} -static int isapnp_get_resources(struct pnp_dev *dev) -{ - int ret; - - dev_dbg(&dev->dev, "get resources\n"); - pnp_init_resources(dev); - isapnp_cfg_begin(dev->card->number, dev->number); - ret = isapnp_read_resources(dev); +__end: isapnp_cfg_end(); - return ret; + return 0; } static int isapnp_set_resources(struct pnp_dev *dev) -- cgit v1.2.3 From 261b20da4bd349f1b26e206f440809f1351be34b Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:41 -0600 Subject: ISAPNP: remove unused pnp_dev->regs field The "regs" field in struct pnp_dev is set but never read, so remove it. Signed-off-by: Bjorn Helgaas Acked-By: Rene Herman Signed-off-by: Len Brown --- drivers/pnp/isapnp/core.c | 3 --- include/linux/pnp.h | 1 - 2 files changed, 4 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index a3f1566ccea5..f1bccdbdeb08 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -416,10 +416,7 @@ static struct pnp_dev *__init isapnp_parse_device(struct pnp_card *card, if (!dev) return NULL; - dev->regs = tmp[4]; dev->card = card; - if (size > 5) - dev->regs |= tmp[5] << 8; dev->capabilities |= PNP_CONFIGURABLE; dev->capabilities |= PNP_READ; dev->capabilities |= PNP_WRITE; diff --git a/include/linux/pnp.h b/include/linux/pnp.h index f5b985e912ae..e3b2c0068de7 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -253,7 +253,6 @@ struct pnp_dev { struct pnp_resource_table *res; char name[PNP_NAME_LEN]; /* contains a human-readable name */ - unsigned short regs; /* ISAPnP: supported registers */ int flags; /* used by protocols */ struct proc_dir_entry *procent; /* device entry in /proc/bus/isapnp */ void *data; -- cgit v1.2.3