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/isapnp/core.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'drivers/pnp/isapnp') diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 10cade83143..ccb04190044 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; } -- cgit v1.2.3