From patchwork Sat Nov 25 10:51:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Wunner X-Patchwork-Id: 10074791 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0640160375 for ; Sat, 25 Nov 2017 10:59:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E35DE297FB for ; Sat, 25 Nov 2017 10:59:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5DEE29807; Sat, 25 Nov 2017 10:59:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6FB14297FB for ; Sat, 25 Nov 2017 10:59:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:To:Subject:Date: From:Message-Id:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=D7bzaHBIHPzQ7CsTVm3q4djDSUMmK0meuoYt17VOino=; b=dUR Q4q26otZYN6kOIVr6gdr3QQpDx4+TY1LCujkzzaaMMeCMqOEnWBhKe+vf6V0aNLeAX21OjRiJDESP sH+VH6ukAj9F99sUillxhE0BaMfJ0OhmD+Z9Li91Htt8pnez3zf8JgJGvk/t+NK8zB4bv+ZPCoeD8 0IQb45OoenchSdvgLLqc7+fU1jNUBfb1jMHtwwuJLEkF6vvL5OMycXZsoBhqgu7OnIymIN9u9HtFz yPezh7mOdLG6P8acUfZ6hgXT53rti62DHb0E0LesyE6DkXaXH1rdVjfwqQG4JJcZtgtrH6+/qo/Gd MYil/72gqpn2YLtFKsgdOTuUYhrn1bQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eIYBK-0003b8-5H; Sat, 25 Nov 2017 10:59:34 +0000 Received: from mailout2.hostsharing.net ([83.223.90.233]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eIYBG-0003ZW-9P for linux-arm-kernel@lists.infradead.org; Sat, 25 Nov 2017 10:59:32 +0000 Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (not verified)) by mailout2.hostsharing.net (Postfix) with ESMTPS id 627E410365B91; Sat, 25 Nov 2017 11:51:21 +0100 (CET) Received: from localhost (6-38-90-81.adsl.cmo.de [81.90.38.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by h08.hostsharing.net (Postfix) with ESMTPSA id 95DA7603E044; Sat, 25 Nov 2017 11:51:20 +0100 (CET) X-Mailbox-Line: From 7b21d96aaabc9ae20bda658bc1ed5b0981e3fc61 Mon Sep 17 00:00:00 2001 Message-Id: <7b21d96aaabc9ae20bda658bc1ed5b0981e3fc61.1511605972.git.lukas@wunner.de> From: Lukas Wunner Date: Sat, 25 Nov 2017 11:51:19 +0100 Subject: [PATCH] coresight: Deduplicate bus_find_device() by name matching To: Mathieu Poirier X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171125_025930_494790_C8631078 X-CRM114-Status: GOOD ( 10.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP No need to reinvent the wheel, we have bus_find_device_by_name(). Signed-off-by: Lukas Wunner --- 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()' */