Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 36071
b: refs/heads/master
c: b19441a
h: refs/heads/master
i:
  36069: edfcd80
  36067: c52bc3c
  36063: 0fd5b56
v: v3
  • Loading branch information
Greg Kroah-Hartman committed Sep 27, 2006
1 parent db8e552 commit fc2ac63
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 63 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 660a0e8fdf85f30b1e5f6905a78361476094eb7c
refs/heads/master: b19441af185559118e8247382ea4f2f76ebffc6d
22 changes: 16 additions & 6 deletions trunk/drivers/pci/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,20 @@ 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);
up_write(&pci_bus_sem);

pci_proc_attach_device(dev);
pci_create_sysfs_dev_files(dev);
return 0;
}

/**
Expand All @@ -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) {
/*
Expand All @@ -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) {
Expand All @@ -129,10 +136,13 @@ void __devinit pci_bus_add_devices(struct pci_bus *bus)
list_add_tail(&dev->subordinate->node,
&dev->bus->children);
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");
}
}
}
Expand Down
18 changes: 14 additions & 4 deletions trunk/drivers/pci/hotplug/fakephp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -185,8 +187,12 @@ 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);
add_slot(dev);
retval = pci_bus_add_device(dev);
if (retval)
dev_err(&dev->dev, "error adding "
"device, continuing.\n");
else
add_slot(dev);
}
}
/* multifunction device? */
Expand All @@ -205,8 +211,12 @@ 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);
add_slot(dev);
retval = pci_bus_add_device(dev);
if (retval)
dev_err(&dev->dev, "error adding "
"device, continuing.\n");
else
add_slot(dev);
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion trunk/drivers/pci/pci-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down
112 changes: 73 additions & 39 deletions trunk/drivers/pci/pci-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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;
}

Expand Down Expand Up @@ -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++) {
Expand All @@ -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);
}
}
}

/**
* 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);
retval = sysfs_create_bin_file(&pdev->dev.kobj, res_attr);
if (retval) {
pci_remove_resource_files(pdev);
return retval;
}
} 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 */

Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/pci/pcie/aer/aerdrv_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions trunk/drivers/pci/pcie/portdrv_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,7 @@ static int suspend_iter(struct device *dev, void *data)

int pcie_port_device_suspend(struct pci_dev *dev, pm_message_t state)
{
device_for_each_child(&dev->dev, &state, suspend_iter);
return 0;
return device_for_each_child(&dev->dev, &state, suspend_iter);
}

static int resume_iter(struct device *dev, void *data)
Expand All @@ -359,8 +358,7 @@ static int resume_iter(struct device *dev, void *data)

int pcie_port_device_resume(struct pci_dev *dev)
{
device_for_each_child(&dev->dev, NULL, resume_iter);
return 0;
return device_for_each_child(&dev->dev, NULL, resume_iter);
}
#endif

Expand Down
16 changes: 12 additions & 4 deletions trunk/drivers/pci/pcie/portdrv_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ static pci_ers_result_t pcie_portdrv_error_detected(struct pci_dev *dev,
{
struct aer_broadcast_data result_data =
{error, PCI_ERS_RESULT_CAN_RECOVER};
int retval;

device_for_each_child(&dev->dev, &result_data, error_detected_iter);
/* can not fail */
retval = device_for_each_child(&dev->dev, &result_data, error_detected_iter);

return result_data.result;
}
Expand Down Expand Up @@ -181,8 +183,10 @@ static int mmio_enabled_iter(struct device *device, void *data)
static pci_ers_result_t pcie_portdrv_mmio_enabled(struct pci_dev *dev)
{
pci_ers_result_t status = PCI_ERS_RESULT_RECOVERED;
int retval;

device_for_each_child(&dev->dev, &status, mmio_enabled_iter);
/* get true return value from &status */
retval = device_for_each_child(&dev->dev, &status, mmio_enabled_iter);
return status;
}

Expand Down Expand Up @@ -214,14 +218,16 @@ static int slot_reset_iter(struct device *device, void *data)
static pci_ers_result_t pcie_portdrv_slot_reset(struct pci_dev *dev)
{
pci_ers_result_t status;
int retval;

/* If fatal, restore cfg space for possible link reset at upstream */
if (dev->error_state == pci_channel_io_frozen) {
pcie_portdrv_restore_config(dev);
pci_enable_pcie_error_reporting(dev);
}

device_for_each_child(&dev->dev, &status, slot_reset_iter);
/* get true return value from &status */
retval = device_for_each_child(&dev->dev, &status, slot_reset_iter);

return status;
}
Expand All @@ -248,7 +254,9 @@ static int resume_iter(struct device *device, void *data)

static void pcie_portdrv_err_resume(struct pci_dev *dev)
{
device_for_each_child(&dev->dev, NULL, resume_iter);
int retval;
/* nothing to do with error value, if it ever happens */
retval = device_for_each_child(&dev->dev, NULL, resume_iter);
}

/*
Expand Down
Loading

0 comments on commit fc2ac63

Please sign in to comment.