vserver 2.0 rc7
[linux-2.6.git] / drivers / pci / proc.c
index da51bf9..e68bbfb 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/byteorder.h>
+#include "pci.h"
 
 static int proc_initialized;   /* = 0 */
 
@@ -313,13 +314,10 @@ static void *pci_seq_start(struct seq_file *m, loff_t *pos)
        struct pci_dev *dev = NULL;
        loff_t n = *pos;
 
-       dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev);
-       while (n--) {
-               dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev);
-               if (dev == NULL)
-                       goto exit;
+       for_each_pci_dev(dev) {
+               if (!n--)
+                       break;
        }
-exit:
        return dev;
 }
 
@@ -384,26 +382,32 @@ static struct proc_dir_entry *proc_bus_pci_dir;
 int pci_proc_attach_device(struct pci_dev *dev)
 {
        struct pci_bus *bus = dev->bus;
-       struct proc_dir_entry *de, *e;
+       struct proc_dir_entry *e;
        char name[16];
 
        if (!proc_initialized)
                return -EACCES;
 
-       if (!(de = bus->procdir)) {
-               if (pci_name_bus(name, bus))
-                       return -EEXIST;
-               de = bus->procdir = proc_mkdir(name, proc_bus_pci_dir);
-               if (!de)
+       if (!bus->procdir) {
+               if (pci_proc_domain(bus)) {
+                       sprintf(name, "%04x:%02x", pci_domain_nr(bus),
+                                       bus->number);
+               } else {
+                       sprintf(name, "%02x", bus->number);
+               }
+               bus->procdir = proc_mkdir(name, proc_bus_pci_dir);
+               if (!bus->procdir)
                        return -ENOMEM;
        }
+
        sprintf(name, "%02x.%x", PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
-       e = dev->procent = create_proc_entry(name, S_IFREG | S_IRUGO | S_IWUSR, de);
+       e = create_proc_entry(name, S_IFREG | S_IRUGO | S_IWUSR, bus->procdir);
        if (!e)
                return -ENOMEM;
        e->proc_fops = &proc_bus_pci_operations;
        e->data = dev;
        e->size = dev->cfg_size;
+       dev->procent = e;
 
        return 0;
 }