Merge tag 'driver-core-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / drivers / base / devcon.c
index 04db9ae235e41ef2a9d254ce6a4c76977ef193b1..09f28479b243ac93f1d9d149db3db1f6ca71799d 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);
@@ -107,7 +133,7 @@ static struct bus_type *generic_match_buses[] = {
        NULL,
 };
 
-static int device_fwnode_match(struct device *dev, void *fwnode)
+static int device_fwnode_match(struct device *dev, const void *fwnode)
 {
        return dev_fwnode(dev) == fwnode;
 }