]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
driver core: Allow fwnode_operations.add_links to differentiate errors
authorSaravana Kannan <saravanak@google.com>
Mon, 28 Oct 2019 22:00:24 +0000 (15:00 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 2 Nov 2019 17:05:18 +0000 (18:05 +0100)
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 <saravanak@google.com>
Link: https://lore.kernel.org/r/20191028220027.251605-4-saravanak@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/core.c
include/linux/fwnode.h

index 48cd43a91ce6a43954ec72c503e782e11914f75a..e6d3e6d485daab3d8801b887df111a609ac34064 100644 (file)
@@ -2297,7 +2297,7 @@ int device_add(struct device *dev)
        struct device *parent;
        struct kobject *kobj;
        struct class_interface *class_intf;
-       int error = -EINVAL;
+       int error = -EINVAL, fw_ret;
        struct kobject *glue_dir = NULL;
 
        dev = get_device(dev);
@@ -2413,9 +2413,13 @@ int device_add(struct device *dev)
         */
        device_link_add_missing_supplier_links();
 
-       if (fwnode_has_op(dev->fwnode, add_links)
-           && fwnode_call_int_op(dev->fwnode, add_links, dev))
-               device_link_wait_for_mandatory_supplier(dev, true);
+       if (fwnode_has_op(dev->fwnode, add_links)) {
+               fw_ret = fwnode_call_int_op(dev->fwnode, add_links, dev);
+               if (fw_ret == -ENODEV)
+                       device_link_wait_for_mandatory_supplier(dev);
+               else if (fw_ret)
+                       device_link_wait_for_optional_supplier(dev);
+       }
 
        bus_probe_device(dev);
        if (parent)
index 97223e2410bd26b6f21f96af69b1371b3a940b2f..766ff9bb58760bd5ce6342567d38435710b0cbed 100644 (file)
@@ -94,10 +94,15 @@ struct fwnode_reference_args {
  *             available suppliers.
  *
  *             Return 0 if device links have been successfully created to all
- *             the suppliers of this device or if the supplier information is
- *             not known. Return an error if and only if the supplier
- *             information is known but some of the suppliers are not yet
- *             available to create device links to.
+ *             the suppliers this device needs to create device links to or if
+ *             the supplier information is not known.
+ *
+ *             Return -ENODEV if and only if the suppliers needed for probing
+ *             the device are not yet available to create device links to.
+ *
+ *             Return -EAGAIN if there are suppliers that need to be linked to
+ *             that are not yet available but none of those suppliers are
+ *             necessary for probing this device.
  */
 struct fwnode_operations {
        struct fwnode_handle *(*get)(struct fwnode_handle *fwnode);