diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2008-04-28 18:33:53 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2008-04-29 03:22:16 -0400 |
commit | 25eb846189d20db4114cebf14fee96d69bef4667 (patch) | |
tree | bca11a6cc777f4ee121b1c04aa9e86075ae04a3e /drivers/pnp/isapnp | |
parent | 772defc6292bae8b6db298476d1dabd22a99492b (diff) |
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 <bjorn.helgaas@hp.com>
Acked-By: Rene Herman <rene.herman@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/pnp/isapnp')
-rw-r--r-- | drivers/pnp/isapnp/core.c | 32 |
1 files changed, 11 insertions, 21 deletions
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 | |||
@@ -398,24 +398,6 @@ static void __init isapnp_skip_bytes(int count) | |||
398 | } | 398 | } |
399 | 399 | ||
400 | /* | 400 | /* |
401 | * Parse EISA id. | ||
402 | */ | ||
403 | static void isapnp_parse_id(struct pnp_dev *dev, unsigned short vendor, | ||
404 | unsigned short device) | ||
405 | { | ||
406 | char id[8]; | ||
407 | |||
408 | sprintf(id, "%c%c%c%x%x%x%x", | ||
409 | 'A' + ((vendor >> 2) & 0x3f) - 1, | ||
410 | 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1, | ||
411 | 'A' + ((vendor >> 8) & 0x1f) - 1, | ||
412 | (device >> 4) & 0x0f, | ||
413 | device & 0x0f, (device >> 12) & 0x0f, (device >> 8) & 0x0f); | ||
414 | |||
415 | pnp_add_id(dev, id); | ||
416 | } | ||
417 | |||
418 | /* | ||
419 | * Parse logical device tag. | 401 | * Parse logical device tag. |
420 | */ | 402 | */ |
421 | static struct pnp_dev *__init isapnp_parse_device(struct pnp_card *card, | 403 | static struct pnp_dev *__init isapnp_parse_device(struct pnp_card *card, |
@@ -423,13 +405,17 @@ static struct pnp_dev *__init isapnp_parse_device(struct pnp_card *card, | |||
423 | { | 405 | { |
424 | unsigned char tmp[6]; | 406 | unsigned char tmp[6]; |
425 | struct pnp_dev *dev; | 407 | struct pnp_dev *dev; |
408 | u32 eisa_id; | ||
409 | char id[8]; | ||
426 | 410 | ||
427 | isapnp_peek(tmp, size); | 411 | isapnp_peek(tmp, size); |
428 | dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); | 412 | dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); |
429 | if (!dev) | 413 | if (!dev) |
430 | return NULL; | 414 | return NULL; |
431 | dev->number = number; | 415 | dev->number = number; |
432 | isapnp_parse_id(dev, (tmp[1] << 8) | tmp[0], (tmp[3] << 8) | tmp[2]); | 416 | eisa_id = tmp[0] | tmp[1] << 8 | tmp[2] << 16 | tmp[3] << 24; |
417 | pnp_eisa_id_to_string(eisa_id, id); | ||
418 | pnp_add_id(dev, id); | ||
433 | dev->regs = tmp[4]; | 419 | dev->regs = tmp[4]; |
434 | dev->card = card; | 420 | dev->card = card; |
435 | if (size > 5) | 421 | if (size > 5) |
@@ -619,6 +605,8 @@ static int __init isapnp_create_device(struct pnp_card *card, | |||
619 | unsigned char type, tmp[17]; | 605 | unsigned char type, tmp[17]; |
620 | struct pnp_option *option; | 606 | struct pnp_option *option; |
621 | struct pnp_dev *dev; | 607 | struct pnp_dev *dev; |
608 | u32 eisa_id; | ||
609 | char id[8]; | ||
622 | 610 | ||
623 | if ((dev = isapnp_parse_device(card, size, number++)) == NULL) | 611 | if ((dev = isapnp_parse_device(card, size, number++)) == NULL) |
624 | return 1; | 612 | return 1; |
@@ -658,8 +646,10 @@ static int __init isapnp_create_device(struct pnp_card *card, | |||
658 | case _STAG_COMPATDEVID: | 646 | case _STAG_COMPATDEVID: |
659 | if (size == 4 && compat < DEVICE_COUNT_COMPATIBLE) { | 647 | if (size == 4 && compat < DEVICE_COUNT_COMPATIBLE) { |
660 | isapnp_peek(tmp, 4); | 648 | isapnp_peek(tmp, 4); |
661 | isapnp_parse_id(dev, (tmp[1] << 8) | tmp[0], | 649 | eisa_id = tmp[0] | tmp[1] << 8 | |
662 | (tmp[3] << 8) | tmp[2]); | 650 | tmp[2] << 16 | tmp[3] << 24; |
651 | pnp_eisa_id_to_string(eisa_id, id); | ||
652 | pnp_add_id(dev, id); | ||
663 | compat++; | 653 | compat++; |
664 | size = 0; | 654 | size = 0; |
665 | } | 655 | } |