diff options
author | Yinghai Lu <yinghai@kernel.org> | 2011-05-12 20:11:39 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2011-05-21 15:17:12 -0400 |
commit | b9d320fcb6259baffaeaf93a5fce252cd09333d6 (patch) | |
tree | c5372d704719ff2c6f7b8d2b6bb3c04901cde242 /drivers/pci/pci-sysfs.c | |
parent | da7822e5ad71ec9b745b412639f1e5e0ba795a20 (diff) |
PCI: add rescan to /sys/.../pci_bus/.../
After remove the device from /sys, we have to rescan all or
find out the bridge and access /sys../device/rescan there.
this patch add /sys/.../pci_bus/.../rescan. So user can rescan more easy.
that is more clean and easy to understand.
like after remove 0000:c4:00.0, you can rescan 0000:c4 directly.
-v2: According to Jesse, use function instead of exposing attr, so could hide
#ifdef in header file.
also add code to remove rescan file in remove path.
-v3: GregKH pointed out that we should use dev_attrs to avoid racing.
So add pcibus_attrs and make it to be member of pcibus_attrs.
-v4: Change name to pcibus_dev_attrs according to GregKH
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/pci-sysfs.c')
-rw-r--r-- | drivers/pci/pci-sysfs.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index f8deb3e380a2..c690abc0e5b8 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -318,6 +318,25 @@ remove_store(struct device *dev, struct device_attribute *dummy, | |||
318 | count = ret; | 318 | count = ret; |
319 | return count; | 319 | return count; |
320 | } | 320 | } |
321 | |||
322 | static ssize_t | ||
323 | dev_bus_rescan_store(struct device *dev, struct device_attribute *attr, | ||
324 | const char *buf, size_t count) | ||
325 | { | ||
326 | unsigned long val; | ||
327 | struct pci_bus *bus = to_pci_bus(dev); | ||
328 | |||
329 | if (strict_strtoul(buf, 0, &val) < 0) | ||
330 | return -EINVAL; | ||
331 | |||
332 | if (val) { | ||
333 | mutex_lock(&pci_remove_rescan_mutex); | ||
334 | pci_rescan_bus(bus); | ||
335 | mutex_unlock(&pci_remove_rescan_mutex); | ||
336 | } | ||
337 | return count; | ||
338 | } | ||
339 | |||
321 | #endif | 340 | #endif |
322 | 341 | ||
323 | struct device_attribute pci_dev_attrs[] = { | 342 | struct device_attribute pci_dev_attrs[] = { |
@@ -347,6 +366,13 @@ struct device_attribute pci_dev_attrs[] = { | |||
347 | __ATTR_NULL, | 366 | __ATTR_NULL, |
348 | }; | 367 | }; |
349 | 368 | ||
369 | struct device_attribute pcibus_dev_attrs[] = { | ||
370 | #ifdef CONFIG_HOTPLUG | ||
371 | __ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_bus_rescan_store), | ||
372 | #endif | ||
373 | __ATTR_NULL, | ||
374 | }; | ||
375 | |||
350 | static ssize_t | 376 | static ssize_t |
351 | boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf) | 377 | boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf) |
352 | { | 378 | { |