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

Revert "driver core: Add edit_links() callback for drivers"

This reverts commit 134b23eec9e3a3c795a6ceb0efe2fa63e87983b2.

Based on a lot of email and in-person discussions, this patch series is
being reworked to address a number of issues that were pointed out that
needed to be taken care of before it should be merged. It will be
resubmitted with those changes hopefully soon.

Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Saravana Kannan <saravanak@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+2 -71
+2 -22
drivers/base/core.c
··· 440 440 } 441 441 442 442 /** 443 - * device_link_remove_from_wfs - Unmark device as waiting for supplier 444 - * @consumer: Consumer device 445 - * 446 - * Unmark the consumer device as waiting for suppliers to become available. 447 - */ 448 - void device_link_remove_from_wfs(struct device *consumer) 449 - { 450 - mutex_lock(&wfs_lock); 451 - list_del_init(&consumer->links.needs_suppliers); 452 - mutex_unlock(&wfs_lock); 453 - } 454 - 455 - /** 456 443 * device_link_check_waiting_consumers - Try to unmark waiting consumers 457 444 * 458 445 * Loops through all consumers waiting on suppliers and tries to add all their ··· 456 469 static void device_link_check_waiting_consumers(void) 457 470 { 458 471 struct device *dev, *tmp; 459 - int ret; 460 472 461 473 mutex_lock(&wfs_lock); 462 474 list_for_each_entry_safe(dev, tmp, &wait_for_suppliers, 463 - links.needs_suppliers) { 464 - ret = 0; 465 - if (dev->has_edit_links) 466 - ret = driver_edit_links(dev); 467 - else if (dev->bus->add_links) 468 - ret = dev->bus->add_links(dev); 469 - if (!ret) 475 + links.needs_suppliers) 476 + if (!dev->bus->add_links(dev)) 470 477 list_del_init(&dev->links.needs_suppliers); 471 - } 472 478 mutex_unlock(&wfs_lock); 473 479 } 474 480
-29
drivers/base/dd.c
··· 710 710 pr_debug("bus: '%s': %s: matched device %s with driver %s\n", 711 711 drv->bus->name, __func__, dev_name(dev), drv->name); 712 712 713 - if (drv->edit_links) { 714 - if (drv->edit_links(dev)) 715 - dev->has_edit_links = true; 716 - else 717 - device_link_remove_from_wfs(dev); 718 - } 719 713 pm_runtime_get_suppliers(dev); 720 714 if (dev->parent) 721 715 pm_runtime_get_sync(dev->parent); ··· 797 803 */ 798 804 bool have_async; 799 805 }; 800 - 801 - static int __driver_edit_links(struct device_driver *drv, void *data) 802 - { 803 - struct device *dev = data; 804 - 805 - if (!drv->edit_links) 806 - return 0; 807 - 808 - if (driver_match_device(drv, dev) <= 0) 809 - return 0; 810 - 811 - return drv->edit_links(dev); 812 - } 813 - 814 - int driver_edit_links(struct device *dev) 815 - { 816 - int ret; 817 - 818 - device_lock(dev); 819 - ret = bus_for_each_drv(dev->bus, NULL, dev, __driver_edit_links); 820 - device_unlock(dev); 821 - return ret; 822 - } 823 806 824 807 static int __device_attach_driver(struct device_driver *drv, void *_data) 825 808 {
-20
include/linux/device.h
··· 349 349 * @probe_type: Type of the probe (synchronous or asynchronous) to use. 350 350 * @of_match_table: The open firmware table. 351 351 * @acpi_match_table: The ACPI match table. 352 - * @edit_links: Called to allow a matched driver to edit the device links the 353 - * bus might have added incorrectly. This will be useful to handle 354 - * cases where the bus incorrectly adds functional dependencies 355 - * that aren't true or tries to create cyclic dependencies. But 356 - * doesn't correctly handle functional dependencies that are 357 - * missed by the bus as the supplier's sync_state might get to 358 - * execute before the driver for a missing consumer is loaded and 359 - * gets to edit the device links for the consumer. 360 - * 361 - * This function might be called multiple times after a new device 362 - * is added. The function is expected to create all the device 363 - * links for the new device and return 0 if it was completed 364 - * successfully or return an error if it needs to be reattempted 365 - * in the future. 366 352 * @probe: Called to query the existence of a specific device, 367 353 * whether this driver can work with it, and bind the driver 368 354 * to a specific device. ··· 390 404 const struct of_device_id *of_match_table; 391 405 const struct acpi_device_id *acpi_match_table; 392 406 393 - int (*edit_links)(struct device *dev); 394 407 int (*probe) (struct device *dev); 395 408 int (*remove) (struct device *dev); 396 409 void (*shutdown) (struct device *dev); ··· 1225 1240 * @offline: Set after successful invocation of bus type's .offline(). 1226 1241 * @of_node_reused: Set if the device-tree node is shared with an ancestor 1227 1242 * device. 1228 - * @has_edit_links: This device has a driver than is capable of 1229 - * editing the device links created by driver core. 1230 1243 * @dma_coherent: this particular device is dma coherent, even if the 1231 1244 * architecture supports non-coherent devices. 1232 1245 * ··· 1321 1338 bool offline_disabled:1; 1322 1339 bool offline:1; 1323 1340 bool of_node_reused:1; 1324 - bool has_edit_links:1; 1325 1341 #if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \ 1326 1342 defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \ 1327 1343 defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) ··· 1572 1590 extern int __must_check driver_attach(struct device_driver *drv); 1573 1591 extern void device_initial_probe(struct device *dev); 1574 1592 extern int __must_check device_reprobe(struct device *dev); 1575 - extern int driver_edit_links(struct device *dev); 1576 1593 1577 1594 extern bool device_is_bound(struct device *dev); 1578 1595 ··· 1663 1682 struct device *supplier, u32 flags); 1664 1683 void device_link_del(struct device_link *link); 1665 1684 void device_link_remove(void *consumer, struct device *supplier); 1666 - void device_link_remove_from_wfs(struct device *consumer); 1667 1685 1668 1686 #ifndef dev_fmt 1669 1687 #define dev_fmt(fmt) fmt