Loading drivers/pci/bus.c +16 −6 Original line number Diff line number Diff line Loading @@ -77,9 +77,12 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, * This adds a single pci device to the global * device list and adds sysfs and procfs entries */ void __devinit pci_bus_add_device(struct pci_dev *dev) int __devinit pci_bus_add_device(struct pci_dev *dev) { device_add(&dev->dev); int retval; retval = device_add(&dev->dev); if (retval) return retval; down_write(&pci_bus_sem); list_add_tail(&dev->global_list, &pci_devices); Loading @@ -87,6 +90,7 @@ void __devinit pci_bus_add_device(struct pci_dev *dev) pci_proc_attach_device(dev); pci_create_sysfs_dev_files(dev); return 0; } /** Loading @@ -104,6 +108,7 @@ void __devinit pci_bus_add_device(struct pci_dev *dev) void __devinit pci_bus_add_devices(struct pci_bus *bus) { struct pci_dev *dev; int retval; list_for_each_entry(dev, &bus->devices, bus_list) { /* Loading @@ -112,7 +117,9 @@ void __devinit pci_bus_add_devices(struct pci_bus *bus) */ if (!list_empty(&dev->global_list)) continue; pci_bus_add_device(dev); retval = pci_bus_add_device(dev); if (retval) dev_err(&dev->dev, "Error adding device, continuing\n"); } list_for_each_entry(dev, &bus->devices, bus_list) { Loading @@ -131,8 +138,11 @@ void __devinit pci_bus_add_devices(struct pci_bus *bus) up_write(&pci_bus_sem); } pci_bus_add_devices(dev->subordinate); sysfs_create_link(&dev->subordinate->class_dev.kobj, &dev->dev.kobj, "bridge"); retval = sysfs_create_link(&dev->subordinate->class_dev.kobj, &dev->dev.kobj, "bridge"); if (retval) dev_err(&dev->dev, "Error creating sysfs " "bridge symlink, continuing...\n"); } } } Loading drivers/pci/hotplug/fakephp.c +14 −4 Original line number Diff line number Diff line Loading @@ -176,7 +176,9 @@ static void pci_rescan_slot(struct pci_dev *temp) struct pci_bus *bus = temp->bus; struct pci_dev *dev; int func; int retval; u8 hdr_type; if (!pci_read_config_byte(temp, PCI_HEADER_TYPE, &hdr_type)) { temp->hdr_type = hdr_type & 0x7f; if (!pci_find_slot(bus->number, temp->devfn)) { Loading @@ -185,7 +187,11 @@ static void pci_rescan_slot(struct pci_dev *temp) dbg("New device on %s function %x:%x\n", bus->name, temp->devfn >> 3, temp->devfn & 7); pci_bus_add_device(dev); retval = pci_bus_add_device(dev); if (retval) dev_err(&dev->dev, "error adding " "device, continuing.\n"); else add_slot(dev); } } Loading @@ -205,7 +211,11 @@ static void pci_rescan_slot(struct pci_dev *temp) dbg("New device on %s function %x:%x\n", bus->name, temp->devfn >> 3, temp->devfn & 7); pci_bus_add_device(dev); retval = pci_bus_add_device(dev); if (retval) dev_err(&dev->dev, "error adding " "device, continuing.\n"); else add_slot(dev); } } Loading drivers/pci/pci-driver.c +4 −1 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count) subdevice=PCI_ANY_ID, class=0, class_mask=0; unsigned long driver_data=0; int fields=0; int retval = 0; fields = sscanf(buf, "%x %x %x %x %x %x %lux", &vendor, &device, &subvendor, &subdevice, Loading @@ -82,10 +83,12 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count) spin_unlock(&pdrv->dynids.lock); if (get_driver(&pdrv->driver)) { driver_attach(&pdrv->driver); retval = driver_attach(&pdrv->driver); put_driver(&pdrv->driver); } if (retval) return retval; return count; } static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); Loading drivers/pci/pci-sysfs.c +73 −39 Original line number Diff line number Diff line Loading @@ -117,6 +117,7 @@ is_enabled_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct pci_dev *pdev = to_pci_dev(dev); int retval = 0; /* this can crash the machine when done on the "wrong" device */ if (!capable(CAP_SYS_ADMIN)) Loading @@ -126,8 +127,10 @@ is_enabled_store(struct device *dev, struct device_attribute *attr, pci_disable_device(pdev); if (*buf == '1') pci_enable_device(pdev); retval = pci_enable_device(pdev); if (retval) return retval; return count; } Loading Loading @@ -425,16 +428,39 @@ pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, return pci_mmap_page_range(pdev, vma, mmap_type, 0); } /** * pci_remove_resource_files - cleanup resource files * @dev: dev to cleanup * * If we created resource files for @dev, remove them from sysfs and * free their resources. */ static void pci_remove_resource_files(struct pci_dev *pdev) { int i; for (i = 0; i < PCI_ROM_RESOURCE; i++) { struct bin_attribute *res_attr; res_attr = pdev->res_attr[i]; if (res_attr) { sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); kfree(res_attr); } } } /** * pci_create_resource_files - create resource files in sysfs for @dev * @dev: dev in question * * Walk the resources in @dev creating files for each resource available. */ static void pci_create_resource_files(struct pci_dev *pdev) static int pci_create_resource_files(struct pci_dev *pdev) { int i; int retval; /* Expose the PCI resources from this device as files */ for (i = 0; i < PCI_ROM_RESOURCE; i++) { Loading @@ -457,35 +483,19 @@ pci_create_resource_files(struct pci_dev *pdev) res_attr->size = pci_resource_len(pdev, i); res_attr->mmap = pci_mmap_resource; res_attr->private = &pdev->resource[i]; sysfs_create_bin_file(&pdev->dev.kobj, res_attr); } } retval = sysfs_create_bin_file(&pdev->dev.kobj, res_attr); if (retval) { pci_remove_resource_files(pdev); return retval; } /** * pci_remove_resource_files - cleanup resource files * @dev: dev to cleanup * * If we created resource files for @dev, remove them from sysfs and * free their resources. */ static void pci_remove_resource_files(struct pci_dev *pdev) { int i; for (i = 0; i < PCI_ROM_RESOURCE; i++) { struct bin_attribute *res_attr; res_attr = pdev->res_attr[i]; if (res_attr) { sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); kfree(res_attr); } else { return -ENOMEM; } } return 0; } #else /* !HAVE_PCI_MMAP */ static inline void pci_create_resource_files(struct pci_dev *dev) { return; } static inline int pci_create_resource_files(struct pci_dev *dev) { return 0; } static inline void pci_remove_resource_files(struct pci_dev *dev) { return; } #endif /* HAVE_PCI_MMAP */ Loading Loading @@ -570,22 +580,27 @@ static struct bin_attribute pcie_config_attr = { .write = pci_write_config, }; int pci_create_sysfs_dev_files (struct pci_dev *pdev) int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev) { struct bin_attribute *rom_attr = NULL; int retval; if (!sysfs_initialized) return -EACCES; if (pdev->cfg_size < 4096) sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr); retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr); else sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr); retval = sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr); if (retval) goto err; pci_create_resource_files(pdev); retval = pci_create_resource_files(pdev); if (retval) goto err_bin_file; /* If the device has a ROM, try to expose it in sysfs. */ if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) { struct bin_attribute *rom_attr; rom_attr = kzalloc(sizeof(*rom_attr), GFP_ATOMIC); if (rom_attr) { pdev->rom_attr = rom_attr; Loading @@ -595,13 +610,28 @@ int pci_create_sysfs_dev_files (struct pci_dev *pdev) rom_attr->attr.owner = THIS_MODULE; rom_attr->read = pci_read_rom; rom_attr->write = pci_write_rom; sysfs_create_bin_file(&pdev->dev.kobj, rom_attr); retval = sysfs_create_bin_file(&pdev->dev.kobj, rom_attr); if (retval) goto err_rom; } else { retval = -ENOMEM; goto err_bin_file; } } /* add platform-specific attributes */ pcibios_add_platform_entries(pdev); return 0; err_rom: kfree(rom_attr); err_bin_file: if (pdev->cfg_size < 4096) sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); else sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); err: return retval; } /** Loading Loading @@ -630,10 +660,14 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev) static int __init pci_sysfs_init(void) { struct pci_dev *pdev = NULL; int retval; sysfs_initialized = 1; for_each_pci_dev(pdev) pci_create_sysfs_dev_files(pdev); for_each_pci_dev(pdev) { retval = pci_create_sysfs_dev_files(pdev); if (retval) return retval; } return 0; } Loading drivers/pci/pcie/aer/aerdrv_core.c +2 −1 Original line number Diff line number Diff line Loading @@ -357,7 +357,8 @@ static int find_aer_service_iter(struct device *device, void *data) static void find_aer_service(struct pci_dev *dev, struct find_aer_service_data *data) { device_for_each_child(&dev->dev, data, find_aer_service_iter); int retval; retval = device_for_each_child(&dev->dev, data, find_aer_service_iter); } static pci_ers_result_t reset_link(struct pcie_device *aerdev, Loading Loading
drivers/pci/bus.c +16 −6 Original line number Diff line number Diff line Loading @@ -77,9 +77,12 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, * This adds a single pci device to the global * device list and adds sysfs and procfs entries */ void __devinit pci_bus_add_device(struct pci_dev *dev) int __devinit pci_bus_add_device(struct pci_dev *dev) { device_add(&dev->dev); int retval; retval = device_add(&dev->dev); if (retval) return retval; down_write(&pci_bus_sem); list_add_tail(&dev->global_list, &pci_devices); Loading @@ -87,6 +90,7 @@ void __devinit pci_bus_add_device(struct pci_dev *dev) pci_proc_attach_device(dev); pci_create_sysfs_dev_files(dev); return 0; } /** Loading @@ -104,6 +108,7 @@ void __devinit pci_bus_add_device(struct pci_dev *dev) void __devinit pci_bus_add_devices(struct pci_bus *bus) { struct pci_dev *dev; int retval; list_for_each_entry(dev, &bus->devices, bus_list) { /* Loading @@ -112,7 +117,9 @@ void __devinit pci_bus_add_devices(struct pci_bus *bus) */ if (!list_empty(&dev->global_list)) continue; pci_bus_add_device(dev); retval = pci_bus_add_device(dev); if (retval) dev_err(&dev->dev, "Error adding device, continuing\n"); } list_for_each_entry(dev, &bus->devices, bus_list) { Loading @@ -131,8 +138,11 @@ void __devinit pci_bus_add_devices(struct pci_bus *bus) up_write(&pci_bus_sem); } pci_bus_add_devices(dev->subordinate); sysfs_create_link(&dev->subordinate->class_dev.kobj, &dev->dev.kobj, "bridge"); retval = sysfs_create_link(&dev->subordinate->class_dev.kobj, &dev->dev.kobj, "bridge"); if (retval) dev_err(&dev->dev, "Error creating sysfs " "bridge symlink, continuing...\n"); } } } Loading
drivers/pci/hotplug/fakephp.c +14 −4 Original line number Diff line number Diff line Loading @@ -176,7 +176,9 @@ static void pci_rescan_slot(struct pci_dev *temp) struct pci_bus *bus = temp->bus; struct pci_dev *dev; int func; int retval; u8 hdr_type; if (!pci_read_config_byte(temp, PCI_HEADER_TYPE, &hdr_type)) { temp->hdr_type = hdr_type & 0x7f; if (!pci_find_slot(bus->number, temp->devfn)) { Loading @@ -185,7 +187,11 @@ static void pci_rescan_slot(struct pci_dev *temp) dbg("New device on %s function %x:%x\n", bus->name, temp->devfn >> 3, temp->devfn & 7); pci_bus_add_device(dev); retval = pci_bus_add_device(dev); if (retval) dev_err(&dev->dev, "error adding " "device, continuing.\n"); else add_slot(dev); } } Loading @@ -205,7 +211,11 @@ static void pci_rescan_slot(struct pci_dev *temp) dbg("New device on %s function %x:%x\n", bus->name, temp->devfn >> 3, temp->devfn & 7); pci_bus_add_device(dev); retval = pci_bus_add_device(dev); if (retval) dev_err(&dev->dev, "error adding " "device, continuing.\n"); else add_slot(dev); } } Loading
drivers/pci/pci-driver.c +4 −1 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count) subdevice=PCI_ANY_ID, class=0, class_mask=0; unsigned long driver_data=0; int fields=0; int retval = 0; fields = sscanf(buf, "%x %x %x %x %x %x %lux", &vendor, &device, &subvendor, &subdevice, Loading @@ -82,10 +83,12 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count) spin_unlock(&pdrv->dynids.lock); if (get_driver(&pdrv->driver)) { driver_attach(&pdrv->driver); retval = driver_attach(&pdrv->driver); put_driver(&pdrv->driver); } if (retval) return retval; return count; } static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); Loading
drivers/pci/pci-sysfs.c +73 −39 Original line number Diff line number Diff line Loading @@ -117,6 +117,7 @@ is_enabled_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct pci_dev *pdev = to_pci_dev(dev); int retval = 0; /* this can crash the machine when done on the "wrong" device */ if (!capable(CAP_SYS_ADMIN)) Loading @@ -126,8 +127,10 @@ is_enabled_store(struct device *dev, struct device_attribute *attr, pci_disable_device(pdev); if (*buf == '1') pci_enable_device(pdev); retval = pci_enable_device(pdev); if (retval) return retval; return count; } Loading Loading @@ -425,16 +428,39 @@ pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, return pci_mmap_page_range(pdev, vma, mmap_type, 0); } /** * pci_remove_resource_files - cleanup resource files * @dev: dev to cleanup * * If we created resource files for @dev, remove them from sysfs and * free their resources. */ static void pci_remove_resource_files(struct pci_dev *pdev) { int i; for (i = 0; i < PCI_ROM_RESOURCE; i++) { struct bin_attribute *res_attr; res_attr = pdev->res_attr[i]; if (res_attr) { sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); kfree(res_attr); } } } /** * pci_create_resource_files - create resource files in sysfs for @dev * @dev: dev in question * * Walk the resources in @dev creating files for each resource available. */ static void pci_create_resource_files(struct pci_dev *pdev) static int pci_create_resource_files(struct pci_dev *pdev) { int i; int retval; /* Expose the PCI resources from this device as files */ for (i = 0; i < PCI_ROM_RESOURCE; i++) { Loading @@ -457,35 +483,19 @@ pci_create_resource_files(struct pci_dev *pdev) res_attr->size = pci_resource_len(pdev, i); res_attr->mmap = pci_mmap_resource; res_attr->private = &pdev->resource[i]; sysfs_create_bin_file(&pdev->dev.kobj, res_attr); } } retval = sysfs_create_bin_file(&pdev->dev.kobj, res_attr); if (retval) { pci_remove_resource_files(pdev); return retval; } /** * pci_remove_resource_files - cleanup resource files * @dev: dev to cleanup * * If we created resource files for @dev, remove them from sysfs and * free their resources. */ static void pci_remove_resource_files(struct pci_dev *pdev) { int i; for (i = 0; i < PCI_ROM_RESOURCE; i++) { struct bin_attribute *res_attr; res_attr = pdev->res_attr[i]; if (res_attr) { sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); kfree(res_attr); } else { return -ENOMEM; } } return 0; } #else /* !HAVE_PCI_MMAP */ static inline void pci_create_resource_files(struct pci_dev *dev) { return; } static inline int pci_create_resource_files(struct pci_dev *dev) { return 0; } static inline void pci_remove_resource_files(struct pci_dev *dev) { return; } #endif /* HAVE_PCI_MMAP */ Loading Loading @@ -570,22 +580,27 @@ static struct bin_attribute pcie_config_attr = { .write = pci_write_config, }; int pci_create_sysfs_dev_files (struct pci_dev *pdev) int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev) { struct bin_attribute *rom_attr = NULL; int retval; if (!sysfs_initialized) return -EACCES; if (pdev->cfg_size < 4096) sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr); retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr); else sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr); retval = sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr); if (retval) goto err; pci_create_resource_files(pdev); retval = pci_create_resource_files(pdev); if (retval) goto err_bin_file; /* If the device has a ROM, try to expose it in sysfs. */ if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) { struct bin_attribute *rom_attr; rom_attr = kzalloc(sizeof(*rom_attr), GFP_ATOMIC); if (rom_attr) { pdev->rom_attr = rom_attr; Loading @@ -595,13 +610,28 @@ int pci_create_sysfs_dev_files (struct pci_dev *pdev) rom_attr->attr.owner = THIS_MODULE; rom_attr->read = pci_read_rom; rom_attr->write = pci_write_rom; sysfs_create_bin_file(&pdev->dev.kobj, rom_attr); retval = sysfs_create_bin_file(&pdev->dev.kobj, rom_attr); if (retval) goto err_rom; } else { retval = -ENOMEM; goto err_bin_file; } } /* add platform-specific attributes */ pcibios_add_platform_entries(pdev); return 0; err_rom: kfree(rom_attr); err_bin_file: if (pdev->cfg_size < 4096) sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); else sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); err: return retval; } /** Loading Loading @@ -630,10 +660,14 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev) static int __init pci_sysfs_init(void) { struct pci_dev *pdev = NULL; int retval; sysfs_initialized = 1; for_each_pci_dev(pdev) pci_create_sysfs_dev_files(pdev); for_each_pci_dev(pdev) { retval = pci_create_sysfs_dev_files(pdev); if (retval) return retval; } return 0; } Loading
drivers/pci/pcie/aer/aerdrv_core.c +2 −1 Original line number Diff line number Diff line Loading @@ -357,7 +357,8 @@ static int find_aer_service_iter(struct device *device, void *data) static void find_aer_service(struct pci_dev *dev, struct find_aer_service_data *data) { device_for_each_child(&dev->dev, data, find_aer_service_iter); int retval; retval = device_for_each_child(&dev->dev, data, find_aer_service_iter); } static pci_ers_result_t reset_link(struct pcie_device *aerdev, Loading