diff options
author | Tejun Heo <tj@kernel.org> | 2014-01-10 08:57:28 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-01-10 17:13:59 -0500 |
commit | 6716d289c437ad42dee455d241b29b71a816fbff (patch) | |
tree | 44e0a780d1edf781bedde8d9bd7c66b678ffd0da | |
parent | 1ae06819c77cff1ea2833c94f8c093fe8a5c79db (diff) |
pci: use device_remove_file_self() instead of device_schedule_callback()
driver-core now supports synchrnous self-deletion of attributes and
the asynchrnous removal mechanism is scheduled for removal. Use it
instead of device_schedule_callback(). This makes "remove" behave
synchronously.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-pci@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/pci/pci-sysfs.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index c91e6c18debc..94d1cb819eb6 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -352,32 +352,20 @@ static struct device_attribute dev_rescan_attr = __ATTR(rescan, | |||
352 | (S_IWUSR|S_IWGRP), | 352 | (S_IWUSR|S_IWGRP), |
353 | NULL, dev_rescan_store); | 353 | NULL, dev_rescan_store); |
354 | 354 | ||
355 | static void remove_callback(struct device *dev) | ||
356 | { | ||
357 | struct pci_dev *pdev = to_pci_dev(dev); | ||
358 | |||
359 | mutex_lock(&pci_remove_rescan_mutex); | ||
360 | pci_stop_and_remove_bus_device(pdev); | ||
361 | mutex_unlock(&pci_remove_rescan_mutex); | ||
362 | } | ||
363 | |||
364 | static ssize_t | 355 | static ssize_t |
365 | remove_store(struct device *dev, struct device_attribute *dummy, | 356 | remove_store(struct device *dev, struct device_attribute *attr, |
366 | const char *buf, size_t count) | 357 | const char *buf, size_t count) |
367 | { | 358 | { |
368 | int ret = 0; | ||
369 | unsigned long val; | 359 | unsigned long val; |
370 | 360 | ||
371 | if (kstrtoul(buf, 0, &val) < 0) | 361 | if (kstrtoul(buf, 0, &val) < 0) |
372 | return -EINVAL; | 362 | return -EINVAL; |
373 | 363 | ||
374 | /* An attribute cannot be unregistered by one of its own methods, | 364 | if (val && device_remove_file_self(dev, attr)) { |
375 | * so we have to use this roundabout approach. | 365 | mutex_lock(&pci_remove_rescan_mutex); |
376 | */ | 366 | pci_stop_and_remove_bus_device(to_pci_dev(dev)); |
377 | if (val) | 367 | mutex_unlock(&pci_remove_rescan_mutex); |
378 | ret = device_schedule_callback(dev, remove_callback); | 368 | } |
379 | if (ret) | ||
380 | count = ret; | ||
381 | return count; | 369 | return count; |
382 | } | 370 | } |
383 | static struct device_attribute dev_remove_attr = __ATTR(remove, | 371 | static struct device_attribute dev_remove_attr = __ATTR(remove, |