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