powerpc: mpc5200: fix build error on mpc52xx_psc_spi device driver
[safe/jmp/linux-2.6] / drivers / pci / pci-sysfs.c
index 6543cbe..8dcf145 100644 (file)
@@ -20,7 +20,7 @@
 #include <linux/stat.h>
 #include <linux/topology.h>
 #include <linux/mm.h>
-
+#include <linux/capability.h>
 #include "pci.h"
 
 static int sysfs_initialized;  /* = 0 */
@@ -358,7 +358,7 @@ pci_read_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr,
                   char *buf, loff_t off, size_t count)
 {
         struct pci_bus *bus = to_pci_bus(container_of(kobj,
-                                                      struct class_device,
+                                                      struct device,
                                                      kobj));
 
         /* Only support 1, 2 or 4 byte accesses */
@@ -383,7 +383,7 @@ pci_write_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr,
                    char *buf, loff_t off, size_t count)
 {
         struct pci_bus *bus = to_pci_bus(container_of(kobj,
-                                                     struct class_device,
+                                                     struct device,
                                                      kobj));
         /* Only support 1, 2 or 4 byte accesses */
         if (count != 1 && count != 2 && count != 4)
@@ -407,7 +407,7 @@ pci_mmap_legacy_mem(struct kobject *kobj, struct bin_attribute *attr,
                     struct vm_area_struct *vma)
 {
         struct pci_bus *bus = to_pci_bus(container_of(kobj,
-                                                      struct class_device,
+                                                      struct device,
                                                      kobj));
 
         return pci_mmap_legacy_page_range(bus, vma);
@@ -603,6 +603,11 @@ static struct bin_attribute pcie_config_attr = {
        .write = pci_write_config,
 };
 
+int __attribute__ ((weak)) pcibios_add_platform_entries(struct pci_dev *dev)
+{
+       return 0;
+}
+
 int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
 {
        struct bin_attribute *rom_attr = NULL;
@@ -642,10 +647,14 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
                }
        }
        /* add platform-specific attributes */
-       pcibios_add_platform_entries(pdev);
+       if (pcibios_add_platform_entries(pdev))
+               goto err_rom_file;
 
        return 0;
 
+err_rom_file:
+       if (pci_resource_len(pdev, PCI_ROM_RESOURCE))
+               sysfs_remove_bin_file(&pdev->dev.kobj, rom_attr);
 err_rom:
        kfree(rom_attr);
 err_resource_files:
@@ -693,8 +702,10 @@ static int __init pci_sysfs_init(void)
        sysfs_initialized = 1;
        for_each_pci_dev(pdev) {
                retval = pci_create_sysfs_dev_files(pdev);
-               if (retval)
+               if (retval) {
+                       pci_dev_put(pdev);
                        return retval;
+               }
        }
 
        return 0;