aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pnp')
-rw-r--r--drivers/pnp/base.h2
-rw-r--r--drivers/pnp/isapnp/core.c32
-rw-r--r--drivers/pnp/pnpbios/core.c2
-rw-r--r--drivers/pnp/pnpbios/rsparser.c26
-rw-r--r--drivers/pnp/support.c26
5 files changed, 43 insertions, 45 deletions
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 @@
1extern spinlock_t pnp_lock; 1extern spinlock_t pnp_lock;
2void *pnp_alloc(long size); 2void *pnp_alloc(long size);
3#define PNP_EISA_ID_MASK 0x7fffffff
4void pnp_eisa_id_to_string(u32 id, char *str);
3struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id); 5struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id);
4int pnp_interface_attach_device(struct pnp_dev *dev); 6int pnp_interface_attach_device(struct pnp_dev *dev);
5void pnp_fixup_device(struct pnp_dev *dev); 7void 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
@@ -398,24 +398,6 @@ static void __init isapnp_skip_bytes(int count)
398} 398}
399 399
400/* 400/*
401 * Parse EISA id.
402 */
403static 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 */
421static struct pnp_dev *__init isapnp_parse_device(struct pnp_card *card, 403static 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 }
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)
332 if (!dev) 332 if (!dev)
333 return -1; 333 return -1;
334 334
335 pnpid32_to_pnpid(node->eisa_id, id); 335 pnp_eisa_id_to_string(node->eisa_id & PNP_EISA_ID_MASK, id);
336 dev_id = pnp_add_id(dev, id); 336 dev_id = pnp_add_id(dev, id);
337 if (!dev_id) { 337 if (!dev_id) {
338 kfree(dev); 338 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:
494 * Compatible Device IDs 494 * Compatible Device IDs
495 */ 495 */
496 496
497#define HEX(id,a) hex[((id)>>a) & 15]
498#define CHAR(id,a) (0x40 + (((id)>>a) & 31))
499
500void pnpid32_to_pnpid(u32 id, char *str)
501{
502 const char *hex = "0123456789abcdef";
503
504 id = be32_to_cpu(id);
505 str[0] = CHAR(id, 26);
506 str[1] = CHAR(id, 21);
507 str[2] = CHAR(id, 16);
508 str[3] = HEX(id, 12);
509 str[4] = HEX(id, 8);
510 str[5] = HEX(id, 4);
511 str[6] = HEX(id, 0);
512 str[7] = '\0';
513}
514
515#undef CHAR
516#undef HEX
517
518static unsigned char *pnpbios_parse_compatible_ids(unsigned char *p, 497static unsigned char *pnpbios_parse_compatible_ids(unsigned char *p,
519 unsigned char *end, 498 unsigned char *end,
520 struct pnp_dev *dev) 499 struct pnp_dev *dev)
521{ 500{
522 int len, tag; 501 int len, tag;
502 u32 eisa_id;
523 char id[8]; 503 char id[8];
524 struct pnp_id *dev_id; 504 struct pnp_id *dev_id;
525 505
@@ -549,8 +529,8 @@ static unsigned char *pnpbios_parse_compatible_ids(unsigned char *p,
549 case SMALL_TAG_COMPATDEVID: /* compatible ID */ 529 case SMALL_TAG_COMPATDEVID: /* compatible ID */
550 if (len != 4) 530 if (len != 4)
551 goto len_err; 531 goto len_err;
552 pnpid32_to_pnpid(p[1] | p[2] << 8 | p[3] << 16 | p[4] << 532 eisa_id = p[1] | p[2] << 8 | p[3] << 16 | p[4] << 24;
553 24, id); 533 pnp_eisa_id_to_string(eisa_id & PNP_EISA_ID_MASK, id);
554 dev_id = pnp_add_id(dev, id); 534 dev_id = pnp_add_id(dev, id);
555 if (!dev_id) 535 if (!dev_id)
556 return NULL; 536 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)
25} 25}
26 26
27EXPORT_SYMBOL(pnp_is_active); 27EXPORT_SYMBOL(pnp_is_active);
28
29/*
30 * Functionally similar to acpi_ex_eisa_id_to_string(), but that's
31 * buried in the ACPI CA, and we can't depend on it being present.
32 */
33void pnp_eisa_id_to_string(u32 id, char *str)
34{
35 id = be32_to_cpu(id);
36
37 /*
38 * According to the specs, the first three characters are five-bit
39 * compressed ASCII, and the left-over high order bit should be zero.
40 * However, the Linux ISAPNP code historically used six bits for the
41 * first character, and there seem to be IDs that depend on that,
42 * e.g., "nEC8241" in the Linux 8250_pnp serial driver and the
43 * FreeBSD sys/pc98/cbus/sio_cbus.c driver.
44 */
45 str[0] = 'A' + ((id >> 26) & 0x3f) - 1;
46 str[1] = 'A' + ((id >> 21) & 0x1f) - 1;
47 str[2] = 'A' + ((id >> 16) & 0x1f) - 1;
48 str[3] = hex_asc((id >> 12) & 0xf);
49 str[4] = hex_asc((id >> 8) & 0xf);
50 str[5] = hex_asc((id >> 4) & 0xf);
51 str[6] = hex_asc((id >> 0) & 0xf);
52 str[7] = '\0';
53}