names.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. struct zorro_prod_info {
  16. __u16 prod;
  17. unsigned short seen;
  18. const char *name;
  19. };
  20. struct zorro_manuf_info {
  21. __u16 manuf;
  22. unsigned short nr;
  23. const char *name;
  24. struct zorro_prod_info *prods;
  25. };
  26. /*
  27. * This is ridiculous, but we want the strings in
  28. * the .init section so that they don't take up
  29. * real memory.. Parse the same file multiple times
  30. * to get all the info.
  31. */
  32. #define MANUF( manuf, name ) static char __manufstr_##manuf[] __initdata = name;
  33. #define ENDMANUF()
  34. #define PRODUCT( manuf, prod, name ) static char __prodstr_##manuf##prod[] __initdata = name;
  35. #include "devlist.h"
  36. #define MANUF( manuf, name ) static struct zorro_prod_info __prods_##manuf[] __initdata = {
  37. #define ENDMANUF() };
  38. #define PRODUCT( manuf, prod, name ) { 0x##prod, 0, __prodstr_##manuf##prod },
  39. #include "devlist.h"
  40. static struct zorro_manuf_info __initdata zorro_manuf_list[] = {
  41. #define MANUF( manuf, name ) { 0x##manuf, ARRAY_SIZE(__prods_##manuf), __manufstr_##manuf, __prods_##manuf },
  42. #define ENDMANUF()
  43. #define PRODUCT( manuf, prod, name )
  44. #include "devlist.h"
  45. };
  46. #define MANUFS ARRAY_SIZE(zorro_manuf_list)
  47. void __init zorro_name_device(struct zorro_dev *dev)
  48. {
  49. const struct zorro_manuf_info *manuf_p = zorro_manuf_list;
  50. int i = MANUFS;
  51. char *name = dev->name;
  52. do {
  53. if (manuf_p->manuf == ZORRO_MANUF(dev->id))
  54. goto match_manuf;
  55. manuf_p++;
  56. } while (--i);
  57. /* Couldn't find either the manufacturer nor the product */
  58. return;
  59. match_manuf: {
  60. struct zorro_prod_info *prod_p = manuf_p->prods;
  61. int i = manuf_p->nr;
  62. while (i > 0) {
  63. if (prod_p->prod ==
  64. ((ZORRO_PROD(dev->id)<<8) | ZORRO_EPC(dev->id)))
  65. goto match_prod;
  66. prod_p++;
  67. i--;
  68. }
  69. /* Ok, found the manufacturer, but unknown product */
  70. sprintf(name, "Zorro device %08x (%s)", dev->id, manuf_p->name);
  71. return;
  72. /* Full match */
  73. match_prod: {
  74. char *n = name + sprintf(name, "%s %s", manuf_p->name, prod_p->name);
  75. int nr = prod_p->seen + 1;
  76. prod_p->seen = nr;
  77. if (nr > 1)
  78. sprintf(n, " (#%d)", nr);
  79. }
  80. }
  81. }