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/support.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'drivers/pnp/support.c') 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.1 From 81b5c75f0ed22a93c3da00650d0898eec56e1d62 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:08 -0600 Subject: PNP: add debug when assigning PNP resources This patch adds code to dump PNP resources before and after assigning resources and before writing them to the device. This is enabled by CONFIG_PNP_DEBUG=y. Signed-off-by: Bjorn Helgaas Signed-off-by: Len Brown --- drivers/pnp/support.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'drivers/pnp/support.c') diff --git a/drivers/pnp/support.c b/drivers/pnp/support.c index e848b794e312..3aeb154e27d6 100644 --- a/drivers/pnp/support.c +++ b/drivers/pnp/support.c @@ -51,3 +51,40 @@ void pnp_eisa_id_to_string(u32 id, char *str) str[6] = hex_asc((id >> 0) & 0xf); str[7] = '\0'; } + +void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc) +{ +#ifdef DEBUG + struct resource *res; + int i; + + dev_dbg(&dev->dev, "current resources: %s\n", desc); + + for (i = 0; i < PNP_MAX_IRQ; i++) { + res = &dev->res.irq_resource[i]; + if (!(res->flags & IORESOURCE_UNSET)) + dev_dbg(&dev->dev, " irq %lld flags %#lx\n", + (unsigned long long) res->start, res->flags); + } + for (i = 0; i < PNP_MAX_DMA; i++) { + res = &dev->res.dma_resource[i]; + if (!(res->flags & IORESOURCE_UNSET)) + dev_dbg(&dev->dev, " dma %lld flags %#lx\n", + (unsigned long long) res->start, res->flags); + } + for (i = 0; i < PNP_MAX_PORT; i++) { + res = &dev->res.port_resource[i]; + if (!(res->flags & IORESOURCE_UNSET)) + dev_dbg(&dev->dev, " io %#llx-%#llx flags %#lx\n", + (unsigned long long) res->start, + (unsigned long long) res->end, res->flags); + } + for (i = 0; i < PNP_MAX_MEM; i++) { + res = &dev->res.mem_resource[i]; + if (!(res->flags & IORESOURCE_UNSET)) + dev_dbg(&dev->dev, " mem %#llx-%#llx flags %#lx\n", + (unsigned long long) res->start, + (unsigned long long) res->end, res->flags); + } +#endif +} -- cgit v1.2.1 From f6505fef18644557f732468c1f22f84560d8a819 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:25 -0600 Subject: PNP: convert assign, interface to use pnp_get_resource(), not pnp_resource_table This removes more direct references to pnp_resource_table from the pnp_assign_resources() path and the /sys user interface path. Signed-off-by: Bjorn Helgaas Signed-off-by: Len Brown --- drivers/pnp/support.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/pnp/support.c') diff --git a/drivers/pnp/support.c b/drivers/pnp/support.c index 3aeb154e27d6..3eba85ed729c 100644 --- a/drivers/pnp/support.c +++ b/drivers/pnp/support.c @@ -61,27 +61,27 @@ void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc) dev_dbg(&dev->dev, "current resources: %s\n", desc); for (i = 0; i < PNP_MAX_IRQ; i++) { - res = &dev->res.irq_resource[i]; - if (!(res->flags & IORESOURCE_UNSET)) + res = pnp_get_resource(dev, IORESOURCE_IRQ, i); + if (res && !(res->flags & IORESOURCE_UNSET)) dev_dbg(&dev->dev, " irq %lld flags %#lx\n", (unsigned long long) res->start, res->flags); } for (i = 0; i < PNP_MAX_DMA; i++) { - res = &dev->res.dma_resource[i]; - if (!(res->flags & IORESOURCE_UNSET)) + res = pnp_get_resource(dev, IORESOURCE_DMA, i); + if (res && !(res->flags & IORESOURCE_UNSET)) dev_dbg(&dev->dev, " dma %lld flags %#lx\n", (unsigned long long) res->start, res->flags); } for (i = 0; i < PNP_MAX_PORT; i++) { - res = &dev->res.port_resource[i]; - if (!(res->flags & IORESOURCE_UNSET)) + res = pnp_get_resource(dev, IORESOURCE_IO, i); + if (res && !(res->flags & IORESOURCE_UNSET)) dev_dbg(&dev->dev, " io %#llx-%#llx flags %#lx\n", (unsigned long long) res->start, (unsigned long long) res->end, res->flags); } for (i = 0; i < PNP_MAX_MEM; i++) { - res = &dev->res.mem_resource[i]; - if (!(res->flags & IORESOURCE_UNSET)) + res = pnp_get_resource(dev, IORESOURCE_MEM, i); + if (res && !(res->flags & IORESOURCE_UNSET)) dev_dbg(&dev->dev, " mem %#llx-%#llx flags %#lx\n", (unsigned long long) res->start, (unsigned long long) res->end, res->flags); -- cgit v1.2.1