Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  *  Zorro Device Name Tables
0004  *
0005  *  Copyright (C) 1999--2000 Geert Uytterhoeven
0006  *
0007  *  Based on the PCI version:
0008  *
0009  *  Copyright 1992--1999 Drew Eckhardt, Frederic Potter,
0010  *  David Mosberger-Tang, Martin Mares
0011  */
0012 
0013 #include <linux/init.h>
0014 #include <linux/kernel.h>
0015 #include <linux/types.h>
0016 #include <linux/zorro.h>
0017 
0018 
0019 struct zorro_prod_info {
0020     __u16 prod;
0021     unsigned short seen;
0022     const char *name;
0023 };
0024 
0025 struct zorro_manuf_info {
0026     __u16 manuf;
0027     unsigned short nr;
0028     const char *name;
0029     struct zorro_prod_info *prods;
0030 };
0031 
0032 /*
0033  * This is ridiculous, but we want the strings in
0034  * the .init section so that they don't take up
0035  * real memory.. Parse the same file multiple times
0036  * to get all the info.
0037  */
0038 #define MANUF( manuf, name )        static char __manufstr_##manuf[] __initdata = name;
0039 #define ENDMANUF()
0040 #define PRODUCT( manuf, prod, name )    static char __prodstr_##manuf##prod[] __initdata = name;
0041 #include "devlist.h"
0042 
0043 
0044 #define MANUF( manuf, name )        static struct zorro_prod_info __prods_##manuf[] __initdata = {
0045 #define ENDMANUF()          };
0046 #define PRODUCT( manuf, prod, name )    { 0x##prod, 0, __prodstr_##manuf##prod },
0047 #include "devlist.h"
0048 
0049 static struct zorro_manuf_info __initdata zorro_manuf_list[] = {
0050 #define MANUF( manuf, name )        { 0x##manuf, ARRAY_SIZE(__prods_##manuf), __manufstr_##manuf, __prods_##manuf },
0051 #define ENDMANUF()
0052 #define PRODUCT( manuf, prod, name )
0053 #include "devlist.h"
0054 };
0055 
0056 #define MANUFS ARRAY_SIZE(zorro_manuf_list)
0057 
0058 void __init zorro_name_device(struct zorro_dev *dev)
0059 {
0060     const struct zorro_manuf_info *manuf_p = zorro_manuf_list;
0061     int i = MANUFS;
0062     char *name = dev->name;
0063 
0064     do {
0065         if (manuf_p->manuf == ZORRO_MANUF(dev->id))
0066             goto match_manuf;
0067         manuf_p++;
0068     } while (--i);
0069 
0070     /* Couldn't find either the manufacturer nor the product */
0071     return;
0072 
0073     match_manuf: {
0074         struct zorro_prod_info *prod_p = manuf_p->prods;
0075         int i = manuf_p->nr;
0076 
0077         while (i > 0) {
0078             if (prod_p->prod ==
0079                 ((ZORRO_PROD(dev->id)<<8) | ZORRO_EPC(dev->id)))
0080                 goto match_prod;
0081             prod_p++;
0082             i--;
0083         }
0084 
0085         /* Ok, found the manufacturer, but unknown product */
0086         sprintf(name, "Zorro device %08x (%s)", dev->id, manuf_p->name);
0087         return;
0088 
0089         /* Full match */
0090         match_prod: {
0091             char *n = name + sprintf(name, "%s %s", manuf_p->name, prod_p->name);
0092             int nr = prod_p->seen + 1;
0093             prod_p->seen = nr;
0094             if (nr > 1)
0095                 sprintf(n, " (#%d)", nr);
0096         }
0097     }
0098 }