]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
device connection: Find connections also by checking the references
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>
Fri, 31 May 2019 14:15:40 +0000 (17:15 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 3 Jun 2019 08:55:38 +0000 (10:55 +0200)
We can also use this API to find named references that the
device nodes have by using fwnode_property_get_reference_args()
function.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/devcon.c
drivers/usb/roles/class.c

index 04db9ae235e41ef2a9d254ce6a4c76977ef193b1..f7035fc12b92801c8f8a6f2c94a740aa78e55cf1 100644 (file)
@@ -38,6 +38,28 @@ fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
        return NULL;
 }
 
+static void *
+fwnode_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
+                   void *data, devcon_match_fn_t match)
+{
+       struct device_connection con = { };
+       void *ret;
+       int i;
+
+       for (i = 0; ; i++) {
+               con.fwnode = fwnode_find_reference(fwnode, con_id, i);
+               if (IS_ERR(con.fwnode))
+                       break;
+
+               ret = match(&con, -1, data);
+               fwnode_handle_put(con.fwnode);
+               if (ret)
+                       return ret;
+       }
+
+       return NULL;
+}
+
 /**
  * device_connection_find_match - Find physical connection to a device
  * @dev: Device with the connection
@@ -65,6 +87,10 @@ void *device_connection_find_match(struct device *dev, const char *con_id,
                ret = fwnode_graph_devcon_match(fwnode, con_id, data, match);
                if (ret)
                        return ret;
+
+               ret = fwnode_devcon_match(fwnode, con_id, data, match);
+               if (ret)
+                       return ret;
        }
 
        mutex_lock(&devcon_lock);
index f45d8df5cfb8aa3255f89f6dde016614c9e11ea4..86defca6623e1b80e00709255df7c65787b296e5 100644 (file)
@@ -101,7 +101,7 @@ static void *usb_role_switch_match(struct device_connection *con, int ep,
        struct device *dev;
 
        if (con->fwnode) {
-               if (!fwnode_property_present(con->fwnode, con->id))
+               if (con->id && !fwnode_property_present(con->fwnode, con->id))
                        return NULL;
 
                dev = class_find_device(role_class, NULL, con->fwnode,