Commit 49ec0f07 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Linus Torvalds

[PATCH] eliminate pci_dev name

This removes the pci_dev "->name[]" field, and makes users use the
"struct device" name field instead.

It also trimps it down to 50 bytes and limited the length of the vendor
& device descriptions to 20 bytes each.  Now we have three cases:

 - unknown vendor & unknown device -> "PCI device %04x:%04x".
	Clearly limited to 21 chars.
 - known vendor, unknown device -> "PCI device %04x:%04x (%.20s)"
	24 + 20 chars
 - known vendor, known device -> "%.20s %.20s"
	20 + 1 + 20 + 1, EXCEPT:
 - multiple devices of the same type add " (#%d)"
	so 42 + 4 + 4 = 50.  This is the point where an IBMer tells me they
	intend to sell a machine with > 9999 PCI devices of the same type ;-)

This limits the PCI IDs to a reasonable amount of space.

For release, I think we do want to go back up to 80 for prettier output
parent 5be2bc3c
...@@ -734,7 +734,7 @@ static int __devinit speedo_found1(struct pci_dev *pdev, ...@@ -734,7 +734,7 @@ static int __devinit speedo_found1(struct pci_dev *pdev,
if (eeprom[3] & 0x0100) if (eeprom[3] & 0x0100)
product = "OEM i82557/i82558 10/100 Ethernet"; product = "OEM i82557/i82558 10/100 Ethernet";
else else
product = pdev->name; product = pdev->dev.name;
printk(KERN_INFO "%s: %s, ", dev->name, product); printk(KERN_INFO "%s: %s, ", dev->name, product);
......
...@@ -56,7 +56,7 @@ void __devinit pci_name_device(struct pci_dev *dev) ...@@ -56,7 +56,7 @@ void __devinit pci_name_device(struct pci_dev *dev)
{ {
const struct pci_vendor_info *vendor_p = pci_vendor_list; const struct pci_vendor_info *vendor_p = pci_vendor_list;
int i = VENDORS; int i = VENDORS;
char *name = dev->name; char *name = dev->dev.name;
do { do {
if (vendor_p->vendor == dev->vendor) if (vendor_p->vendor == dev->vendor)
...@@ -80,12 +80,15 @@ void __devinit pci_name_device(struct pci_dev *dev) ...@@ -80,12 +80,15 @@ void __devinit pci_name_device(struct pci_dev *dev)
} }
/* Ok, found the vendor, but unknown device */ /* Ok, found the vendor, but unknown device */
sprintf(name, "PCI device %04x:%04x (%s)", dev->vendor, dev->device, vendor_p->name); sprintf(name, "PCI device %04x:%04x (%." DEVICE_NAME_HALF "s)",
dev->vendor, dev->device, vendor_p->name);
return; return;
/* Full match */ /* Full match */
match_device: { match_device: {
char *n = name + sprintf(name, "%s %s", vendor_p->name, device_p->name); char *n = name + sprintf(name, "%." DEVICE_NAME_HALF
"s %." DEVICE_NAME_HALF "s",
vendor_p->name, device_p->name);
int nr = device_p->seen + 1; int nr = device_p->seen + 1;
device_p->seen = nr; device_p->seen = nr;
if (nr > 1) if (nr > 1)
......
...@@ -52,7 +52,7 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom) ...@@ -52,7 +52,7 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
for(pos=0; pos<howmany; pos = next) { for(pos=0; pos<howmany; pos = next) {
next = pos+1; next = pos+1;
res = &dev->resource[pos]; res = &dev->resource[pos];
res->name = dev->name; res->name = dev->dev.name;
reg = PCI_BASE_ADDRESS_0 + (pos << 2); reg = PCI_BASE_ADDRESS_0 + (pos << 2);
pci_read_config_dword(dev, reg, &l); pci_read_config_dword(dev, reg, &l);
pci_write_config_dword(dev, reg, ~0); pci_write_config_dword(dev, reg, ~0);
...@@ -112,7 +112,7 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom) ...@@ -112,7 +112,7 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
sz = pci_size(sz, PCI_ROM_ADDRESS_MASK); sz = pci_size(sz, PCI_ROM_ADDRESS_MASK);
res->end = res->start + (unsigned long) sz; res->end = res->start + (unsigned long) sz;
} }
res->name = dev->name; res->name = dev->dev.name;
} }
} }
...@@ -129,7 +129,7 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child) ...@@ -129,7 +129,7 @@ void __devinit pci_read_bridge_bases(struct pci_bus *child)
return; return;
if (dev->transparent) { if (dev->transparent) {
printk("Transparent bridge - %s\n", dev->name); printk("Transparent bridge - %s\n", dev->dev.name);
for(i = 0; i < PCI_BUS_NUM_RESOURCES; i++) for(i = 0; i < PCI_BUS_NUM_RESOURCES; i++)
child->resource[i] = child->parent->resource[i]; child->resource[i] = child->parent->resource[i];
return; return;
...@@ -355,7 +355,7 @@ int pci_setup_device(struct pci_dev * dev) ...@@ -355,7 +355,7 @@ int pci_setup_device(struct pci_dev * dev)
u32 class; u32 class;
sprintf(dev->slot_name, "%02x:%02x.%d", dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); sprintf(dev->slot_name, "%02x:%02x.%d", dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
sprintf(dev->name, "PCI device %04x:%04x", dev->vendor, dev->device); sprintf(dev->dev.name, "PCI device %04x:%04x", dev->vendor, dev->device);
INIT_LIST_HEAD(&dev->pools); INIT_LIST_HEAD(&dev->pools);
pci_read_config_dword(dev, PCI_CLASS_REVISION, &class); pci_read_config_dword(dev, PCI_CLASS_REVISION, &class);
...@@ -447,7 +447,6 @@ struct pci_dev * __devinit pci_scan_device(struct pci_dev *temp) ...@@ -447,7 +447,6 @@ struct pci_dev * __devinit pci_scan_device(struct pci_dev *temp)
pci_name_device(dev); pci_name_device(dev);
/* now put in global tree */ /* now put in global tree */
strcpy(dev->dev.name,dev->name);
strcpy(dev->dev.bus_id,dev->slot_name); strcpy(dev->dev.bus_id,dev->slot_name);
device_register(&dev->dev); device_register(&dev->dev);
......
...@@ -511,7 +511,7 @@ static int show_dev_config(struct seq_file *m, void *v) ...@@ -511,7 +511,7 @@ static int show_dev_config(struct seq_file *m, void *v)
seq_printf(m, " %s", class); seq_printf(m, " %s", class);
else else
seq_printf(m, " Class %04x", class_rev >> 16); seq_printf(m, " Class %04x", class_rev >> 16);
seq_printf(m, ": %s (rev %d).\n", dev->name, class_rev & 0xff); seq_printf(m, ": %s (rev %d).\n", dev->dev.name, class_rev & 0xff);
if (dev->irq) if (dev->irq)
seq_printf(m, " IRQ %d.\n", dev->irq); seq_printf(m, " IRQ %d.\n", dev->irq);
......
...@@ -203,7 +203,7 @@ static void __devinit quirk_io_region(struct pci_dev *dev, unsigned region, unsi ...@@ -203,7 +203,7 @@ static void __devinit quirk_io_region(struct pci_dev *dev, unsigned region, unsi
if (region) { if (region) {
struct resource *res = dev->resource + nr; struct resource *res = dev->resource + nr;
res->name = dev->name; res->name = dev->dev.name;
res->start = region; res->start = region;
res->end = region + size - 1; res->end = region + size - 1;
res->flags = IORESOURCE_IO; res->flags = IORESOURCE_IO;
......
...@@ -53,7 +53,7 @@ pdev_fixup_irq(struct pci_dev *dev, ...@@ -53,7 +53,7 @@ pdev_fixup_irq(struct pci_dev *dev,
irq = 0; irq = 0;
dev->irq = irq; dev->irq = irq;
DBGC((KERN_ERR "PCI fixup irq: (%s) got %d\n", dev->name, dev->irq)); DBGC((KERN_ERR "PCI fixup irq: (%s) got %d\n", dev->dev.name, dev->irq));
/* Always tell the device, so the driver knows what is /* Always tell the device, so the driver knows what is
the real IRQ to use; the device does not use it. */ the real IRQ to use; the device does not use it. */
......
...@@ -46,11 +46,11 @@ pci_claim_resource(struct pci_dev *dev, int resource) ...@@ -46,11 +46,11 @@ pci_claim_resource(struct pci_dev *dev, int resource)
if (err) { if (err) {
printk(KERN_ERR "PCI: Address space collision on " printk(KERN_ERR "PCI: Address space collision on "
"region %d of device %s [%lx:%lx]\n", "region %d of device %s [%lx:%lx]\n",
resource, dev->name, res->start, res->end); resource, dev->dev.name, res->start, res->end);
} }
} else { } else {
printk(KERN_ERR "PCI: No parent found for region %d " printk(KERN_ERR "PCI: No parent found for region %d "
"of device %s\n", resource, dev->name); "of device %s\n", resource, dev->dev.name);
} }
return err; return err;
...@@ -155,7 +155,7 @@ pdev_sort_resources(struct pci_dev *dev, struct resource_list *head) ...@@ -155,7 +155,7 @@ pdev_sort_resources(struct pci_dev *dev, struct resource_list *head)
if (!r_align) { if (!r_align) {
printk(KERN_WARNING "PCI: Ignore bogus resource %d " printk(KERN_WARNING "PCI: Ignore bogus resource %d "
"[%lx:%lx] of %s\n", "[%lx:%lx] of %s\n",
i, r->start, r->end, dev->name); i, r->start, r->end, dev->dev.name);
continue; continue;
} }
r_align = (i < PCI_BRIDGE_RESOURCES) ? r_align + 1 : r->start; r_align = (i < PCI_BRIDGE_RESOURCES) ? r_align + 1 : r->start;
......
...@@ -284,7 +284,6 @@ int cb_alloc(socket_info_t * s) ...@@ -284,7 +284,6 @@ int cb_alloc(socket_info_t * s)
pci_setup_device(dev); pci_setup_device(dev);
strcpy(dev->dev.name, dev->name);
strcpy(dev->dev.bus_id, dev->slot_name); strcpy(dev->dev.bus_id, dev->slot_name);
/* FIXME: Do we need to enable the expansion ROM? */ /* FIXME: Do we need to enable the expansion ROM? */
......
...@@ -585,7 +585,7 @@ static void yenta_open_bh(void * data) ...@@ -585,7 +585,7 @@ static void yenta_open_bh(void * data)
/* It's OK to overwrite this now */ /* It's OK to overwrite this now */
INIT_WORK(&socket->tq_task, yenta_bh, socket); INIT_WORK(&socket->tq_task, yenta_bh, socket);
if (!socket->cb_irq || request_irq(socket->cb_irq, yenta_interrupt, SA_SHIRQ, socket->dev->name, socket)) { if (!socket->cb_irq || request_irq(socket->cb_irq, yenta_interrupt, SA_SHIRQ, socket->dev->dev.name, socket)) {
/* No IRQ or request_irq failed. Poll */ /* No IRQ or request_irq failed. Poll */
socket->cb_irq = 0; /* But zero is a valid IRQ number. */ socket->cb_irq = 0; /* But zero is a valid IRQ number. */
socket->poll_timer.function = yenta_interrupt_wrapper; socket->poll_timer.function = yenta_interrupt_wrapper;
......
...@@ -137,7 +137,7 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) ...@@ -137,7 +137,7 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id)
hcd->description = driver->description; hcd->description = driver->description;
hcd->pdev = dev; hcd->pdev = dev;
hcd->self.bus_name = dev->slot_name; hcd->self.bus_name = dev->slot_name;
hcd->product_desc = dev->name; hcd->product_desc = dev->dev.name;
if ((retval = hcd_buffer_create (hcd)) != 0) { if ((retval = hcd_buffer_create (hcd)) != 0) {
clean_3: clean_3:
...@@ -145,7 +145,7 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id) ...@@ -145,7 +145,7 @@ int usb_hcd_pci_probe (struct pci_dev *dev, const struct pci_device_id *id)
goto clean_2; goto clean_2;
} }
info ("%s @ %s, %s", hcd->description, dev->slot_name, dev->name); info ("%s @ %s, %s", hcd->description, dev->slot_name, dev->dev.name);
#ifndef __sparc__ #ifndef __sparc__
sprintf (buf, "%d", dev->irq); sprintf (buf, "%d", dev->irq);
......
...@@ -23,14 +23,17 @@ ...@@ -23,14 +23,17 @@
#ifndef _DEVICE_H_ #ifndef _DEVICE_H_
#define _DEVICE_H_ #define _DEVICE_H_
#include <linux/types.h>
#include <linux/config.h> #include <linux/config.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/kobject.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/kobject.h> #include <linux/spinlock.h>
#include <linux/types.h>
#include <asm/atomic.h>
#define DEVICE_NAME_SIZE 80 #define DEVICE_NAME_SIZE 50
#define DEVICE_NAME_HALF __stringify(20) /* Less than half to accommodate slop */
#define DEVICE_ID_SIZE 32 #define DEVICE_ID_SIZE 32
#define BUS_ID_SIZE 16 #define BUS_ID_SIZE 16
......
...@@ -371,7 +371,6 @@ struct pci_dev { ...@@ -371,7 +371,6 @@ struct pci_dev {
struct resource dma_resource[DEVICE_COUNT_DMA]; struct resource dma_resource[DEVICE_COUNT_DMA];
struct resource irq_resource[DEVICE_COUNT_IRQ]; struct resource irq_resource[DEVICE_COUNT_IRQ];
char name[90]; /* device name */
char slot_name[8]; /* slot name */ char slot_name[8]; /* slot name */
int active; /* ISAPnP: device is active */ int active; /* ISAPnP: device is active */
int ro; /* ISAPnP: read only */ int ro; /* ISAPnP: read only */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment