Skip to content

Commit

Permalink
driver core: Use device's fwnode to check if it is waiting for suppliers
Browse files Browse the repository at this point in the history
To check if a device is still waiting for its supplier devices to be
added, we used to check if the devices is in a global
waiting_for_suppliers list. Since the global list will be deleted in
subsequent patches, this patch stops using this check.

Instead, this patch uses a more device specific check. It checks if the
device's fwnode has any fwnode links that haven't been converted to
device links yet.

Signed-off-by: Saravana Kannan <saravanak@google.com>
Link: https://lore.kernel.org/r/20201121020232.908850-14-saravanak@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Saravana Kannan authored and Greg Kroah-Hartman committed Dec 9, 2020
1 parent c2c724c commit 25ac86c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static DEFINE_MUTEX(wfs_lock);
static LIST_HEAD(deferred_sync);
static unsigned int defer_sync_state_count = 1;
static DEFINE_MUTEX(fwnode_link_lock);
static bool fw_devlink_is_permissive(void);

/**
* fwnode_link_add - Create a link between two fwnode_handles.
Expand Down Expand Up @@ -995,13 +996,13 @@ int device_links_check_suppliers(struct device *dev)
* Device waiting for supplier to become available is not allowed to
* probe.
*/
mutex_lock(&wfs_lock);
if (!list_empty(&dev->links.needs_suppliers) &&
dev->links.need_for_probe) {
mutex_unlock(&wfs_lock);
mutex_lock(&fwnode_link_lock);
if (dev->fwnode && !list_empty(&dev->fwnode->suppliers) &&
!fw_devlink_is_permissive()) {
mutex_unlock(&fwnode_link_lock);
return -EPROBE_DEFER;
}
mutex_unlock(&wfs_lock);
mutex_unlock(&fwnode_link_lock);

device_links_write_lock();

Expand Down Expand Up @@ -1167,8 +1168,7 @@ static ssize_t waiting_for_supplier_show(struct device *dev,
bool val;

device_lock(dev);
val = !list_empty(&dev->links.needs_suppliers)
&& dev->links.need_for_probe;
val = !list_empty(&dev->fwnode->suppliers);
device_unlock(dev);
return sysfs_emit(buf, "%u\n", val);
}
Expand Down Expand Up @@ -2200,7 +2200,7 @@ static int device_add_attrs(struct device *dev)
goto err_remove_dev_groups;
}

if (fw_devlink_flags && !fw_devlink_is_permissive()) {
if (fw_devlink_flags && !fw_devlink_is_permissive() && dev->fwnode) {
error = device_create_file(dev, &dev_attr_waiting_for_supplier);
if (error)
goto err_remove_dev_online;
Expand Down

0 comments on commit 25ac86c

Please sign in to comment.