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