Import 2.3.16
[davej-history.git] / drivers / pci / names.c
blob52d0492368fb4c226679af1ed583dc5e8f6879f5
1 /*
2 * $Id: oldproc.c,v 1.24 1998/10/11 15:13:04 mj Exp $
4 * Backward-compatible procfs interface for PCI.
6 * Copyright 1993, 1994, 1995, 1997 Drew Eckhardt, Frederic Potter,
7 * David Mosberger-Tang, Martin Mares
8 */
10 #include <linux/types.h>
11 #include <linux/kernel.h>
12 #include <linux/pci.h>
13 #include <linux/init.h>
15 struct pci_device_info {
16 unsigned short device;
17 unsigned short seen;
18 const char *name;
21 struct pci_vendor_info {
22 unsigned short vendor;
23 unsigned short nr;
24 const char *name;
25 struct pci_device_info *devices;
29 * This is ridiculous, but we want the strings in
30 * the .init section so that they don't take up
31 * real memory.. Parse the same file multiple times
32 * to get all the info.
34 #define VENDOR( vendor, name ) static const char __vendorstr_##vendor[] __initdata = name;
35 #define ENDVENDOR()
36 #define DEVICE( vendor, device, name ) static const char __devicestr_##vendor##device[] __initdata = name;
37 #include "devlist.h"
40 #define VENDOR( vendor, name ) static struct pci_device_info __devices_##vendor[] __initdata = {
41 #define ENDVENDOR() };
42 #define DEVICE( vendor, device, name ) { PCI_DEVICE_ID_##device, 0, __devicestr_##vendor##device },
43 #include "devlist.h"
45 static const struct pci_vendor_info __initdata pci_vendor_list[] = {
46 #define VENDOR( vendor, name ) { PCI_VENDOR_ID_##vendor, sizeof(__devices_##vendor) / sizeof(struct pci_device_info), __vendorstr_##vendor, __devices_##vendor },
47 #define ENDVENDOR()
48 #define DEVICE( vendor, device, name )
49 #include "devlist.h"
52 #define VENDORS (sizeof(pci_vendor_list)/sizeof(struct pci_vendor_info))
54 void __init pci_name_device(struct pci_dev *dev)
56 const struct pci_vendor_info *vendor_p = pci_vendor_list;
57 int i = VENDORS;
58 char *name = dev->name;
60 do {
61 if (vendor_p->vendor == dev->vendor)
62 goto match_vendor;
63 vendor_p++;
64 } while (--i);
66 /* Couldn't find either the vendor nor the device */
67 sprintf(name, "PCI device %04x:%04x", dev->vendor, dev->device);
68 return;
70 match_vendor: {
71 struct pci_device_info *device_p = vendor_p->devices;
72 int i = vendor_p->nr;
74 while (i > 0) {
75 if (device_p->device == dev->device)
76 goto match_device;
77 device_p++;
78 i--;
81 /* Ok, found the vendor, but unknown device */
82 sprintf(name, "PCI device %04x:%04x (%s)", dev->vendor, dev->device, vendor_p->name);
83 return;
85 /* Full match */
86 match_device: {
87 char *n = name + sprintf(name, "%s %s", vendor_p->name, device_p->name);
88 int nr = device_p->seen + 1;
89 device_p->seen = nr;
90 if (nr > 1)
91 sprintf(n, " (#%d)", nr);