diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/zorro/names.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/zorro/names.c')
-rw-r--r-- | drivers/zorro/names.c | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/drivers/zorro/names.c b/drivers/zorro/names.c new file mode 100644 index 000000000000..0dd532d3a5d6 --- /dev/null +++ b/drivers/zorro/names.c | |||
@@ -0,0 +1,109 @@ | |||
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 | |||
12 | #include <linux/config.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/types.h> | ||
16 | #include <linux/zorro.h> | ||
17 | |||
18 | |||
19 | #ifdef CONFIG_ZORRO_NAMES | ||
20 | |||
21 | struct zorro_prod_info { | ||
22 | __u16 prod; | ||
23 | unsigned short seen; | ||
24 | const char *name; | ||
25 | }; | ||
26 | |||
27 | struct zorro_manuf_info { | ||
28 | __u16 manuf; | ||
29 | unsigned short nr; | ||
30 | const char *name; | ||
31 | struct zorro_prod_info *prods; | ||
32 | }; | ||
33 | |||
34 | /* | ||
35 | * This is ridiculous, but we want the strings in | ||
36 | * the .init section so that they don't take up | ||
37 | * real memory.. Parse the same file multiple times | ||
38 | * to get all the info. | ||
39 | */ | ||
40 | #define MANUF( manuf, name ) static char __manufstr_##manuf[] __initdata = name; | ||
41 | #define ENDMANUF() | ||
42 | #define PRODUCT( manuf, prod, name ) static char __prodstr_##manuf##prod[] __initdata = name; | ||
43 | #include "devlist.h" | ||
44 | |||
45 | |||
46 | #define MANUF( manuf, name ) static struct zorro_prod_info __prods_##manuf[] __initdata = { | ||
47 | #define ENDMANUF() }; | ||
48 | #define PRODUCT( manuf, prod, name ) { 0x##prod, 0, __prodstr_##manuf##prod }, | ||
49 | #include "devlist.h" | ||
50 | |||
51 | static struct zorro_manuf_info __initdata zorro_manuf_list[] = { | ||
52 | #define MANUF( manuf, name ) { 0x##manuf, sizeof(__prods_##manuf) / sizeof(struct zorro_prod_info), __manufstr_##manuf, __prods_##manuf }, | ||
53 | #define ENDMANUF() | ||
54 | #define PRODUCT( manuf, prod, name ) | ||
55 | #include "devlist.h" | ||
56 | }; | ||
57 | |||
58 | #define MANUFS (sizeof(zorro_manuf_list)/sizeof(struct zorro_manuf_info)) | ||
59 | |||
60 | void __init zorro_name_device(struct zorro_dev *dev) | ||
61 | { | ||
62 | const struct zorro_manuf_info *manuf_p = zorro_manuf_list; | ||
63 | int i = MANUFS; | ||
64 | char *name = dev->name; | ||
65 | |||
66 | do { | ||
67 | if (manuf_p->manuf == ZORRO_MANUF(dev->id)) | ||
68 | goto match_manuf; | ||
69 | manuf_p++; | ||
70 | } while (--i); | ||
71 | |||
72 | /* Couldn't find either the manufacturer nor the product */ | ||
73 | sprintf(name, "Zorro device %08x", dev->id); | ||
74 | return; | ||
75 | |||
76 | match_manuf: { | ||
77 | struct zorro_prod_info *prod_p = manuf_p->prods; | ||
78 | int i = manuf_p->nr; | ||
79 | |||
80 | while (i > 0) { | ||
81 | if (prod_p->prod == | ||
82 | ((ZORRO_PROD(dev->id)<<8) | ZORRO_EPC(dev->id))) | ||
83 | goto match_prod; | ||
84 | prod_p++; | ||
85 | i--; | ||
86 | } | ||
87 | |||
88 | /* Ok, found the manufacturer, but unknown product */ | ||
89 | sprintf(name, "Zorro device %08x (%s)", dev->id, manuf_p->name); | ||
90 | return; | ||
91 | |||
92 | /* Full match */ | ||
93 | match_prod: { | ||
94 | char *n = name + sprintf(name, "%s %s", manuf_p->name, prod_p->name); | ||
95 | int nr = prod_p->seen + 1; | ||
96 | prod_p->seen = nr; | ||
97 | if (nr > 1) | ||
98 | sprintf(n, " (#%d)", nr); | ||
99 | } | ||
100 | } | ||
101 | } | ||
102 | |||
103 | #else | ||
104 | |||
105 | void __init zorro_name_device(struct zorro_dev *dev) | ||
106 | { | ||
107 | } | ||
108 | |||
109 | #endif | ||