coresight: Deduplicate bus_find_device() by name matching
authorLukas Wunner <lukas@wunner.de>
Mon, 18 Dec 2017 18:05:42 +0000 (11:05 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Dec 2017 09:05:18 +0000 (10:05 +0100)
No need to reinvent the wheel, we have bus_find_device_by_name().

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwtracing/coresight/coresight.c

index b8091bef21dc79085c450c783b5784d229c3b333..389c4baeca9d261310357242ad7cd68c97fbdf3b 100644 (file)
@@ -843,32 +843,17 @@ static void coresight_fixup_orphan_conns(struct coresight_device *csdev)
 }
 
 
-static int coresight_name_match(struct device *dev, void *data)
-{
-       char *to_match;
-       struct coresight_device *i_csdev;
-
-       to_match = data;
-       i_csdev = to_coresight_device(dev);
-
-       if (to_match && !strcmp(to_match, dev_name(&i_csdev->dev)))
-               return 1;
-
-       return 0;
-}
-
 static void coresight_fixup_device_conns(struct coresight_device *csdev)
 {
        int i;
-       struct device *dev = NULL;
-       struct coresight_connection *conn;
 
        for (i = 0; i < csdev->nr_outport; i++) {
-               conn = &csdev->conns[i];
-               dev = bus_find_device(&coresight_bustype, NULL,
-                                     (void *)conn->child_name,
-                                     coresight_name_match);
+               struct coresight_connection *conn = &csdev->conns[i];
+               struct device *dev = NULL;
 
+               if (conn->child_name)
+                       dev = bus_find_device_by_name(&coresight_bustype, NULL,
+                                                     conn->child_name);
                if (dev) {
                        conn->child_dev = to_coresight_device(dev);
                        /* and put reference from 'bus_find_device()' */