Skip to content

Commit 6716d28

Browse files
htejungregkh
authored andcommitted
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>
1 parent 1ae0681 commit 6716d28

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

drivers/pci/pci-sysfs.c

+6-18
Original file line numberDiff line numberDiff line change
@@ -352,32 +352,20 @@ static struct device_attribute dev_rescan_attr = __ATTR(rescan,
352352
(S_IWUSR|S_IWGRP),
353353
NULL, dev_rescan_store);
354354

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-
364355
static ssize_t
365-
remove_store(struct device *dev, struct device_attribute *dummy,
356+
remove_store(struct device *dev, struct device_attribute *attr,
366357
const char *buf, size_t count)
367358
{
368-
int ret = 0;
369359
unsigned long val;
370360

371361
if (kstrtoul(buf, 0, &val) < 0)
372362
return -EINVAL;
373363

374-
/* An attribute cannot be unregistered by one of its own methods,
375-
* so we have to use this roundabout approach.
376-
*/
377-
if (val)
378-
ret = device_schedule_callback(dev, remove_callback);
379-
if (ret)
380-
count = ret;
364+
if (val && device_remove_file_self(dev, attr)) {
365+
mutex_lock(&pci_remove_rescan_mutex);
366+
pci_stop_and_remove_bus_device(to_pci_dev(dev));
367+
mutex_unlock(&pci_remove_rescan_mutex);
368+
}
381369
return count;
382370
}
383371
static struct device_attribute dev_remove_attr = __ATTR(remove,

0 commit comments

Comments
 (0)