Linux Audio

Check our new training course

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