names.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Zorro Device Name Tables
  3. *
  4. * Copyright (C) 1999--2000 Geert Uytterhoeven
  5. *
  6. * Based on the PCI version:
  7. *
  8. * Copyright 1992--1999 Drew Eckhardt, Frederic Potter,
  9. * David Mosberger-Tang, Martin Mares
  10. */
  11. #include <linux/init.h>
  12. #include <linux/kernel.h>
  13. #include <linux/types.h>
  14. #include <linux/zorro.h>
  15. #ifdef CONFIG_ZORRO_NAMES
  16. struct zorro_prod_info {
  17. __u16 prod;
  18. unsigned short seen;
  19. const char *name;
  20. };
  21. struct zorro_manuf_info {
  22. __u16 manuf;
  23. unsigned short nr;
  24. const char *name;
  25. struct zorro_prod_info *prods;
  26. };
  27. /*
  28. * This is ridiculous, but we want the strings in
  29. * the .init section so that they don't take up
  30. * real memory.. Parse the same file multiple times
  31. * to get all the info.
  32. */
  33. #define MANUF( manuf, name ) static char __manufstr_##manuf[] __initdata = name;
  34. #define ENDMANUF()
  35. #define PRODUCT( manuf, prod, name ) static char __prodstr_##manuf##prod[] __initdata = name;
  36. #include "devlist.h"
  37. #define MANUF( manuf, name ) static struct zorro_prod_info __prods_##manuf[] __initdata = {
  38. #define ENDMANUF() };
  39. #define PRODUCT( manuf, prod, name ) { 0x##prod, 0, __prodstr_##manuf##prod },
  40. #include "devlist.h"
  41. static struct zorro_manuf_info __initdata zorro_manuf_list[] = {
  42. #define MANUF( manuf, name ) { 0x##manuf, sizeof(__prods_##manuf) / sizeof(struct zorro_prod_info), __manufstr_##manuf, __prods_##manuf },
  43. #define ENDMANUF()
  44. #define PRODUCT( manuf, prod, name )
  45. #include "devlist.h"
  46. };
  47. #define MANUFS (sizeof(zorro_manuf_list)/sizeof(struct zorro_manuf_info))
  48. void __init zorro_name_device(struct zorro_dev *dev)
  49. {
  50. const struct zorro_manuf_info *manuf_p = zorro_manuf_list;
  51. int i = MANUFS;
  52. char *name = dev->name;
  53. do {
  54. if (manuf_p->manuf == ZORRO_MANUF(dev->id))
  55. goto match_manuf;
  56. manuf_p++;
  57. } while (--i);
  58. /* Couldn't find either the manufacturer nor the product */
  59. sprintf(name, "Zorro device %08x", dev->id);
  60. return;
  61. match_manuf: {
  62. struct zorro_prod_info *prod_p = manuf_p->prods;
  63. int i = manuf_p->nr;
  64. while (i > 0) {
  65. if (prod_p->prod ==
  66. ((ZORRO_PROD(dev->id)<<8) | ZORRO_EPC(dev->id)))
  67. goto match_prod;
  68. prod_p++;
  69. i--;
  70. }
  71. /* Ok, found the manufacturer, but unknown product */
  72. sprintf(name, "Zorro device %08x (%s)", dev->id, manuf_p->name);
  73. return;
  74. /* Full match */
  75. match_prod: {
  76. char *n = name + sprintf(name, "%s %s", manuf_p->name, prod_p->name);
  77. int nr = prod_p->seen + 1;
  78. prod_p->seen = nr;
  79. if (nr > 1)
  80. sprintf(n, " (#%d)", nr);
  81. }
  82. }
  83. }
  84. #else
  85. void __init zorro_name_device(struct zorro_dev *dev)
  86. {
  87. }
  88. #endif