Skip to content

Commit 0332450

Browse files
Saravana Kannangregkh
authored andcommitted
driver core: Allow fwnode_operations.add_links to differentiate errors
When add_links() still has suppliers that it needs to link to in the future, this patch allows it to differentiate between suppliers that are needed for probing vs suppliers that are needed for sync_state() correctness. Signed-off-by: Saravana Kannan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent bcbbcfd commit 0332450

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

drivers/base/core.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,7 +2297,7 @@ int device_add(struct device *dev)
22972297
struct device *parent;
22982298
struct kobject *kobj;
22992299
struct class_interface *class_intf;
2300-
int error = -EINVAL;
2300+
int error = -EINVAL, fw_ret;
23012301
struct kobject *glue_dir = NULL;
23022302

23032303
dev = get_device(dev);
@@ -2413,9 +2413,13 @@ int device_add(struct device *dev)
24132413
*/
24142414
device_link_add_missing_supplier_links();
24152415

2416-
if (fwnode_has_op(dev->fwnode, add_links)
2417-
&& fwnode_call_int_op(dev->fwnode, add_links, dev))
2418-
device_link_wait_for_mandatory_supplier(dev, true);
2416+
if (fwnode_has_op(dev->fwnode, add_links)) {
2417+
fw_ret = fwnode_call_int_op(dev->fwnode, add_links, dev);
2418+
if (fw_ret == -ENODEV)
2419+
device_link_wait_for_mandatory_supplier(dev);
2420+
else if (fw_ret)
2421+
device_link_wait_for_optional_supplier(dev);
2422+
}
24192423

24202424
bus_probe_device(dev);
24212425
if (parent)

include/linux/fwnode.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,15 @@ struct fwnode_reference_args {
9494
* available suppliers.
9595
*
9696
* Return 0 if device links have been successfully created to all
97-
* the suppliers of this device or if the supplier information is
98-
* not known. Return an error if and only if the supplier
99-
* information is known but some of the suppliers are not yet
100-
* available to create device links to.
97+
* the suppliers this device needs to create device links to or if
98+
* the supplier information is not known.
99+
*
100+
* Return -ENODEV if and only if the suppliers needed for probing
101+
* the device are not yet available to create device links to.
102+
*
103+
* Return -EAGAIN if there are suppliers that need to be linked to
104+
* that are not yet available but none of those suppliers are
105+
* necessary for probing this device.
101106
*/
102107
struct fwnode_operations {
103108
struct fwnode_handle *(*get)(struct fwnode_handle *fwnode);

0 commit comments

Comments
 (0)