All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] coresight: Deduplicate bus_find_device() by name matching
@ 2017-11-25 10:51 Lukas Wunner
  2017-11-27 20:37 ` Mathieu Poirier
  0 siblings, 1 reply; 2+ messages in thread
From: Lukas Wunner @ 2017-11-25 10:51 UTC (permalink / raw)
  To: linux-arm-kernel

No need to reinvent the wheel, we have bus_find_device_by_name().

Signed-off-by: Lukas Wunner <lukas@wunner.de>
---
 drivers/hwtracing/coresight/coresight.c | 25 +++++--------------------
 1 file changed, 5 insertions(+), 20 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
index b8091bef21dc..389c4baeca9d 100644
--- a/drivers/hwtracing/coresight/coresight.c
+++ b/drivers/hwtracing/coresight/coresight.c
@@ -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()' */
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] coresight: Deduplicate bus_find_device() by name matching
  2017-11-25 10:51 [PATCH] coresight: Deduplicate bus_find_device() by name matching Lukas Wunner
@ 2017-11-27 20:37 ` Mathieu Poirier
  0 siblings, 0 replies; 2+ messages in thread
From: Mathieu Poirier @ 2017-11-27 20:37 UTC (permalink / raw)
  To: linux-arm-kernel

On 25 November 2017 at 03:51, Lukas Wunner <lukas@wunner.de> wrote:
> No need to reinvent the wheel, we have bus_find_device_by_name().
>
> Signed-off-by: Lukas Wunner <lukas@wunner.de>

Applied - thanks.
Mathieu

> ---
>  drivers/hwtracing/coresight/coresight.c | 25 +++++--------------------
>  1 file changed, 5 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
> index b8091bef21dc..389c4baeca9d 100644
> --- a/drivers/hwtracing/coresight/coresight.c
> +++ b/drivers/hwtracing/coresight/coresight.c
> @@ -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()' */
> --
> 2.11.0
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-11-27 20:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-25 10:51 [PATCH] coresight: Deduplicate bus_find_device() by name matching Lukas Wunner
2017-11-27 20:37 ` Mathieu Poirier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.