Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Tejun Heo and committed by
Greg Kroah-Hartman
bc6caf02 6b0afc2a

+3 -14
+3 -14
drivers/pci/pci-sysfs.c
··· 351 351 (S_IWUSR|S_IWGRP), 352 352 NULL, dev_rescan_store); 353 353 354 - static void remove_callback(struct device *dev) 355 - { 356 - pci_stop_and_remove_bus_device_locked(to_pci_dev(dev)); 357 - } 358 - 359 354 static ssize_t 360 - remove_store(struct device *dev, struct device_attribute *dummy, 355 + remove_store(struct device *dev, struct device_attribute *attr, 361 356 const char *buf, size_t count) 362 357 { 363 - int ret = 0; 364 358 unsigned long val; 365 359 366 360 if (kstrtoul(buf, 0, &val) < 0) 367 361 return -EINVAL; 368 362 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)); 376 365 return count; 377 366 } 378 367 static struct device_attribute dev_remove_attr = __ATTR(remove,