Skip to content

Commit 25ac86c

Browse files
Saravana Kannangregkh
authored andcommitted
driver core: Use device's fwnode to check if it is waiting for suppliers
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>
1 parent c2c724c commit 25ac86c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/base/core.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ static DEFINE_MUTEX(wfs_lock);
5151
static LIST_HEAD(deferred_sync);
5252
static unsigned int defer_sync_state_count = 1;
5353
static DEFINE_MUTEX(fwnode_link_lock);
54+
static bool fw_devlink_is_permissive(void);
5455

5556
/**
5657
* fwnode_link_add - Create a link between two fwnode_handles.
@@ -995,13 +996,13 @@ int device_links_check_suppliers(struct device *dev)
995996
* Device waiting for supplier to become available is not allowed to
996997
* probe.
997998
*/
998-
mutex_lock(&wfs_lock);
999-
if (!list_empty(&dev->links.needs_suppliers) &&
1000-
dev->links.need_for_probe) {
1001-
mutex_unlock(&wfs_lock);
999+
mutex_lock(&fwnode_link_lock);
1000+
if (dev->fwnode && !list_empty(&dev->fwnode->suppliers) &&
1001+
!fw_devlink_is_permissive()) {
1002+
mutex_unlock(&fwnode_link_lock);
10021003
return -EPROBE_DEFER;
10031004
}
1004-
mutex_unlock(&wfs_lock);
1005+
mutex_unlock(&fwnode_link_lock);
10051006

10061007
device_links_write_lock();
10071008

@@ -1167,8 +1168,7 @@ static ssize_t waiting_for_supplier_show(struct device *dev,
11671168
bool val;
11681169

11691170
device_lock(dev);
1170-
val = !list_empty(&dev->links.needs_suppliers)
1171-
&& dev->links.need_for_probe;
1171+
val = !list_empty(&dev->fwnode->suppliers);
11721172
device_unlock(dev);
11731173
return sysfs_emit(buf, "%u\n", val);
11741174
}
@@ -2200,7 +2200,7 @@ static int device_add_attrs(struct device *dev)
22002200
goto err_remove_dev_groups;
22012201
}
22022202

2203-
if (fw_devlink_flags && !fw_devlink_is_permissive()) {
2203+
if (fw_devlink_flags && !fw_devlink_is_permissive() && dev->fwnode) {
22042204
error = device_create_file(dev, &dev_attr_waiting_for_supplier);
22052205
if (error)
22062206
goto err_remove_dev_online;

0 commit comments

Comments
 (0)