Skip to content

Commit bc6caf0

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 6b0afc2 commit bc6caf0

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

drivers/pci/pci-sysfs.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -351,28 +351,17 @@ static struct device_attribute dev_rescan_attr = __ATTR(rescan,
351351
(S_IWUSR|S_IWGRP),
352352
NULL, dev_rescan_store);
353353

354-
static void remove_callback(struct device *dev)
355-
{
356-
pci_stop_and_remove_bus_device_locked(to_pci_dev(dev));
357-
}
358-
359354
static ssize_t
360-
remove_store(struct device *dev, struct device_attribute *dummy,
355+
remove_store(struct device *dev, struct device_attribute *attr,
361356
const char *buf, size_t count)
362357
{
363-
int ret = 0;
364358
unsigned long val;
365359

366360
if (kstrtoul(buf, 0, &val) < 0)
367361
return -EINVAL;
368362

369-
/* An attribute cannot be unregistered by one of its own methods,
370-
* so we have to use this roundabout approach.
371-
*/
372-
if (val)
373-
ret = device_schedule_callback(dev, remove_callback);
374-
if (ret)
375-
count = ret;
363+
if (val && device_remove_file_self(dev, attr))
364+
pci_stop_and_remove_bus_device_locked(to_pci_dev(dev));
376365
return count;
377366
}
378367
static struct device_attribute dev_remove_attr = __ATTR(remove,

0 commit comments

Comments
 (0)