From patchwork Fri Jun 14 17:53:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166876 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352411ilk; Fri, 14 Jun 2019 10:54:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwoZIzGohHqkb+N0MtNLk3+KPlnJjvfuRenKFDYW1UQoQuxVpoXQnR+JKEl2tramxta4Bnm X-Received: by 2002:a63:151a:: with SMTP id v26mr3147914pgl.9.1560534889827; Fri, 14 Jun 2019 10:54:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534889; cv=none; d=google.com; s=arc-20160816; b=B5QRD2/BTH+4wy9gqd/x9muJ/k23B/WYWDnV2ojmb1iQF08AB71G7zJURDzp5j4sGM BkgzEiQNiDtH4iSAYbVe0LWwE1emEaYqXRRPeL+gRHmsY94CtDdU3tumpz4ZAiApTK/I 1sjVUPvUOdm2uD296hIRhZT5v+0DB6xPlrLSjT+ng9zv2eKClGz0TWxIVEeo3Ds9cYEI jmh062CDAb2hOrcxWGkcXgM5bodQqhjp+placmPcACYzN65Rq5EdmtzVwolk+VmtNN2j w3CX29j46qIxTACGr/ksheCslVOjLZa1aeDK406nk1HctmVYgow7ghu35lvrRRQG2Kyl eb5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=cmiRNRL4Z8Sa8uProqN91EswVc8qrR81ADs3tz2KlmU=; b=aT+TVXKh9LXN4R/3SWdN6ZCqTzhWSH7edk2sG+uhb1LN1PzGXHPFFf2L4MNmFtioIg YvKV3GPjgxPsv08bqTH6t1pjo984u1L+GuHK8mcaUTQeib4D19by1Z6rbTcthZbw+cEf B0FW0Zz1MzXhPDLmZHLiiDTcpc1cPiv8T+2gaS5zacSqiXlbHDKt1oXAQm/W9KMidEJc w9oT6ybRAHb7/eMAgSEhXwts/QeHh1HMTjwnZGMG9uwr6tXUdydeZcNRg6a3hsc+G2pu S1jsRduIIQ+dYU4/ql8h1GlQXjSCHB/SQxND59bfCzu8BXkAlRNkQRg5gou/JgCXYdZr Fk/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s18si2804363plp.128.2019.06.14.10.54.49; Fri, 14 Jun 2019 10:54:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727066AbfFNRyq (ORCPT + 17 others); Fri, 14 Jun 2019 13:54:46 -0400 Received: from foss.arm.com ([217.140.110.172]:39234 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726693AbfFNRyp (ORCPT ); Fri, 14 Jun 2019 13:54:45 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F3577346; Fri, 14 Jun 2019 10:54:44 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id F05FA3F718; Fri, 14 Jun 2019 10:54:43 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Christian Gromm , "Gustavo A. R. Silva" , Colin Ian King Subject: [PATCH v2 01/28] staging: most-core: Use bus_find_device_by_name Date: Fri, 14 Jun 2019 18:53:56 +0100 Message-Id: <1560534863-15115-2-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use bus_find_device_by_name() helper instead of writing our own helper. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: Christian Gromm Cc: "Gustavo A. R. Silva" Cc: Colin Ian King Signed-off-by: Suzuki K Poulose --- Hi, This patch can be split from the series. But it will eventually conflict with the series. Hence included it here. --- drivers/staging/most/core.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) -- 2.7.4 diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c index 86a8545..b9841adb 100644 --- a/drivers/staging/most/core.c +++ b/drivers/staging/most/core.c @@ -561,13 +561,6 @@ static int split_string(char *buf, char **a, char **b, char **c, char **d) return 0; } -static int match_bus_dev(struct device *dev, void *data) -{ - char *mdev_name = data; - - return !strcmp(dev_name(dev), mdev_name); -} - /** * get_channel - get pointer to channel * @mdev: name of the device interface @@ -579,7 +572,7 @@ static struct most_channel *get_channel(char *mdev, char *mdev_ch) struct most_interface *iface; struct most_channel *c, *tmp; - dev = bus_find_device(&mc.bus, NULL, mdev, match_bus_dev); + dev = bus_find_device_by_name(&mc.bus, NULL, mdev); if (!dev) return NULL; iface = to_most_interface(dev); From patchwork Fri Jun 14 17:53:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166877 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352415ilk; Fri, 14 Jun 2019 10:54:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9X0zH0DHPWc7F7CqQH5Bhz02yhxtEkYrRaJIk48mUgDyfuOCuvGrUrA9vr5Ivaw/wOYth X-Received: by 2002:a17:902:f213:: with SMTP id gn19mr1857656plb.35.1560534890636; Fri, 14 Jun 2019 10:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534890; cv=none; d=google.com; s=arc-20160816; b=yV7Zx85YvvdGIpF3z5aEoIFm6N2f9O5w2eZgloIO5ioaa+glzgpVPBpU5WbT3HuqNS ERjdRCM3kbsLsSzMAkG9SKG2b/DfgZK/KTpWpe7RmHSA/G35hpAkzBy7oSMsItpedhmn eHGEJ0yzo6RDDqu6kQnT1qE0JqkeD9FHGoYn5mkxhP/pcv7e++7DjtC/IRkXnjRmRAHG 2Cn0LUUaGqHJ+0ZOdIWSpX06NhdjT4gyb/IHkcf442TK4pxG+ATbLe09VrWCm5ZWrlFu Z47GYVEF272pkXBuJ2C9DmUCcU9N8GYAaaCc9+zbhOPUj9CmFK+kxCd8n8hAuV2oSXy6 utCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=4saOm+Kbi/B+rHzWQeHPKy/tnExaYywZMNJR2pVUx+I=; b=na6NZy9mSJUjKMmUbwvillzOXvEdsUJ8faaXqiEzzmD9YIs+0dFOqylNJdx3KCHOIr u6op0X5FVveCYueP+hd1hSU0Mxd2qI00B1OIf1ThNpKUOQnaLJ0/IhDI9sgkGyHJxeJ/ 8ZMiszP4Oc3eJ4R96EHf1wxVrvxQaaSU+cfGpEHroeKUpTjpsU0f4jK03ft73daEhXQl to+yNXFrlg7DGsSpg1nuBryTsdruia27Qu6QQ8HA2KV1wM5BsDEWqIRSAo2hz/d+I4uj 3fV1wYmvuXXmwgLj/l72t4wnzsttURrFPyzhkVpMil7J0Mlv2CTpwsBtP9/872yFzTGx 5j8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s18si2804363plp.128.2019.06.14.10.54.50; Fri, 14 Jun 2019 10:54:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727196AbfFNRyr (ORCPT + 17 others); Fri, 14 Jun 2019 13:54:47 -0400 Received: from foss.arm.com ([217.140.110.172]:39252 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726693AbfFNRyq (ORCPT ); Fri, 14 Jun 2019 13:54:46 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F31D8367; Fri, 14 Jun 2019 10:54:45 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 324B93F718; Fri, 14 Jun 2019 10:54:45 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Arnd Bergman Subject: [PATCH v2 02/28] mfd: Remove unused helper syscon_regmap_lookup_by_pdevname Date: Fri, 14 Jun 2019 18:53:57 +0100 Message-Id: <1560534863-15115-3-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Nobody uses the exported helper syscon_regmap_lookup_by_pdevname, to lookup a device by name. Let us remove it. Suggested-by: Arnd Bergman Cc: Arnd Bergman Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- Hi, This patch again, could be separate from the series. However, it will conflict with the series during the merge. I have included it here before the actual series changes appear. Please do the necessary. --- drivers/mfd/syscon.c | 21 --------------------- include/linux/mfd/syscon.h | 6 ------ 2 files changed, 27 deletions(-) -- 2.7.4 diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c index 8ce1e41..b65e585 100644 --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c @@ -190,27 +190,6 @@ struct regmap *syscon_regmap_lookup_by_compatible(const char *s) } EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_compatible); -static int syscon_match_pdevname(struct device *dev, void *data) -{ - return !strcmp(dev_name(dev), (const char *)data); -} - -struct regmap *syscon_regmap_lookup_by_pdevname(const char *s) -{ - struct device *dev; - struct syscon *syscon; - - dev = driver_find_device(&syscon_driver.driver, NULL, (void *)s, - syscon_match_pdevname); - if (!dev) - return ERR_PTR(-EPROBE_DEFER); - - syscon = dev_get_drvdata(dev); - - return syscon->regmap; -} -EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_pdevname); - struct regmap *syscon_regmap_lookup_by_phandle(struct device_node *np, const char *property) { diff --git a/include/linux/mfd/syscon.h b/include/linux/mfd/syscon.h index f0273c9..8cfda05 100644 --- a/include/linux/mfd/syscon.h +++ b/include/linux/mfd/syscon.h @@ -19,7 +19,6 @@ struct device_node; #ifdef CONFIG_MFD_SYSCON extern struct regmap *syscon_node_to_regmap(struct device_node *np); extern struct regmap *syscon_regmap_lookup_by_compatible(const char *s); -extern struct regmap *syscon_regmap_lookup_by_pdevname(const char *s); extern struct regmap *syscon_regmap_lookup_by_phandle( struct device_node *np, const char *property); @@ -34,11 +33,6 @@ static inline struct regmap *syscon_regmap_lookup_by_compatible(const char *s) return ERR_PTR(-ENOTSUPP); } -static inline struct regmap *syscon_regmap_lookup_by_pdevname(const char *s) -{ - return ERR_PTR(-ENOTSUPP); -} - static inline struct regmap *syscon_regmap_lookup_by_phandle( struct device_node *np, const char *property) From patchwork Fri Jun 14 17:53:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166879 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352484ilk; Fri, 14 Jun 2019 10:54:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqywPvQ2rJ9lVFlSAKhBxhZ4ORjWrmbUSXLSQeYtlOlfypK1uPcDyIZtQQE5jjY/D2COikdZ X-Received: by 2002:a62:1ec3:: with SMTP id e186mr101255309pfe.197.1560534895465; Fri, 14 Jun 2019 10:54:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534895; cv=none; d=google.com; s=arc-20160816; b=aBkoRDoIocIoI96FiaLi9eXqetPfg0LXcvyC2c+tZmzoE5ERzQi92MqgGqI4hOa0lL gBbX4sITj5Ef2RDV3Kh/zsTMoHB7bO8pFCX+OchBk+njOCH1NAzXwvYd9hCp3NWf08sT Rad6ZlhvoMXLFVmI0KkvvRq3QRRgcS4FFaJxWddhNOE8dJqdAPABoZ+1rCUnp0b+7hFs vVKaVYFoyQeLsJTJSpadxppbCnavAYtREVKePzdaOqnHRBt78PHS4eFvDQCSR8NXEx25 ueAmfHmsgazi2ZYAr28lYhDewgyBfqZj6RGFswPPv2WJaeNhYXRfQA1bHvdW5QU7VXxc +yjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=umDZ9YiQPpc3QM2hYGwriK2qWieE+8FrXrDjd9HIb30=; b=X4yObKwURp6D6C7bwJ0Umtk+hvLu9Q8D7kXdtOdY+3dSRMDjT9C3jTomHyZ6BGZFqk 4AELMNg4MUgjx0tgCaZzkoNZnIEN/YxTluK6xfM7cuyR1i7kYht+02KbZobDBx7glvq2 igdJU7EB3TBHjwsneUhohueV+xWrvHJtUaPKz7MfNElNzZJISRpMV+3nyZoghWF75EoO YfUAc5DQ40A0gFFU+pceBImcpg2UlzdAoP+iUOBMDNoXJIhXI9+kNZ1pQMN1XTeFBEuk kh0QbodObCc/IkT3gM9dko6/Gwhe0dBj3tix+ilwbI8AHIs6igM3Eb3zmU3pQGx+P3+G 3PTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s18si2804363plp.128.2019.06.14.10.54.55; Fri, 14 Jun 2019 10:54:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727260AbfFNRyy (ORCPT + 17 others); Fri, 14 Jun 2019 13:54:54 -0400 Received: from foss.arm.com ([217.140.110.172]:39274 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727176AbfFNRyx (ORCPT ); Fri, 14 Jun 2019 13:54:53 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6A7183EF; Fri, 14 Jun 2019 10:54:51 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4F9683F718; Fri, 14 Jun 2019 10:54:47 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Alexander Shishkin , Andrew Lunn , Andreas Noever , Arnd Bergmann , Bjorn Helgaas , Corey Minyard , Christian Borntraeger , David Kershner , "David S. Miller" , David Airlie , Felipe Balbi , Frank Rowand , Grygorii Strashko , Harald Freudenberger , Hartmut Knaack , Heiko Stuebner , Jason Gunthorpe , Jonathan Cameron , "James E.J. Bottomley" , Len Brown , Mark Brown , Michael Ellerman , Michael Jamet , "Martin K. Petersen" , Peter Oberparleiter , Rob Herring , Sebastian Ott , Srinivas Kandagatla , Yehezkel Bernat , Wolfram Sang Subject: [PATCH v2 04/28] bus_find_device: Unify the match callback with class_find_device Date: Fri, 14 Jun 2019 18:53:59 +0100 Message-Id: <1560534863-15115-5-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is an arbitrary difference between the prototypes of bus_find_device() and class_find_device() preventing their callers from passing the same pair of data and match() arguments to both of them, which is the const qualifier used in the prototype of class_find_device(). If that qualifier is also used in the bus_find_device() prototype, it will be possible to pass the same match() callback function to both bus_find_device() and class_find_device(), which will allow some optimizations to be made in order to avoid code duplication going forward. Also with that, constify the "data" parameter as it is passed as a const to the match function. For this reason, change the prototype of bus_find_device() to match the prototype of class_find_device() and adjust its callers to use the const qualifier in accordance with the new prototype of it. Cc: Alexander Shishkin Cc: Andrew Lunn Cc: Andreas Noever Cc: Arnd Bergmann Cc: Bjorn Helgaas Cc: Corey Minyard Cc: Christian Borntraeger Cc: David Kershner Cc: "David S. Miller" Cc: David Airlie Cc: Felipe Balbi Cc: Frank Rowand Cc: Grygorii Strashko Cc: Harald Freudenberger Cc: Hartmut Knaack Cc: Heiko Stuebner Cc: Jason Gunthorpe Cc: Jonathan Cameron Cc: Jonathan Cameron Cc: "James E.J. Bottomley" Cc: Len Brown Cc: Mark Brown Cc: Michael Ellerman Cc: Michael Jamet Cc: "Martin K. Petersen" Cc: Peter Oberparleiter Cc: Rob Herring Cc: Sebastian Ott Cc: Srinivas Kandagatla Cc: Yehezkel Bernat Cc: Wolfram Sang Cc: rafael@kernel.org Cc: Greg Kroah-Hartman Acked-by: Corey Minyard Acked-by: David Kershner Acked-by: Mark Brown Acked-by: Rafael J. Wysocki Acked-by: Srinivas Kandagatla Signed-off-by: Suzuki K Poulose --- Changes since v1: - Removed staging/core and mfd/syscon changes as they have been dealt with in other ways. Otherwise remains unchanged - Fix warnings on s390 build --- arch/powerpc/platforms/pseries/ibmebus.c | 4 ++-- drivers/acpi/acpi_lpss.c | 4 ++-- drivers/acpi/sleep.c | 2 +- drivers/acpi/utils.c | 4 ++-- drivers/base/bus.c | 6 +++--- drivers/base/devcon.c | 2 +- drivers/char/ipmi/ipmi_si_platform.c | 2 +- drivers/firmware/efi/dev-path-parser.c | 4 ++-- drivers/gpu/drm/drm_mipi_dsi.c | 2 +- drivers/hwtracing/coresight/coresight.c | 6 +++--- drivers/hwtracing/coresight/of_coresight.c | 2 +- drivers/hwtracing/intel_th/core.c | 5 ++--- drivers/i2c/i2c-core-acpi.c | 4 ++-- drivers/i2c/i2c-core-of.c | 4 ++-- drivers/iio/inkern.c | 2 +- drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 2 +- drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 2 +- drivers/net/ethernet/ti/cpsw-phy-sel.c | 4 ++-- drivers/net/ethernet/ti/davinci_emac.c | 2 +- drivers/net/ethernet/toshiba/tc35815.c | 4 ++-- drivers/nvmem/core.c | 2 +- drivers/of/of_mdio.c | 2 +- drivers/of/platform.c | 2 +- drivers/pci/probe.c | 2 +- drivers/pci/search.c | 4 ++-- drivers/s390/cio/css.c | 4 ++-- drivers/s390/cio/device.c | 4 ++-- drivers/s390/cio/scm.c | 4 ++-- drivers/s390/crypto/ap_bus.c | 8 ++++---- drivers/scsi/scsi_proc.c | 2 +- drivers/spi/spi.c | 4 ++-- drivers/thunderbolt/switch.c | 4 ++-- drivers/usb/core/devio.c | 4 ++-- drivers/usb/core/usb.c | 4 ++-- drivers/usb/phy/phy-am335x-control.c | 4 ++-- drivers/usb/phy/phy-isp1301.c | 4 ++-- drivers/visorbus/visorbus_main.c | 4 ++-- include/linux/device.h | 4 ++-- sound/soc/rockchip/rk3399_gru_sound.c | 2 +- 39 files changed, 67 insertions(+), 68 deletions(-) -- 2.7.4 Acked-by: Rob Herring Acked-by: Wolfram Sang # for the I2C parts diff --git a/arch/powerpc/platforms/pseries/ibmebus.c b/arch/powerpc/platforms/pseries/ibmebus.c index 84e8ec4..b91eb09 100644 --- a/arch/powerpc/platforms/pseries/ibmebus.c +++ b/arch/powerpc/platforms/pseries/ibmebus.c @@ -147,13 +147,13 @@ static const struct dma_map_ops ibmebus_dma_ops = { .unmap_page = ibmebus_unmap_page, }; -static int ibmebus_match_path(struct device *dev, void *data) +static int ibmebus_match_path(struct device *dev, const void *data) { struct device_node *dn = to_platform_device(dev)->dev.of_node; return (of_find_node_by_path(data) == dn); } -static int ibmebus_match_node(struct device *dev, void *data) +static int ibmebus_match_node(struct device *dev, const void *data) { return to_platform_device(dev)->dev.of_node == data; } diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index cf76860..dc2ca78 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -511,10 +511,10 @@ struct hid_uid { const char *uid; }; -static int match_hid_uid(struct device *dev, void *data) +static int match_hid_uid(struct device *dev, const void *data) { struct acpi_device *adev = ACPI_COMPANION(dev); - struct hid_uid *id = data; + const struct hid_uid *id = data; if (!adev) return 0; diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 8ff08e5..cd11070 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c @@ -452,7 +452,7 @@ static int acpi_pm_prepare(void) return error; } -static int find_powerf_dev(struct device *dev, void *data) +static int find_powerf_dev(struct device *dev, const void *data) { struct acpi_device *device = to_acpi_device(dev); const char *hid = acpi_device_hid(device); diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 1391b63..e3974a8 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -730,10 +730,10 @@ struct acpi_dev_match_info { s64 hrv; }; -static int acpi_dev_match_cb(struct device *dev, void *data) +static int acpi_dev_match_cb(struct device *dev, const void *data) { struct acpi_device *adev = to_acpi_device(dev); - struct acpi_dev_match_info *match = data; + const struct acpi_dev_match_info *match = data; unsigned long long hrv; acpi_status status; diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 0a58e96..df3cac7 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -323,8 +323,8 @@ EXPORT_SYMBOL_GPL(bus_for_each_dev); * return to the caller and not iterate over any more devices. */ struct device *bus_find_device(struct bus_type *bus, - struct device *start, void *data, - int (*match)(struct device *dev, void *data)) + struct device *start, const void *data, + int (*match)(struct device *dev, const void *data)) { struct klist_iter i; struct device *dev; @@ -342,7 +342,7 @@ struct device *bus_find_device(struct bus_type *bus, } EXPORT_SYMBOL_GPL(bus_find_device); -static int match_name(struct device *dev, void *data) +static int match_name(struct device *dev, const void *data) { const char *name = data; diff --git a/drivers/base/devcon.c b/drivers/base/devcon.c index 04db9ae..ac026d5 100644 --- a/drivers/base/devcon.c +++ b/drivers/base/devcon.c @@ -107,7 +107,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; } diff --git a/drivers/char/ipmi/ipmi_si_platform.c b/drivers/char/ipmi/ipmi_si_platform.c index f2a91c4..fd94c42 100644 --- a/drivers/char/ipmi/ipmi_si_platform.c +++ b/drivers/char/ipmi/ipmi_si_platform.c @@ -426,7 +426,7 @@ static int ipmi_remove(struct platform_device *pdev) return ipmi_si_remove_by_dev(&pdev->dev); } -static int pdev_match_name(struct device *dev, void *data) +static int pdev_match_name(struct device *dev, const void *data) { struct platform_device *pdev = to_platform_device(dev); const char *name = data; diff --git a/drivers/firmware/efi/dev-path-parser.c b/drivers/firmware/efi/dev-path-parser.c index 85ec99f..2012338 100644 --- a/drivers/firmware/efi/dev-path-parser.c +++ b/drivers/firmware/efi/dev-path-parser.c @@ -17,9 +17,9 @@ struct acpi_hid_uid { char uid[11]; /* UINT_MAX + null byte */ }; -static int __init match_acpi_dev(struct device *dev, void *data) +static int __init match_acpi_dev(struct device *dev, const void *data) { - struct acpi_hid_uid hid_uid = *(struct acpi_hid_uid *)data; + struct acpi_hid_uid hid_uid = *(const struct acpi_hid_uid *)data; struct acpi_device *adev = to_acpi_device(dev); if (acpi_match_device_ids(adev, hid_uid.hid)) diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index 80b7550..ad19df0 100644 --- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c @@ -93,7 +93,7 @@ static struct bus_type mipi_dsi_bus_type = { .pm = &mipi_dsi_device_pm_ops, }; -static int of_device_match(struct device *dev, void *data) +static int of_device_match(struct device *dev, const void *data) { return dev->of_node == data; } diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 4b13028..b67ab6a 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -498,9 +498,9 @@ struct coresight_device *coresight_get_sink(struct list_head *path) return csdev; } -static int coresight_enabled_sink(struct device *dev, void *data) +static int coresight_enabled_sink(struct device *dev, const void *data) { - bool *reset = data; + const bool *reset = data; struct coresight_device *csdev = to_coresight_device(dev); if ((csdev->type == CORESIGHT_DEV_TYPE_SINK || @@ -544,7 +544,7 @@ struct coresight_device *coresight_get_enabled_sink(bool deactivate) return dev ? to_coresight_device(dev) : NULL; } -static int coresight_sink_by_id(struct device *dev, void *data) +static int coresight_sink_by_id(struct device *dev, const void *data) { struct coresight_device *csdev = to_coresight_device(dev); unsigned long hash; diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c index 7045930..3fc200e 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -18,7 +18,7 @@ #include -static int of_dev_node_match(struct device *dev, void *data) +static int of_dev_node_match(struct device *dev, const void *data) { return dev->of_node == data; } diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c index 033dce5..5592289 100644 --- a/drivers/hwtracing/intel_th/core.c +++ b/drivers/hwtracing/intel_th/core.c @@ -789,10 +789,9 @@ static int intel_th_populate(struct intel_th *th) return 0; } -static int match_devt(struct device *dev, void *data) +static int match_devt(struct device *dev, const void *data) { - dev_t devt = (dev_t)(unsigned long)data; - + dev_t devt = (dev_t)(unsigned long)(void *)data; return dev->devt == devt; } diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index d840955..8af35f11 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -318,7 +318,7 @@ u32 i2c_acpi_find_bus_speed(struct device *dev) } EXPORT_SYMBOL_GPL(i2c_acpi_find_bus_speed); -static int i2c_acpi_find_match_adapter(struct device *dev, void *data) +static int i2c_acpi_find_match_adapter(struct device *dev, const void *data) { struct i2c_adapter *adapter = i2c_verify_adapter(dev); @@ -328,7 +328,7 @@ static int i2c_acpi_find_match_adapter(struct device *dev, void *data) return ACPI_HANDLE(dev) == (acpi_handle)data; } -static int i2c_acpi_find_match_device(struct device *dev, void *data) +static int i2c_acpi_find_match_device(struct device *dev, const void *data) { return ACPI_COMPANION(dev) == data; } diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c index 406e5f6..2eb59a2 100644 --- a/drivers/i2c/i2c-core-of.c +++ b/drivers/i2c/i2c-core-of.c @@ -112,12 +112,12 @@ void of_i2c_register_devices(struct i2c_adapter *adap) of_node_put(bus); } -static int of_dev_node_match(struct device *dev, void *data) +static int of_dev_node_match(struct device *dev, const void *data) { return dev->of_node == data; } -static int of_dev_or_parent_node_match(struct device *dev, void *data) +static int of_dev_or_parent_node_match(struct device *dev, const void *data) { if (dev->of_node == data) return 1; diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 4a5eff3..c46fb59 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -93,7 +93,7 @@ static const struct iio_chan_spec #ifdef CONFIG_OF -static int iio_dev_node_match(struct device *dev, void *data) +static int iio_dev_node_match(struct device *dev, const void *data) { return dev->of_node == data && dev->type == &iio_device_type; } diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c index e068a02..3afd3e9 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c @@ -4498,7 +4498,7 @@ static const struct acpi_device_id hns_roce_acpi_match[] = { }; MODULE_DEVICE_TABLE(acpi, hns_roce_acpi_match); -static int hns_roce_node_match(struct device *dev, void *fwnode) +static int hns_roce_node_match(struct device *dev, const void *fwnode) { return dev->fwnode == fwnode; } diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c index 09c16d8..bb6586d 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c @@ -754,7 +754,7 @@ struct dsaf_misc_op *hns_misc_op_get(struct dsaf_device *dsaf_dev) return (void *)misc_op; } -static int hns_dsaf_dev_match(struct device *dev, void *fwnode) +static int hns_dsaf_dev_match(struct device *dev, const void *fwnode) { return dev->fwnode == fwnode; } diff --git a/drivers/net/ethernet/ti/cpsw-phy-sel.c b/drivers/net/ethernet/ti/cpsw-phy-sel.c index 48e0924..4e184ee 100644 --- a/drivers/net/ethernet/ti/cpsw-phy-sel.c +++ b/drivers/net/ethernet/ti/cpsw-phy-sel.c @@ -151,9 +151,9 @@ static void cpsw_gmii_sel_dra7xx(struct cpsw_phy_sel_priv *priv, } static struct platform_driver cpsw_phy_sel_driver; -static int match(struct device *dev, void *data) +static int match(struct device *dev, const void *data) { - struct device_node *node = (struct device_node *)data; + const struct device_node *node = (const struct device_node *)data; return dev->of_node == node && dev->driver == &cpsw_phy_sel_driver.driver; } diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index 4bf65ca..57d131a 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -1371,7 +1371,7 @@ static int emac_devioctl(struct net_device *ndev, struct ifreq *ifrq, int cmd) return -EOPNOTSUPP; } -static int match_first_device(struct device *dev, void *data) +static int match_first_device(struct device *dev, const void *data) { if (dev->parent && dev->parent->of_node) return of_device_is_compatible(dev->parent->of_node, diff --git a/drivers/net/ethernet/toshiba/tc35815.c b/drivers/net/ethernet/toshiba/tc35815.c index c50a977..8479a44 100644 --- a/drivers/net/ethernet/toshiba/tc35815.c +++ b/drivers/net/ethernet/toshiba/tc35815.c @@ -694,10 +694,10 @@ static int tc_mii_init(struct net_device *dev) * should provide a "tc35815-mac" device with a MAC address in its * platform_data. */ -static int tc35815_mac_match(struct device *dev, void *data) +static int tc35815_mac_match(struct device *dev, const void *data) { struct platform_device *plat_dev = to_platform_device(dev); - struct pci_dev *pci_dev = data; + const struct pci_dev *pci_dev = data; unsigned int id = pci_dev->irq; return !strcmp(plat_dev->name, "tc35815-mac") && plat_dev->id == id; } diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index c7892c3..ac5d945 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -76,7 +76,7 @@ static struct bus_type nvmem_bus_type = { .name = "nvmem", }; -static int of_nvmem_match(struct device *dev, void *nvmem_np) +static int of_nvmem_match(struct device *dev, const void *nvmem_np) { return dev->of_node == nvmem_np; } diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index 3b67896..44f5349 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c @@ -281,7 +281,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) EXPORT_SYMBOL(of_mdiobus_register); /* Helper function for of_phy_find_device */ -static int of_phy_match(struct device *dev, void *phy_np) +static int of_phy_match(struct device *dev, const void *phy_np) { return dev->of_node == phy_np; } diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 04ad312..008d79e 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -37,7 +37,7 @@ static const struct of_device_id of_skipped_node_table[] = { {} /* Empty terminated list */ }; -static int of_dev_node_match(struct device *dev, void *data) +static int of_dev_node_match(struct device *dev, const void *data) { return dev->of_node == data; } diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 0e8e2c1..f9ef7ad 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -64,7 +64,7 @@ static struct resource *get_pci_domain_busn_res(int domain_nr) return &r->res; } -static int find_anything(struct device *dev, void *data) +static int find_anything(struct device *dev, const void *data) { return 1; } diff --git a/drivers/pci/search.c b/drivers/pci/search.c index 5c79226..7f4e658 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c @@ -236,10 +236,10 @@ struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus, } EXPORT_SYMBOL(pci_get_domain_bus_and_slot); -static int match_pci_dev_by_id(struct device *dev, void *data) +static int match_pci_dev_by_id(struct device *dev, const void *data) { struct pci_dev *pdev = to_pci_dev(dev); - struct pci_device_id *id = data; + const struct pci_device_id *id = data; if (pci_match_one_device(id, pdev)) return 1; diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index aea5029..a2c9783 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c @@ -434,10 +434,10 @@ static int css_probe_device(struct subchannel_id schid, struct schib *schib) } static int -check_subchannel(struct device * dev, void * data) +check_subchannel(struct device *dev, const void *data) { struct subchannel *sch; - struct subchannel_id *schid = data; + struct subchannel_id *schid = (void *)data; sch = to_subchannel(dev); return schid_equal(&sch->schid, schid); diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index 1540229..d32f373 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c @@ -642,10 +642,10 @@ static int ccw_device_add(struct ccw_device *cdev) return device_add(dev); } -static int match_dev_id(struct device *dev, void *data) +static int match_dev_id(struct device *dev, const void *data) { struct ccw_device *cdev = to_ccwdev(dev); - struct ccw_dev_id *dev_id = data; + struct ccw_dev_id *dev_id = (void *)data; return ccw_dev_id_is_equal(&cdev->private->dev_id, dev_id); } diff --git a/drivers/s390/cio/scm.c b/drivers/s390/cio/scm.c index 6bca1d5..9f26d43 100644 --- a/drivers/s390/cio/scm.c +++ b/drivers/s390/cio/scm.c @@ -174,10 +174,10 @@ static void scmdev_update(struct scm_device *scmdev, struct sale *sale) kobject_uevent(&scmdev->dev.kobj, KOBJ_CHANGE); } -static int check_address(struct device *dev, void *data) +static int check_address(struct device *dev, const void *data) { struct scm_device *scmdev = to_scm_dev(dev); - struct sale *sale = data; + const struct sale *sale = data; return scmdev->address == sale->sa; } diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index b9fc502..b7902b6 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c @@ -1356,16 +1356,16 @@ static int ap_get_compatible_type(ap_qid_t qid, int rawtype, unsigned int func) * Helper function to be used with bus_find_dev * matches for the card device with the given id */ -static int __match_card_device_with_id(struct device *dev, void *data) +static int __match_card_device_with_id(struct device *dev, const void *data) { - return is_card_dev(dev) && to_ap_card(dev)->id == (int)(long) data; + return is_card_dev(dev) && to_ap_card(dev)->id == (int)(long)(void *) data; } /* * Helper function to be used with bus_find_dev * matches for the queue device with a given qid */ -static int __match_queue_device_with_qid(struct device *dev, void *data) +static int __match_queue_device_with_qid(struct device *dev, const void *data) { return is_queue_dev(dev) && to_ap_queue(dev)->qid == (int)(long) data; } @@ -1374,7 +1374,7 @@ static int __match_queue_device_with_qid(struct device *dev, void *data) * Helper function to be used with bus_find_dev * matches any queue device with given queue id */ -static int __match_queue_device_with_queue_id(struct device *dev, void *data) +static int __match_queue_device_with_queue_id(struct device *dev, const void *data) { return is_queue_dev(dev) && AP_QID_QUEUE(to_ap_queue(dev)->qid) == (int)(long) data; diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c index 7f0ceb6..c074631 100644 --- a/drivers/scsi/scsi_proc.c +++ b/drivers/scsi/scsi_proc.c @@ -372,7 +372,7 @@ static ssize_t proc_scsi_write(struct file *file, const char __user *buf, return err; } -static int always_match(struct device *dev, void *data) +static int always_match(struct device *dev, const void *data) { return 1; } diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 5e75944..3da1121 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -3538,7 +3538,7 @@ EXPORT_SYMBOL_GPL(spi_write_then_read); /*-------------------------------------------------------------------------*/ #if IS_ENABLED(CONFIG_OF) -static int __spi_of_device_match(struct device *dev, void *data) +static int __spi_of_device_match(struct device *dev, const void *data) { return dev->of_node == data; } @@ -3639,7 +3639,7 @@ static int spi_acpi_controller_match(struct device *dev, const void *data) return ACPI_COMPANION(dev->parent) == data; } -static int spi_acpi_device_match(struct device *dev, void *data) +static int spi_acpi_device_match(struct device *dev, const void *data) { return ACPI_COMPANION(dev) == data; } diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index c1b0165..c9a7e4a 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -1946,10 +1946,10 @@ struct tb_sw_lookup { u64 route; }; -static int tb_switch_match(struct device *dev, void *data) +static int tb_switch_match(struct device *dev, const void *data) { struct tb_switch *sw = tb_to_switch(dev); - struct tb_sw_lookup *lookup = data; + const struct tb_sw_lookup *lookup = data; if (!sw) return 0; diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index fa783531..7bd7de7 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -947,9 +947,9 @@ static int parse_usbdevfs_streams(struct usb_dev_state *ps, return ret; } -static int match_devt(struct device *dev, void *data) +static int match_devt(struct device *dev, const void *data) { - return dev->devt == (dev_t) (unsigned long) data; + return dev->devt == (dev_t)(unsigned long)(void *)data; } static struct usb_device *usbdev_lookup_by_devt(dev_t devt) diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 7fcb9f7..1678e30 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -325,9 +325,9 @@ struct find_interface_arg { struct device_driver *drv; }; -static int __find_interface(struct device *dev, void *data) +static int __find_interface(struct device *dev, const void *data) { - struct find_interface_arg *arg = data; + const struct find_interface_arg *arg = data; struct usb_interface *intf; if (!is_usb_interface(dev)) diff --git a/drivers/usb/phy/phy-am335x-control.c b/drivers/usb/phy/phy-am335x-control.c index a3cb25c..d16dfc3 100644 --- a/drivers/usb/phy/phy-am335x-control.c +++ b/drivers/usb/phy/phy-am335x-control.c @@ -118,9 +118,9 @@ static const struct of_device_id omap_control_usb_id_table[] = { MODULE_DEVICE_TABLE(of, omap_control_usb_id_table); static struct platform_driver am335x_control_driver; -static int match(struct device *dev, void *data) +static int match(struct device *dev, const void *data) { - struct device_node *node = (struct device_node *)data; + const struct device_node *node = (const struct device_node *)data; return dev->of_node == node && dev->driver == &am335x_control_driver.driver; } diff --git a/drivers/usb/phy/phy-isp1301.c b/drivers/usb/phy/phy-isp1301.c index 93b7d6a..6cf6fbd 100644 --- a/drivers/usb/phy/phy-isp1301.c +++ b/drivers/usb/phy/phy-isp1301.c @@ -142,9 +142,9 @@ static struct i2c_driver isp1301_driver = { module_i2c_driver(isp1301_driver); -static int match(struct device *dev, void *data) +static int match(struct device *dev, const void *data) { - struct device_node *node = (struct device_node *)data; + const struct device_node *node = (const struct device_node *)data; return (dev->of_node == node) && (dev->driver == &isp1301_driver.driver); } diff --git a/drivers/visorbus/visorbus_main.c b/drivers/visorbus/visorbus_main.c index 0b2434c..152fd29 100644 --- a/drivers/visorbus/visorbus_main.c +++ b/drivers/visorbus/visorbus_main.c @@ -171,10 +171,10 @@ struct visor_busdev { u32 dev_no; }; -static int match_visorbus_dev_by_id(struct device *dev, void *data) +static int match_visorbus_dev_by_id(struct device *dev, const void *data) { struct visor_device *vdev = to_visor_device(dev); - struct visor_busdev *id = data; + const struct visor_busdev *id = data; if (vdev->chipset_bus_no == id->bus_no && vdev->chipset_dev_no == id->dev_no) diff --git a/include/linux/device.h b/include/linux/device.h index e85264f..cbbdcadc 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -166,8 +166,8 @@ void subsys_dev_iter_exit(struct subsys_dev_iter *iter); int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, int (*fn)(struct device *dev, void *data)); struct device *bus_find_device(struct bus_type *bus, struct device *start, - void *data, - int (*match)(struct device *dev, void *data)); + const void *data, + int (*match)(struct device *dev, const void *data)); struct device *bus_find_device_by_name(struct bus_type *bus, struct device *start, const char *name); diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c index 3d0cc6e..c04c9ed 100644 --- a/sound/soc/rockchip/rk3399_gru_sound.c +++ b/sound/soc/rockchip/rk3399_gru_sound.c @@ -405,7 +405,7 @@ static const struct dailink_match_data dailink_match[] = { }, }; -static int of_dev_node_match(struct device *dev, void *data) +static int of_dev_node_match(struct device *dev, const void *data) { return dev->of_node == data; } From patchwork Fri Jun 14 17:54:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166880 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352502ilk; Fri, 14 Jun 2019 10:54:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyzwGIr0PQVCFJhz7nhgWkfMoog5LPwvzgq5LBJg2rAypIuCbubinz+qUznA3o8ex6IdFzA X-Received: by 2002:a17:90a:2430:: with SMTP id h45mr12775380pje.14.1560534896729; Fri, 14 Jun 2019 10:54:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534896; cv=none; d=google.com; s=arc-20160816; b=gCa2VRfNAlQRNB7gjk+q3R5o6o8HLiDc+sqJ0VH1bSAHj6abnKJsxKaauAR4xQfjNX XaK/QUKoLNWh7oGw1UKsZP7mjV78Y611UKInor/0oZ2QavNLDYJxfvD2bGf6/DOQB4S+ I/BwYTNvMvSBjOm1D13zxRg2ggVBPqui6UEpwI6bHZ5ox9AC+9Z0Eu9ddP+sjBnezfAs CaIFbloNSV3DVN06ifz7qaiUVsXMOWg2rP0q5GOsL3XQCh4+N7eEvOEwgvDmWGB8QT4I xVkfmzLkIRmMrNtUlwivcRFSgjkNdjXYDKZ1RhR5cL50uJWExrL1xrIP4gMGknCch1D5 FQNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=ZGJUZuEeuPVAxMas4NgipH5qPLy6byST44/MdDz5Mik=; b=0jpoGJyLOHttvl8K1UYVinJnt7TsvmFoSB8G6Ek4T6Nyl2OK1obnUi8PxrH2rpA4cc KHciOPYpfUvfcjFsqn0H/UA7WuyXnyho0PjX+YmcCxqoPeceTVk02UgwognU9mfvY/sl bsOP7RRQQYe+bhUvr7l+d2I8yo73odZYRkmbLLQrXTL27oN3mUFxsVR+XSGr9DM/CgMR EQKudx5N/k8MBevs2Vzib2cdK2DRB9qBR/xfKZ34rSrXHDt9PKor14X4glvsEl27HLTZ oKhJqBrqZaAFtimCn22Cqj/OcbqiJnyUk796GUpZDBr+pCqkQExm7fCv5dtxcsxExlw/ NXew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o61si2951523pld.392.2019.06.14.10.54.56; Fri, 14 Jun 2019 10:54:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727290AbfFNRyy (ORCPT + 17 others); Fri, 14 Jun 2019 13:54:54 -0400 Received: from foss.arm.com ([217.140.110.172]:39326 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727246AbfFNRyy (ORCPT ); Fri, 14 Jun 2019 13:54:54 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BA494CFC; Fri, 14 Jun 2019 10:54:53 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9DDE13F718; Fri, 14 Jun 2019 10:54:51 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Corey Minyard , Russell King , Thierry Reding , Will Deacon , Joerg Roedel , Peter Oberparleiter , Sebastian Ott , David Airlie , Daniel Vetter , Nehal Shah , Shyam Sundar S K , Lee Jones , Christian Borntraeger Subject: [PATCH v2 05/28] driver_find_device: Unify the match function with class_find_device() Date: Fri, 14 Jun 2019 18:54:00 +0100 Message-Id: <1560534863-15115-6-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The driver_find_device() accepts a match function pointer to filter the devices for lookup, similar to bus/class_find_device(). However, there is a minor difference in the prototype for the match parameter for driver_find_device() with the now unified version accepted by {bus/class}_find_device(), where it doesn't accept a "const" qualifier for the data argument. This prevents us from reusing the generic match functions for driver_find_device(). For this reason, change the prototype of the driver_find_device() to make the "match" parameter in line with {bus/class}_find_device() and adjust its callers to use the const qualifier. Also, we could now promote the "data" parameter to const as we pass it down as a const parameter to the match functions. Cc: Corey Minyard Cc: Russell King Cc: Thierry Reding Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: Will Deacon Cc: Joerg Roedel Cc: Peter Oberparleiter Cc: Sebastian Ott Cc: David Airlie Cc: Daniel Vetter Cc: Nehal Shah Cc: Shyam Sundar S K Cc: Lee Jones Cc: Christian Borntraeger Signed-off-by: Suzuki K Poulose --- drivers/amba/tegra-ahb.c | 4 ++-- drivers/base/driver.c | 4 ++-- drivers/char/ipmi/ipmi_msghandler.c | 8 ++++---- drivers/gpu/drm/tegra/dc.c | 4 ++-- drivers/i2c/busses/i2c-amd-mp2-pci.c | 2 +- drivers/iommu/arm-smmu-v3.c | 2 +- drivers/iommu/arm-smmu.c | 2 +- drivers/mfd/altera-sysmgr.c | 4 ++-- drivers/s390/cio/ccwgroup.c | 4 ++-- drivers/s390/cio/chsc_sch.c | 2 +- drivers/s390/cio/device.c | 2 +- include/linux/device.h | 4 ++-- 12 files changed, 21 insertions(+), 21 deletions(-) -- 2.7.4 diff --git a/drivers/amba/tegra-ahb.c b/drivers/amba/tegra-ahb.c index 3eaa459..aa64eec 100644 --- a/drivers/amba/tegra-ahb.c +++ b/drivers/amba/tegra-ahb.c @@ -134,10 +134,10 @@ static inline void gizmo_writel(struct tegra_ahb *ahb, u32 value, u32 offset) } #ifdef CONFIG_TEGRA_IOMMU_SMMU -static int tegra_ahb_match_by_smmu(struct device *dev, void *data) +static int tegra_ahb_match_by_smmu(struct device *dev, const void *data) { struct tegra_ahb *ahb = dev_get_drvdata(dev); - struct device_node *dn = data; + const struct device_node *dn = data; return (ahb->dev->of_node == dn) ? 1 : 0; } diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 857c8f1..4e5ca63 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -73,8 +73,8 @@ EXPORT_SYMBOL_GPL(driver_for_each_device); * return to the caller and not iterate over any more devices. */ struct device *driver_find_device(struct device_driver *drv, - struct device *start, void *data, - int (*match)(struct device *dev, void *data)) + struct device *start, const void *data, + int (*match)(struct device *dev, const void *data)) { struct klist_iter i; struct device *dev; diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 1dc1074..6707659 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -2819,9 +2819,9 @@ static const struct device_type bmc_device_type = { .groups = bmc_dev_attr_groups, }; -static int __find_bmc_guid(struct device *dev, void *data) +static int __find_bmc_guid(struct device *dev, const void *data) { - guid_t *guid = data; + const guid_t *guid = data; struct bmc_device *bmc; int rv; @@ -2857,9 +2857,9 @@ struct prod_dev_id { unsigned char device_id; }; -static int __find_bmc_prod_dev_id(struct device *dev, void *data) +static int __find_bmc_prod_dev_id(struct device *dev, const void *data) { - struct prod_dev_id *cid = data; + const struct prod_dev_id *cid = data; struct bmc_device *bmc; int rv; diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c index 607a6ea1..52109a6 100644 --- a/drivers/gpu/drm/tegra/dc.c +++ b/drivers/gpu/drm/tegra/dc.c @@ -2375,10 +2375,10 @@ static int tegra_dc_parse_dt(struct tegra_dc *dc) return 0; } -static int tegra_dc_match_by_pipe(struct device *dev, void *data) +static int tegra_dc_match_by_pipe(struct device *dev, const void *data) { struct tegra_dc *dc = dev_get_drvdata(dev); - unsigned int pipe = (unsigned long)data; + unsigned int pipe = (unsigned long)(void *)data; return dc->pipe == pipe; } diff --git a/drivers/i2c/busses/i2c-amd-mp2-pci.c b/drivers/i2c/busses/i2c-amd-mp2-pci.c index 455e1f3..c7fe3b4 100644 --- a/drivers/i2c/busses/i2c-amd-mp2-pci.c +++ b/drivers/i2c/busses/i2c-amd-mp2-pci.c @@ -457,7 +457,7 @@ static struct pci_driver amd_mp2_pci_driver = { }; module_pci_driver(amd_mp2_pci_driver); -static int amd_mp2_device_match(struct device *dev, void *data) +static int amd_mp2_device_match(struct device *dev, const void *data) { return 1; } diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 4d5a694..d787856 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -2023,7 +2023,7 @@ arm_smmu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova) static struct platform_driver arm_smmu_driver; -static int arm_smmu_match_node(struct device *dev, void *data) +static int arm_smmu_match_node(struct device *dev, const void *data) { return dev->fwnode == data; } diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 5aeb1db..3af579a 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1419,7 +1419,7 @@ static bool arm_smmu_capable(enum iommu_cap cap) } } -static int arm_smmu_match_node(struct device *dev, void *data) +static int arm_smmu_match_node(struct device *dev, const void *data) { return dev->fwnode == data; } diff --git a/drivers/mfd/altera-sysmgr.c b/drivers/mfd/altera-sysmgr.c index 8976f82..2ee14d8 100644 --- a/drivers/mfd/altera-sysmgr.c +++ b/drivers/mfd/altera-sysmgr.c @@ -92,9 +92,9 @@ static struct regmap_config altr_sysmgr_regmap_cfg = { * Matching function used by driver_find_device(). * Return: True if match is found, otherwise false. */ -static int sysmgr_match_phandle(struct device *dev, void *data) +static int sysmgr_match_phandle(struct device *dev, const void *data) { - return dev->of_node == (struct device_node *)data; + return dev->of_node == (const struct device_node *)data; } /** diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c index 4ebf6d4..ea176157 100644 --- a/drivers/s390/cio/ccwgroup.c +++ b/drivers/s390/cio/ccwgroup.c @@ -581,7 +581,7 @@ int ccwgroup_driver_register(struct ccwgroup_driver *cdriver) } EXPORT_SYMBOL(ccwgroup_driver_register); -static int __ccwgroup_match_all(struct device *dev, void *data) +static int __ccwgroup_match_all(struct device *dev, const void *data) { return 1; } @@ -608,7 +608,7 @@ void ccwgroup_driver_unregister(struct ccwgroup_driver *cdriver) } EXPORT_SYMBOL(ccwgroup_driver_unregister); -static int __ccwgroupdev_check_busid(struct device *dev, void *id) +static int __ccwgroupdev_check_busid(struct device *dev, const void *id) { char *bus_id = id; diff --git a/drivers/s390/cio/chsc_sch.c b/drivers/s390/cio/chsc_sch.c index 8d9f366..8f080d3 100644 --- a/drivers/s390/cio/chsc_sch.c +++ b/drivers/s390/cio/chsc_sch.c @@ -203,7 +203,7 @@ static void chsc_cleanup_sch_driver(void) static DEFINE_SPINLOCK(chsc_lock); -static int chsc_subchannel_match_next_free(struct device *dev, void *data) +static int chsc_subchannel_match_next_free(struct device *dev, const void *data) { struct subchannel *sch = to_subchannel(dev); diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index d32f373..f27536b 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c @@ -1653,7 +1653,7 @@ EXPORT_SYMBOL_GPL(ccw_device_force_console); * get ccw_device matching the busid, but only if owned by cdrv */ static int -__ccwdev_check_busid(struct device *dev, void *id) +__ccwdev_check_busid(struct device *dev, const void *id) { char *bus_id; diff --git a/include/linux/device.h b/include/linux/device.h index cbbdcadc..4d7c881 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -336,8 +336,8 @@ extern int __must_check driver_for_each_device(struct device_driver *drv, int (*fn)(struct device *dev, void *)); struct device *driver_find_device(struct device_driver *drv, - struct device *start, void *data, - int (*match)(struct device *dev, void *data)); + struct device *start, const void *data, + int (*match)(struct device *dev, const void *data)); void driver_deferred_probe_add(struct device *dev); int driver_deferred_probe_check_state(struct device *dev); From patchwork Fri Jun 14 17:54:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166881 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352584ilk; Fri, 14 Jun 2019 10:55:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZ4Ma1/vglgaSnCwQ7Hjkqg9ILeBn9q8WrgCaIQKoHWuu6/g5D3VDc8k0mzBRs0yGp1Ekv X-Received: by 2002:a63:1919:: with SMTP id z25mr37594416pgl.440.1560534901813; Fri, 14 Jun 2019 10:55:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534901; cv=none; d=google.com; s=arc-20160816; b=d63qx6eeKlM0wNAjMrMpuMIXq5TdwGCY/DHeXbUHiVJqWbL3lYY69bqWZoKHqJGeu5 yVi4SGc+O/P/ECjPluqaJ5jYrYNlpeA0qn+cdh4le/+SkvIMpHhLGizBf+R+nKSJvf+b V1VT1TVsZeVj5heH3lvT40mIN+VZGlz3BgfTd0Bmk83qeWDRV4kDcI7pnjo7qN8FWLXK RV9PNplwZ4EfRYgj9Dx+RCnTz5PN/Z3gqdDz+0ScVOtYN/KnBAK70T749qN8NOL1KJ4x EdvhT/BJV1vFbI4iFbCeMDTB/BDsRzJcpcJFSflRt+/xZNLgfyZ7vT6WIwHbrdL253mx 0vYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Pi188EItlRZ4O9JGvL8x5kEaGLgBtARxNQtM7nqr+z4=; b=X4Heoh4oGK36Q/ntC3wVWZQMqfPcysz+tnFiGqiIqYz1OuTm3LEnojA6JgDbao5fdD LjYYc1C9Egd/ZPkqU5sxcFP36dgrWAl0krtxaXS4zM8JnvOkLSDs9XlgD5Qgntzkch+K J64xQRm1/BLAKyfWuVOeKKc0N2eJ3hgSRpPieTQNx+y8HmAI8aBgmx0NZDUnFtURV0+Z SWAVtrIlYJ2t3+vBHJtqK0YVP9pNuxbToJtsYEIE+IYM/b3DlxFPsFq07Fni0Q7xihYh jHk+/mpRTVawwlleQMbjvVFGQBYMAobgCwZB9qP+gqnJwyjqCpcGAc9y2xK0uNXtgLV7 6Tsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t14si3268706pgc.90.2019.06.14.10.55.01; Fri, 14 Jun 2019 10:55:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727405AbfFNRy7 (ORCPT + 17 others); Fri, 14 Jun 2019 13:54:59 -0400 Received: from foss.arm.com ([217.140.110.172]:39354 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726837AbfFNRy7 (ORCPT ); Fri, 14 Jun 2019 13:54:59 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EEF05346; Fri, 14 Jun 2019 10:54:57 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EF5FE3F718; Fri, 14 Jun 2019 10:54:53 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Alan Tull , Andrew Lunn , Daniel Vetter , David Airlie , "David S. Miller" , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, Florian Fainelli , Frank Rowand , Heiner Kallweit , Jiri Slaby , Jonathan Hunter , Lee Jones , Liam Girdwood , linux-fpga@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, Maarten Lankhorst , Mark Brown , Mathieu Poirier , Maxime Ripard , Moritz Fischer , Peter Rosin , Rob Herring , Srinivas Kandagatla , Thierry Reding , Thor Thayer , Wolfram Sang , Ulf Hansson , Joe Perches Subject: [PATCH v2 06/28] drivers: Add generic helper to match by of_node Date: Fri, 14 Jun 2019 18:54:01 +0100 Message-Id: <1560534863-15115-7-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a helper to match device by the of_node. This will be later used to provide wrappers to the device iterators for {bus/class/driver}_find_device(). Convert other users to reuse this new helper. Cc: Alan Tull Cc: Andrew Lunn Cc: Daniel Vetter Cc: David Airlie Cc: "David S. Miller" Cc: devicetree@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: Florian Fainelli Cc: Frank Rowand Cc: Greg Kroah-Hartman Cc: Heiner Kallweit Cc: Jiri Slaby Cc: Jonathan Hunter Cc: Lee Jones Cc: Liam Girdwood Cc: linux-fpga@vger.kernel.org Cc: linux-i2c@vger.kernel.org Cc: linux-spi@vger.kernel.org Cc: Maarten Lankhorst Cc: Mark Brown Cc: Mathieu Poirier Cc: Maxime Ripard Cc: Moritz Fischer Cc: Peter Rosin Cc: Rob Herring Cc: Srinivas Kandagatla Cc: Thierry Reding Cc: Thor Thayer Cc: Wolfram Sang Cc: "Rafael J. Wysocki" Cc: Greg Kroah-Hartman Cc: Ulf Hansson Cc: Joe Perches Signed-off-by: Suzuki K Poulose --- drivers/base/core.c | 6 ++++++ drivers/fpga/of-fpga-region.c | 7 +------ include/linux/device.h | 2 ++ 3 files changed, 9 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/drivers/base/core.c b/drivers/base/core.c index fd7511e..9211908 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3328,3 +3328,9 @@ void device_set_of_node_from_dev(struct device *dev, const struct device *dev2) dev->of_node_reused = true; } EXPORT_SYMBOL_GPL(device_set_of_node_from_dev); + +int device_match_of_node(struct device *dev, const void *np) +{ + return dev->of_node == np; +} +EXPORT_SYMBOL_GPL(device_match_of_node); diff --git a/drivers/fpga/of-fpga-region.c b/drivers/fpga/of-fpga-region.c index 75f64ab..e405309 100644 --- a/drivers/fpga/of-fpga-region.c +++ b/drivers/fpga/of-fpga-region.c @@ -22,11 +22,6 @@ static const struct of_device_id fpga_region_of_match[] = { }; MODULE_DEVICE_TABLE(of, fpga_region_of_match); -static int fpga_region_of_node_match(struct device *dev, const void *data) -{ - return dev->of_node == data; -} - /** * of_fpga_region_find - find FPGA region * @np: device node of FPGA Region @@ -37,7 +32,7 @@ static int fpga_region_of_node_match(struct device *dev, const void *data) */ static struct fpga_region *of_fpga_region_find(struct device_node *np) { - return fpga_region_class_find(NULL, np, fpga_region_of_node_match); + return fpga_region_class_find(NULL, np, device_match_of_node); } /** diff --git a/include/linux/device.h b/include/linux/device.h index 4d7c881..7093085 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -163,6 +163,8 @@ void subsys_dev_iter_init(struct subsys_dev_iter *iter, struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter); void subsys_dev_iter_exit(struct subsys_dev_iter *iter); +int device_match_of_node(struct device *dev, const void *np); + int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, int (*fn)(struct device *dev, void *data)); struct device *bus_find_device(struct bus_type *bus, struct device *start, From patchwork Fri Jun 14 17:54:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166882 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352594ilk; Fri, 14 Jun 2019 10:55:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwatFLkgXmgZgCPGVpaxpgVnb4nlrB666HTjtlu5Nx6QgGrDClxgThY5iEJZADzS8YmDp7F X-Received: by 2002:a62:3605:: with SMTP id d5mr101073903pfa.28.1560534902731; Fri, 14 Jun 2019 10:55:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534902; cv=none; d=google.com; s=arc-20160816; b=bP6Odb3mccIlLtRmJwNykODQa4aA2vANDAxnwYcPO/LLlWkq2CLSLSEmX/eQwMCM7P LVI+5hnvCeWrzELTZsmq3upidwFZwrGo7WQ/GPGujjDDa31oa7cirjkXPrcv6O6wfvc5 KO2/Mi3M26P+zLWrl9HugMU6UTtHT1Si4R2y6U3f3flXpEUxY1cxDlRbvJCfsWnj8zgX Z6yFyDjE3fGB3JkBapFx+VyJVThPcxnCgzgL8roesjK7veSm+AR2jbKZV/WTAXZHS7wc 9GlI716TJYLOPo9woopadqTBaUGv7RnJyNaaBrJfeQLT0ss0ln4F2GO2haxBuckJCK0C u7JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=VStcCyo7cIBzRVdAFDdZh5mn68wGtntaR0HYCc/TaqA=; b=t3tK67DYSAapSsRm6h88HcFz0lytG2RG7/G6ewpAZYBz8dsWhEdu96O5P21s0SSqXt saKlHTREzUzqLd0zJaUfoewS/5f3Mz/yzXsckk2cM9ZWfzRl3iy13rNt0GzKXy/4++gE e1C9uM+Ed9zRDR9RGn+EjHsET+nAQmlcdlr34Fn6jBfaMY8Kp6wMbyWW79RyQLhN045Y tuI2VbSNFjZFXrZDinvfsmbdcXUHHOpBCmK4aZ1sNJCqnUnNjNDoUYQq1Mw2JXQRu4og GdtGGFy/8blc0S7HoXplK7t8ammJlM3DbQm+gD7ukQULs9gaMSTS38WmEZ3zIrtaQ0oc jcPQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t14si3268706pgc.90.2019.06.14.10.55.02; Fri, 14 Jun 2019 10:55:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727426AbfFNRzA (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:00 -0400 Received: from foss.arm.com ([217.140.110.172]:39392 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727397AbfFNRzA (ORCPT ); Fri, 14 Jun 2019 13:55:00 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9CA5C367; Fri, 14 Jun 2019 10:54:59 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2DFC23F718; Fri, 14 Jun 2019 10:54:58 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, "David S. Miller" , Doug Ledford , Heikki Krogerus , Jason Gunthorpe , linux-usb@vger.kernel.org, Ulf Hansson , Joe Perches Subject: [PATCH v2 07/28] drivers: Add generic helper to match by fwnode Date: Fri, 14 Jun 2019 18:54:02 +0100 Message-Id: <1560534863-15115-8-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a helper to match the firmware node handle of a device. This will be used later for generic look up by fwnode helpers for bus/class/driver. Cc: "David S. Miller" Cc: Doug Ledford Cc: Greg Kroah-Hartman Cc: Heikki Krogerus Cc: Jason Gunthorpe Cc: linux-usb@vger.kernel.org Cc: "Rafael J. Wysocki" Cc: Greg Kroah-Hartman Cc: Ulf Hansson Cc: Joe Perches Signed-off-by: Suzuki K Poulose --- drivers/base/core.c | 6 ++++++ include/linux/device.h | 1 + 2 files changed, 7 insertions(+) -- 2.7.4 diff --git a/drivers/base/core.c b/drivers/base/core.c index 9211908..efcdb96 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3334,3 +3334,9 @@ int device_match_of_node(struct device *dev, const void *np) return dev->of_node == np; } EXPORT_SYMBOL_GPL(device_match_of_node); + +int device_match_fwnode(struct device *dev, const void *fwnode) +{ + return dev_fwnode(dev) == fwnode; +} +EXPORT_SYMBOL_GPL(device_match_fwnode); diff --git a/include/linux/device.h b/include/linux/device.h index 7093085..08aa087 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -164,6 +164,7 @@ struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter); void subsys_dev_iter_exit(struct subsys_dev_iter *iter); int device_match_of_node(struct device *dev, const void *np); +int device_match_fwnode(struct device *dev, const void *fwnode); int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, int (*fn)(struct device *dev, void *data)); From patchwork Fri Jun 14 17:54:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166883 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352627ilk; Fri, 14 Jun 2019 10:55:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqxoZEs5uEBH4RYcPDP94bjl5w4qcW2YjEVs9ZI6wdGVJl+qA0FuyiI6DrSGFlFn0Z2cjR4g X-Received: by 2002:a17:90a:8c18:: with SMTP id a24mr11962102pjo.111.1560534905019; Fri, 14 Jun 2019 10:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534905; cv=none; d=google.com; s=arc-20160816; b=uiyg0ZB5CLo3fELZIkjBpdiTgYJdk+AnLGC9qWdezq4JEqBra639/ys0OGGRKp1Fqc ZqwnJX2FZJ60HoY/oM2o6iyiqrErBDXP5B5OAK2A7Kfva2Hg5FI81vFmK/7ArOEIKhdR X7snQ9PMSjvKFyQCRc1qRqgHyNvcsED6I2GtVlsUTIHnHdAqebUyzGp1m4xiiBS2zADt RpF07J6MI1HQaDHPtG5qd5Vy28K6Ks78wrm7Dm48I4pybYD9JQ9D29UmUq+knpQQm4K1 veurF3/WXRvETYW+U0WjMSZDWrAVlgknWE63rAefHFCHKMQY1IAaeQr+KQxYo412pAuR rvLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=HHSek7wbTNGzrDs5ANHcDOTs5rK//1HpoCrWGwl4XZU=; b=OSrPa8SDPx/kgOE2qh0JOQgmKUIs4n8ZkX2lCC6A+zqFH1yln3XG4l0pc6ZKc7uCNT 1LA/RL90o3zgNnN8MWJT5OOq8RW9BlPuJO6VrjEi5xNbgR7zuZ+qva5JK9xVVIGJx+ug 7jzDd2Cg52HUh4KYg6yM9d4FH9x8kxkVbYgf3ZeDiqpIZqb3zh/bOiVvLfv0eovmq8zY wSHnkfcNcsfYqmt7hLGIqvDzx3bVb4FmIk/4sTXTWRtyY74UAEBhvb3NPCWXkIy87rYj IpfTu0+ph/YVa5M/RBR20yHZy/F1DwjaTLkHW/Dk98CIYXaVo97byCW+NfCc8ubpxFfH 6KVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11si2767868plg.136.2019.06.14.10.55.04; Fri, 14 Jun 2019 10:55:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727441AbfFNRzD (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:03 -0400 Received: from foss.arm.com ([217.140.110.172]:39414 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727397AbfFNRzC (ORCPT ); Fri, 14 Jun 2019 13:55:02 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9ED5DCFC; Fri, 14 Jun 2019 10:55:01 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D092E3F718; Fri, 14 Jun 2019 10:54:59 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Alexander Shishkin , Arnd Bergmann , Harald Freudenberger , Heiko Carstens , linux-usb@vger.kernel.org, Oliver Neukum , Sebastian Andrzej Siewior , Tomas Winkler , Ulf Hansson , Joe Perches Subject: [PATCH v2 08/28] drivers: Add generic helper to match by device type Date: Fri, 14 Jun 2019 18:54:03 +0100 Message-Id: <1560534863-15115-9-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a helper to match a device by its type. This will be used later for providing wrappers to the device iterators for bus/class/driver. Cc: Alexander Shishkin Cc: Arnd Bergmann Cc: Harald Freudenberger Cc: Heiko Carstens Cc: linux-usb@vger.kernel.org Cc: Oliver Neukum Cc: Sebastian Andrzej Siewior Cc: Tomas Winkler Cc: "Rafael J. Wysocki" Cc: Greg Kroah-Hartman Cc: Ulf Hansson Cc: Joe Perches Signed-off-by: Suzuki K Poulose --- drivers/base/core.c | 6 ++++++ include/linux/device.h | 1 + 2 files changed, 7 insertions(+) -- 2.7.4 diff --git a/drivers/base/core.c b/drivers/base/core.c index efcdb96..b827ca1 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3340,3 +3340,9 @@ int device_match_fwnode(struct device *dev, const void *fwnode) return dev_fwnode(dev) == fwnode; } EXPORT_SYMBOL_GPL(device_match_fwnode); + +int device_match_devt(struct device *dev, const void *pdevt) +{ + return dev->devt == *(dev_t *)pdevt; +} +EXPORT_SYMBOL_GPL(device_match_devt); diff --git a/include/linux/device.h b/include/linux/device.h index 08aa087..f315692 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -165,6 +165,7 @@ void subsys_dev_iter_exit(struct subsys_dev_iter *iter); int device_match_of_node(struct device *dev, const void *np); int device_match_fwnode(struct device *dev, const void *fwnode); +int device_match_devt(struct device *dev, const void *pdevt); int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, int (*fn)(struct device *dev, void *data)); From patchwork Fri Jun 14 17:54:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166884 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352655ilk; Fri, 14 Jun 2019 10:55:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0qKH9JmBqaO5MPyX0pVnoDhschMKLSuJm0cWbj1OeQbatKaWaDpo3bqafVkIo1V+nwn/c X-Received: by 2002:a17:90a:2561:: with SMTP id j88mr12408078pje.121.1560534906968; Fri, 14 Jun 2019 10:55:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534906; cv=none; d=google.com; s=arc-20160816; b=xhSS/69pn+FVU80hf8vr85o+oDyO7U9EJoI+gRYXw2pXfxkpRlcG8BS+tSxHwYlus3 DWXT0skX/CKxD32j21CDuPAOPLYW8fII3RS8BICUUs0liOWw7U9LTMPeyywoMdCDzmjK 17yAZ0Hsl2wKTINKY4wfl4skajI+dWEgN3hXCqlyrWILy2dIXxcMfgaPxCx9ZvvDoZpG /8svkvgVzCFxO9j+6CcltC4s6ttQqSFqjYd2mAua3k+RZkPpj6GNxMT4bHwdGZpctmtg 5+VyKhACoi4juUaRnaHsvk7V7oygyW/Ca+0ojTN2Ila53EaBbx/++fF0I8Yv0+POsBQa xrag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=CeJAGbwwBA7CtijUMYZbDd70ASAVRCcKIyjMRHAK3os=; b=Hfc91Ssn19BJIqBi3eND7uS7WchKnDQgwL5JDXS2fgF7elwX4jCa/Y+wd9wmql3qc9 +SpZ8HVMBpAx3jBU0KWAjJyzKRg8H++n65ufFB56B0X3ySXlZtKTvkGUnpsuswGBLUsB 1zgIr7IOStp5M1D/oCfnbK/yL/eLeo+SCyWT/eVXOjLA5xfeiA14gx0pyeJqkdmzsnd9 pfG2m5WRiMSBk3o8RRweX0tsYC3jMKp6LTn3gEjr9MzCuVBBL9S5BvBkjUvi+WySddhY Kb4/MPbPk489/E0tWWjXDXQBjCG2p/0txWRNoSap9GYwGEhorrEcHOvqCjPFZIbaSyGj JAHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11si2767868plg.136.2019.06.14.10.55.06; Fri, 14 Jun 2019 10:55:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727453AbfFNRzF (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:05 -0400 Received: from foss.arm.com ([217.140.110.172]:39438 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727434AbfFNRzD (ORCPT ); Fri, 14 Jun 2019 13:55:03 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EFBB9346; Fri, 14 Jun 2019 10:55:02 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D20023F718; Fri, 14 Jun 2019 10:55:01 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Len Brown , linux-acpi@vger.kernel.org, linux-spi@vger.kernel.org, Mark Brown Subject: [PATCH v2 09/28] drivers: Add generic match helper by ACPI_COMPANION device Date: Fri, 14 Jun 2019 18:54:04 +0100 Message-Id: <1560534863-15115-10-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a generic helper to match a device by the ACPI_COMPANION device. This will be later used for providing wrappers for (bus/class/driver)_find_device(). Cc: Len Brown Cc: linux-acpi@vger.kernel.org Cc: linux-spi@vger.kernel.org Cc: Mark Brown Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- drivers/base/core.c | 6 ++++++ include/linux/device.h | 1 + 2 files changed, 7 insertions(+) -- 2.7.4 diff --git a/drivers/base/core.c b/drivers/base/core.c index b827ca1..597095b 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3346,3 +3346,9 @@ int device_match_devt(struct device *dev, const void *pdevt) return dev->devt == *(dev_t *)pdevt; } EXPORT_SYMBOL_GPL(device_match_devt); + +int device_match_acpi_dev(struct device *dev, const void *adev) +{ + return ACPI_COMPANION(dev) == adev; +} +EXPORT_SYMBOL(device_match_acpi_dev); diff --git a/include/linux/device.h b/include/linux/device.h index f315692..a03b50d 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -166,6 +166,7 @@ void subsys_dev_iter_exit(struct subsys_dev_iter *iter); int device_match_of_node(struct device *dev, const void *np); int device_match_fwnode(struct device *dev, const void *fwnode); int device_match_devt(struct device *dev, const void *pdevt); +int device_match_acpi_dev(struct device *dev, const void *adev); int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, int (*fn)(struct device *dev, void *data)); From patchwork Fri Jun 14 17:54:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166885 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352694ilk; Fri, 14 Jun 2019 10:55:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPwRnCrGljQZvvvIASqqXOeM1Yui5bUeWwdZyNJz40oNgVfLS1QIlblANUB01JZEtgfOWe X-Received: by 2002:a63:e54d:: with SMTP id z13mr36778176pgj.132.1560534909756; Fri, 14 Jun 2019 10:55:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534909; cv=none; d=google.com; s=arc-20160816; b=Gj6WsSgxG+fR/6iZ5VmZG36wjev52Np4+aavjp7BO8MwQv8Faxsu7ZQ8ENAijlp6G1 QjhCTqgRi59vb1VBq+n87DvHMcabrJmcEwKCXENKy/pcclOIpv2JJBRB2s7/b5LEQlKN xA9+6XIlTGZFiHdE1oDSl4MjfbOSQpDgVxsvxUMBYLKmeojA1RRNtbU2+463T6DjSnSB 44MpaIFWM91C0qZSz7wG0jBiwjuqJ5H7xlW427YcAipyN8ZnV+8QyfovmkrdILaxWGt4 r2b7msCtYQDiZ8vJgkSCLpVwUUu8lO3T3qR6N1RFzZIMuJ0knJuT9irbEm8wzlMuICP2 pDjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=zWrn72NEPIaq9uHfMY9JsitT/U6NIhl9BpjU4fepj+8=; b=azVJFew7SFyionTGXkEZRhdqFfSIj/KkS+IQqpJMqVXgFPLJzEnn1XIkxoLH4wq34b a0nkPyKywTf7XJTImoQcevT7k49LNI3bRpFumwcXIOPcbTvZnO2LtfWNyGbMDC7T67Fq xncqRYi7WB6xgp/gplXMSa7i2C0l9X5BEXSSrCxl9VFJyYrCCC9PQPG9FdlwxLpo4rFT izICUqDdGHYNSlZ5p+UT3uUDLdSZdEY+d5w2Btqtl1J3RM0ELrBBoJw7kYOvCcy8sbdD 6ZkkPgVeqptULQD37mJWBUROgXRw0hkGpYeAOI9zqOEeNA73qFoSX84iiImxpSZ6bw67 vcZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a20si3109760pgw.306.2019.06.14.10.55.09; Fri, 14 Jun 2019 10:55:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727487AbfFNRzI (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:08 -0400 Received: from foss.arm.com ([217.140.110.172]:39448 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727434AbfFNRzH (ORCPT ); Fri, 14 Jun 2019 13:55:07 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3123E346; Fri, 14 Jun 2019 10:55:06 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 302813F718; Fri, 14 Jun 2019 10:55:03 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Alessandro Zummo , Alexander Aring , Alexander Shishkin , Alexandre Belloni , Arnd Bergmann , Dan Murphy , Harald Freudenberger , Heikki Krogerus , Heiko Carstens , Jacek Anaszewski , Lee Jones , linux-leds@vger.kernel.org, linux-rtc@vger.kernel.org, linux-usb@vger.kernel.org, linux-wpan@vger.kernel.org, Martin Schwidefsky , Maxime Coquelin , Pavel Machek , Peter Oberparleiter , Stefan Schmidt , "Rafael J. Wysocki" Subject: [PATCH v2 10/28] drivers: Add generic helper to match by name Date: Fri, 14 Jun 2019 18:54:05 +0100 Message-Id: <1560534863-15115-11-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a helper to match the device name. Also reuse this generic exported helper for bus_find_device_by_name(). This will also be used to add similar interface for (driver/class)_find_device() Cc: Alessandro Zummo Cc: Alexander Aring Cc: Alexander Shishkin Cc: Alexandre Belloni Cc: Arnd Bergmann Cc: Dan Murphy Cc: Greg Kroah-Hartman Cc: Harald Freudenberger Cc: Heikki Krogerus Cc: Heiko Carstens Cc: Jacek Anaszewski Cc: Lee Jones Cc: linux-leds@vger.kernel.org Cc: linux-rtc@vger.kernel.org Cc: linux-usb@vger.kernel.org Cc: linux-wpan@vger.kernel.org Cc: Martin Schwidefsky Cc: Maxime Coquelin Cc: Pavel Machek Cc: Peter Oberparleiter Cc: "Rafael J. Wysocki" Cc: Stefan Schmidt Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- drivers/base/bus.c | 24 ------------------------ drivers/base/core.c | 6 ++++++ include/linux/device.h | 18 +++++++++++++++--- 3 files changed, 21 insertions(+), 27 deletions(-) -- 2.7.4 diff --git a/drivers/base/bus.c b/drivers/base/bus.c index df3cac7..a1d1e82 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -342,30 +342,6 @@ struct device *bus_find_device(struct bus_type *bus, } EXPORT_SYMBOL_GPL(bus_find_device); -static int match_name(struct device *dev, const void *data) -{ - const char *name = data; - - return sysfs_streq(name, dev_name(dev)); -} - -/** - * bus_find_device_by_name - device iterator for locating a particular device of a specific name - * @bus: bus type - * @start: Device to begin with - * @name: name of the device to match - * - * This is similar to the bus_find_device() function above, but it handles - * searching by a name automatically, no need to write another strcmp matching - * function. - */ -struct device *bus_find_device_by_name(struct bus_type *bus, - struct device *start, const char *name) -{ - return bus_find_device(bus, start, (void *)name, match_name); -} -EXPORT_SYMBOL_GPL(bus_find_device_by_name); - /** * subsys_find_device_by_id - find a device with a specific enumeration number * @subsys: subsystem diff --git a/drivers/base/core.c b/drivers/base/core.c index 597095b..5724f93 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3352,3 +3352,9 @@ int device_match_acpi_dev(struct device *dev, const void *adev) return ACPI_COMPANION(dev) == adev; } EXPORT_SYMBOL(device_match_acpi_dev); + +int device_match_name(struct device *dev, const void *name) +{ + return sysfs_streq(dev_name(dev), name); +} +EXPORT_SYMBOL_GPL(device_match_name); diff --git a/include/linux/device.h b/include/linux/device.h index a03b50d..b9b82b7 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -167,15 +167,27 @@ int device_match_of_node(struct device *dev, const void *np); int device_match_fwnode(struct device *dev, const void *fwnode); int device_match_devt(struct device *dev, const void *pdevt); int device_match_acpi_dev(struct device *dev, const void *adev); +int device_match_name(struct device *dev, const void *name); int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, int (*fn)(struct device *dev, void *data)); struct device *bus_find_device(struct bus_type *bus, struct device *start, const void *data, int (*match)(struct device *dev, const void *data)); -struct device *bus_find_device_by_name(struct bus_type *bus, - struct device *start, - const char *name); +/** + * bus_find_device_by_name - device iterator for locating a particular device + * of a specific name. + * @bus: bus type + * @start: Device to begin with + * @name: name of the device to match + */ +static inline struct device *bus_find_device_by_name(struct bus_type *bus, + struct device *start, + const char *name) +{ + return bus_find_device(bus, start, name, device_match_name); +} + struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id, struct device *hint); int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, From patchwork Fri Jun 14 17:54:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166886 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352730ilk; Fri, 14 Jun 2019 10:55:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqwbqQ3ZErOfzgt/pqUVK/3u7hTwN8zFTX386C0XzQRYs6QrIMxr2Zcat2gtCAC/G4FTD0P6 X-Received: by 2002:a17:902:44a4:: with SMTP id l33mr14818273pld.174.1560534911911; Fri, 14 Jun 2019 10:55:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534911; cv=none; d=google.com; s=arc-20160816; b=JDHTtdMmE9o9cRER6wjdrkhEvlxzzy6VGLex6Y4T9Wsl89xMw4Fsr5VkDK/mAjQh4J zH0iesf6N/sI+4n/MVLyjN7aGxyY6XRTFJ13/1JNe/Fz5UN3+lWX7WukapF1ogQCSZdv SX9APjVUGEBzfKfeXhLYFHyXQh3u6Kz8BD440/bPksJNlRHg3oQ9FFT1zvVITp6KodRb tfAx6fA1LsrTNbpdztw3npfd+Sf9yZ100+tPtRjr72OQoiavY/aEAjkb5deIqwGDU/M+ 3o4QNu9iLJCIn7oLQUlRuUc2QxaxxRPCx9uTGliE/7kiVpajYb/TCH8y9oZOMzgOJJiR En3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=a9IXM88j6Ie+YWYt+f76NKxQ+LJdkM9Ws5fTUTyr3vQ=; b=sbnnvYVz8GpBGFlafRxiJdN4ul3E2cMtAbQr3BNCWTNGE1y/p7QPd5tW2rr7MGrW0H AwEk/VqigGdN+PKL5Vr6GeOv8t+sBPSl1HvT+mtE2l0o8a7MoRZt0yEBAOiTnRdtmHHb L9il6lB8cvfITNPqDcxXcu25OQ0ERYAkG7jL1zTJmoNfoOM/ZeNX3IXuYTRSCQVdUVE4 i8v7pgWXOeCwm0SSCryZrJPmZpz6J6DjuRSnXKMndTRqfIgu6IAunNC+Bt6vuq2dN8QS 9W0G8D6rALjEMcmWtM0TNXeqrdFNe2mmp63hdN7RiKriBqOde4C5a9rDnOUdSVZb0Y77 rLYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s13si3122309pgp.95.2019.06.14.10.55.11; Fri, 14 Jun 2019 10:55:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727506AbfFNRzK (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:10 -0400 Received: from foss.arm.com ([217.140.110.172]:39480 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727483AbfFNRzI (ORCPT ); Fri, 14 Jun 2019 13:55:08 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D3019D6E; Fri, 14 Jun 2019 10:55:07 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 644D63F718; Fri, 14 Jun 2019 10:55:06 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Bjorn Helgaas , Elie Morisse , "James E.J. Bottomley" , "Martin K. Petersen" , Nehal Shah , "Rafael J. Wysocki" , Shyam Sundar S K Subject: [PATCH v2 11/28] drivers: Add generic helper to match any device Date: Fri, 14 Jun 2019 18:54:06 +0100 Message-Id: <1560534863-15115-12-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a generic helper to match any/all devices. This will be used for providing {bus/driver/class}_find_next_device() Cc: Bjorn Helgaas Cc: Elie Morisse Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: Nehal Shah Cc: "Rafael J. Wysocki" Cc: Shyam Sundar S K Cc: Greg Kroah-Hartman Signed-off-by: Suzuki K Poulose --- drivers/base/core.c | 6 ++++++ include/linux/device.h | 1 + 2 files changed, 7 insertions(+) -- 2.7.4 diff --git a/drivers/base/core.c b/drivers/base/core.c index 5724f93..053ee2e 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3358,3 +3358,9 @@ int device_match_name(struct device *dev, const void *name) return sysfs_streq(dev_name(dev), name); } EXPORT_SYMBOL_GPL(device_match_name); + +int device_match_any(struct device *dev, const void *unused) +{ + return 1; +} +EXPORT_SYMBOL_GPL(device_match_any); diff --git a/include/linux/device.h b/include/linux/device.h index b9b82b7..a449d09 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -168,6 +168,7 @@ int device_match_fwnode(struct device *dev, const void *fwnode); int device_match_devt(struct device *dev, const void *pdevt); int device_match_acpi_dev(struct device *dev, const void *adev); int device_match_name(struct device *dev, const void *name); +int device_match_any(struct device *dev, const void *unused); int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, int (*fn)(struct device *dev, void *data)); From patchwork Fri Jun 14 17:54:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166887 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352764ilk; Fri, 14 Jun 2019 10:55:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRhuWsljpTEcXRvYcBlNJwSpRKjH9zqYyqU6YzYOYkMNPMwKUuaXsGjCEYfF0OQzHfwIZ7 X-Received: by 2002:a17:90a:b104:: with SMTP id z4mr12302410pjq.102.1560534914405; Fri, 14 Jun 2019 10:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534914; cv=none; d=google.com; s=arc-20160816; b=Hz55FMJQzBOgwyhOX1EbNfuiEE0+Tj8gX5ejbhIKRtwRHUZ7iTZNKU3NpLeBhCdCk+ 6Ta9i8Qpwobk8dKar3ejaxx7p4ulxnIHedVbW1E0g6IwKzABtm8mfj/bF0LICAJtFkf2 mU+Ixw9wWubYQoKx89P477E/wVHkHF/t/mfBt7FObe8GPaSYqE6bOv/LS1nFNha9SLQz +UOaRGMxuMHWqTyT/sbep4Td6+pTF/YRWBsi0443joFeQLCJLmMudTH6qg1uCj3QisP7 tLPqyH86vd6yZkPhUnGBH0gV3pKwagpkuAJ2gsE5WNoABOeCKVf5KuOIhAI8sjphAwWJ +ZJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=hjZdlozWKMX5wwkAk6+Z0oVzT7j8RQd3WT7xBQI2TIo=; b=Cm3AoiNa5sAEqOrN/Gazrtre3rZKvTXV7KQygVAI9w7ufKg/9mdEyujCDz49hdnwBw 74zYSdGolHHxtvMz7A4MIX4Ma8JktMfDXMV+QIx+6NM3iA8z7h/LCRdjZsjuoY6CxcJ0 y2hUgwMZrIXaTNx4rnzdfb7OPzzISX4cokQJMoZ+OohxypH8++JO+AA33DlBDdkV4J17 AQoIxdPJ34x37AoFuxAIUn+yW86krJMnzVA+4KPlga+YTOnJBwCWy89CrTNfWW+J/gZM EFPva5MW16+hLSgtgD6nebalrrnNtBZiXnAFnGAj+Np2+FzsRCnfYHkrFYXWyUSQ4PnI ykMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s13si3122309pgp.95.2019.06.14.10.55.14; Fri, 14 Jun 2019 10:55:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727530AbfFNRzM (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:12 -0400 Received: from foss.arm.com ([217.140.110.172]:39504 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727508AbfFNRzL (ORCPT ); Fri, 14 Jun 2019 13:55:11 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 66F1FCFC; Fri, 14 Jun 2019 10:55:10 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 145A83F718; Fri, 14 Jun 2019 10:55:07 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Alexander Shishkin , Maxime Coquelin , Alessandro Zummo , Alexander Aring , Alexandre Belloni , Dan Murphy , Heikki Krogerus , Heiko Carstens , Jacek Anaszewski , linux-leds@vger.kernel.org, linux-rtc@vger.kernel.org, linux-usb@vger.kernel.org, linux-wpan@vger.kernel.org, Martin Schwidefsky , Stefan Schmidt Subject: [PATCH v2 12/28] drivers: Introduce class_find_device_by_name() helper Date: Fri, 14 Jun 2019 18:54:07 +0100 Message-Id: <1560534863-15115-13-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a new wrapper for class_find_device() to search for devices by name and convert the existing users to use the new helper. Cc: Alexander Shishkin Cc: Maxime Coquelin Cc: Alessandro Zummo Cc: Alexander Aring Cc: Alexandre Belloni Cc: Dan Murphy Cc: Greg Kroah-Hartman Cc: Heikki Krogerus Cc: Heiko Carstens Cc: Jacek Anaszewski Cc: linux-leds@vger.kernel.org Cc: linux-rtc@vger.kernel.org Cc: linux-usb@vger.kernel.org Cc: linux-wpan@vger.kernel.org Cc: Martin Schwidefsky Cc: Stefan Schmidt Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/stm/core.c | 9 +-------- drivers/leds/led-class.c | 9 +-------- drivers/rtc/interface.c | 11 +---------- drivers/s390/crypto/zcrypt_api.c | 11 +---------- drivers/usb/roles/class.c | 8 +------- drivers/usb/typec/class.c | 8 +------- include/linux/device.h | 12 ++++++++++++ net/ieee802154/core.c | 7 +------ 8 files changed, 19 insertions(+), 56 deletions(-) -- 2.7.4 Acked-by: Pavel Machek diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c index e55b902..2b6bd42 100644 --- a/drivers/hwtracing/stm/core.c +++ b/drivers/hwtracing/stm/core.c @@ -89,13 +89,6 @@ static struct class stm_class = { .dev_groups = stm_groups, }; -static int stm_dev_match(struct device *dev, const void *data) -{ - const char *name = data; - - return sysfs_streq(name, dev_name(dev)); -} - /** * stm_find_device() - find stm device by name * @buf: character buffer containing the name @@ -116,7 +109,7 @@ struct stm_device *stm_find_device(const char *buf) if (!stm_core_up) return NULL; - dev = class_find_device(&stm_class, NULL, buf, stm_dev_match); + dev = class_find_device_by_name(&stm_class, buf); if (!dev) return NULL; diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index 85848c5..317a619 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -216,13 +216,6 @@ static int led_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(leds_class_dev_pm_ops, led_suspend, led_resume); -static int match_name(struct device *dev, const void *data) -{ - if (!dev_name(dev)) - return 0; - return !strcmp(dev_name(dev), (char *)data); -} - static int led_classdev_next_name(const char *init_name, char *name, size_t len) { @@ -233,7 +226,7 @@ static int led_classdev_next_name(const char *init_name, char *name, strlcpy(name, init_name, len); while ((ret < len) && - (dev = class_find_device(leds_class, NULL, name, match_name))) { + (dev = class_find_device_by_name(leds_class, name))) { put_device(dev); ret = snprintf(name, len, "%s_%u", init_name, ++i); } diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 4124f4d..1bee39c 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -663,21 +663,12 @@ void rtc_update_irq(struct rtc_device *rtc, } EXPORT_SYMBOL_GPL(rtc_update_irq); -static int __rtc_match(struct device *dev, const void *data) -{ - const char *name = data; - - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - struct rtc_device *rtc_class_open(const char *name) { struct device *dev; struct rtc_device *rtc = NULL; - dev = class_find_device(rtc_class, NULL, name, __rtc_match); + dev = class_find_device_by_name(rtc_class, name); if (dev) rtc = to_rtc_device(dev); diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c index 1058b4b..38a5a47 100644 --- a/drivers/s390/crypto/zcrypt_api.c +++ b/drivers/s390/crypto/zcrypt_api.c @@ -133,12 +133,6 @@ struct zcdn_device { static int zcdn_create(const char *name); static int zcdn_destroy(const char *name); -/* helper function, matches the name for find_zcdndev_by_name() */ -static int __match_zcdn_name(struct device *dev, const void *data) -{ - return strcmp(dev_name(dev), (const char *)data) == 0; -} - /* helper function, matches the devt value for find_zcdndev_by_devt() */ static int __match_zcdn_devt(struct device *dev, const void *data) { @@ -152,10 +146,7 @@ static int __match_zcdn_devt(struct device *dev, const void *data) */ static inline struct zcdn_device *find_zcdndev_by_name(const char *name) { - struct device *dev = - class_find_device(zcrypt_class, NULL, - (void *) name, - __match_zcdn_name); + struct device *dev = class_find_device_by_name(zcrypt_class, name); return dev ? to_zcdn_dev(dev) : NULL; } diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c index f45d8df..07aaa96 100644 --- a/drivers/usb/roles/class.c +++ b/drivers/usb/roles/class.c @@ -90,11 +90,6 @@ static int switch_fwnode_match(struct device *dev, const void *fwnode) return dev_fwnode(dev) == fwnode; } -static int switch_name_match(struct device *dev, const void *name) -{ - return !strcmp((const char *)name, dev_name(dev)); -} - static void *usb_role_switch_match(struct device_connection *con, int ep, void *data) { @@ -107,8 +102,7 @@ static void *usb_role_switch_match(struct device_connection *con, int ep, dev = class_find_device(role_class, NULL, con->fwnode, switch_fwnode_match); } else { - dev = class_find_device(role_class, NULL, con->endpoint[ep], - switch_name_match); + dev = class_find_device_by_name(role_class, con->endpoint[ep]); } return dev ? to_role_switch(dev) : ERR_PTR(-EPROBE_DEFER); diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 2eb6238..18a0687 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -210,11 +210,6 @@ static int typec_port_fwnode_match(struct device *dev, const void *fwnode) return dev_fwnode(dev) == fwnode; } -static int typec_port_name_match(struct device *dev, const void *name) -{ - return !strcmp((const char *)name, dev_name(dev)); -} - static void *typec_port_match(struct device_connection *con, int ep, void *data) { struct device *dev; @@ -227,8 +222,7 @@ static void *typec_port_match(struct device_connection *con, int ep, void *data) return class_find_device(typec_class, NULL, con->fwnode, typec_port_fwnode_match); - dev = class_find_device(typec_class, NULL, con->endpoint[ep], - typec_port_name_match); + dev = class_find_device_by_name(typec_class, con->endpoint[ep]); return dev ? dev : ERR_PTR(-EPROBE_DEFER); } diff --git a/include/linux/device.h b/include/linux/device.h index a449d09..bb14c7f 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -485,6 +485,18 @@ extern struct device *class_find_device(struct class *class, struct device *start, const void *data, int (*match)(struct device *, const void *)); +/** + * class_find_device_by_name - device iterator for locating a particular device + * of a specific name. + * @class: class type + * @name: name of the device to match + */ +static inline struct device *class_find_device_by_name(struct class *class, + const char *name) +{ + return class_find_device(class, NULL, name, device_match_name); +} + struct class_attribute { struct attribute attr; ssize_t (*show)(struct class *class, struct class_attribute *attr, diff --git a/net/ieee802154/core.c b/net/ieee802154/core.c index 60b7ac5..de259b5 100644 --- a/net/ieee802154/core.c +++ b/net/ieee802154/core.c @@ -23,11 +23,6 @@ LIST_HEAD(cfg802154_rdev_list); int cfg802154_rdev_list_generation; -static int wpan_phy_match(struct device *dev, const void *data) -{ - return !strcmp(dev_name(dev), (const char *)data); -} - struct wpan_phy *wpan_phy_find(const char *str) { struct device *dev; @@ -35,7 +30,7 @@ struct wpan_phy *wpan_phy_find(const char *str) if (WARN_ON(!str)) return NULL; - dev = class_find_device(&wpan_phy_class, NULL, str, wpan_phy_match); + dev = class_find_device_by_name(&wpan_phy_class, str); if (!dev) return NULL; From patchwork Fri Jun 14 17:54:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166888 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352793ilk; Fri, 14 Jun 2019 10:55:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkdO3jJTqQt6UFS7DZULJ2oX7ESD/JvDTxYtC6N4Ugzb4HVad1JAgBPvuOXcWFpRqVYmcn X-Received: by 2002:a17:902:bc47:: with SMTP id t7mr81420741plz.336.1560534916256; Fri, 14 Jun 2019 10:55:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534916; cv=none; d=google.com; s=arc-20160816; b=aIktQ4koY2EgyT1GIeLtFezna5w/VnsxnDkNow3MRGht5mZFgyB5RUxSltI8JcveTf Nh4hDRUd+C8NF/47V1usNuYlbFqJ0hrejQdB6i+aEbgoX5DKuQN89RQXlXZLDlKDrfKC fsMvYXOPDwaQokgpW6ONsZFG70j/ztiQmWMxdA/rj8yBTbaN4Eyt/SNjr+ieqpHA79L6 E6wLR8eYesbcHSAklBHHITzk4Tz6funvSN5nSko9LhvJv/QQwB30J6LMbg1X/kw/IHfv yNfaCl5A1cESKnzaSV9WYC4KuDdqiymAtPw/6dRv3HOe60wcoLz4M5KTw0iJRi6HgtCb MKxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=LJLgb+s7BFIl3y5JB7dDO7fV/DqG7/b2nAjN+ziswsc=; b=qJ9d6CpiY2DRfMtYk7TbOg9PNGh/d2EkFN9XGKmepXtDfR/bIQiIJxFEYpYNAA9vGt wKSrT50+7K2WexYOD+uvaSoU1szy90xkyETCJaaGV0l3Kb/bdQXh6/LkmZ4cQlS21T9H Yrr7aSQeASEDCIqgJkw3MF0/u9S4InIVqS1hSZR4IkT97YStGjB7h8jH0aUcGZGoLmtJ z1iE++Rg/DmDGpqjs5sl/pM5R8E5q2QIj81CL0ENAvhvU8Gw/LU8rFz5QY+gXf5JHq9N fxiMHlmJZ26x3XL/NcLjbMUF15lYExv6me/ULMZ47mTaw5tu8qFe0wmLKd+qyspE5xsa DPIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s13si3122309pgp.95.2019.06.14.10.55.16; Fri, 14 Jun 2019 10:55:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727554AbfFNRzP (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:15 -0400 Received: from foss.arm.com ([217.140.110.172]:39528 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727125AbfFNRzN (ORCPT ); Fri, 14 Jun 2019 13:55:13 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 81C2ED6E; Fri, 14 Jun 2019 10:55:12 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9A9403F718; Fri, 14 Jun 2019 10:55:10 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Alan Tull , Moritz Fischer , linux-fpga@vger.kernel.org, Peter Rosin , Mark Brown , Florian Fainelli , Heiner Kallweit , "David S. Miller" , Andrew Lunn , Liam Girdwood , Jiri Slaby Subject: [PATCH v2 13/28] drivers: Introduce class_find_device_by_of_node() helper Date: Fri, 14 Jun 2019 18:54:08 +0100 Message-Id: <1560534863-15115-14-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a wrapper to class_find_device() to search for a device by the of_node pointer, reusing the generic match function. Also convert the existing users to make use of the new helper. Cc: Alan Tull Cc: Moritz Fischer Cc: linux-fpga@vger.kernel.org Cc: Peter Rosin Cc: Mark Brown Cc: Florian Fainelli Cc: Heiner Kallweit Cc: "David S. Miller" Cc: Andrew Lunn Cc: Liam Girdwood Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: Jiri Slaby Acked-by: Mark Brown Reviewed-by: Andrew Lunn Reviewed-by: Peter Rosin Signed-off-by: Suzuki K Poulose --- drivers/fpga/fpga-bridge.c | 8 +------- drivers/fpga/fpga-mgr.c | 8 +------- drivers/mux/core.c | 7 +------ drivers/net/phy/mdio_bus.c | 9 +-------- drivers/regulator/of_regulator.c | 7 +------ drivers/spi/spi.c | 11 ++--------- include/linux/device.h | 12 ++++++++++++ 7 files changed, 19 insertions(+), 43 deletions(-) -- 2.7.4 diff --git a/drivers/fpga/fpga-bridge.c b/drivers/fpga/fpga-bridge.c index 80bd8f1..4bab902 100644 --- a/drivers/fpga/fpga-bridge.c +++ b/drivers/fpga/fpga-bridge.c @@ -19,11 +19,6 @@ static struct class *fpga_bridge_class; /* Lock for adding/removing bridges to linked lists*/ static spinlock_t bridge_list_lock; -static int fpga_bridge_of_node_match(struct device *dev, const void *data) -{ - return dev->of_node == data; -} - /** * fpga_bridge_enable - Enable transactions on the bridge * @@ -104,8 +99,7 @@ struct fpga_bridge *of_fpga_bridge_get(struct device_node *np, { struct device *dev; - dev = class_find_device(fpga_bridge_class, NULL, np, - fpga_bridge_of_node_match); + dev = class_find_device_by_of_node(fpga_bridge_class, np); if (!dev) return ERR_PTR(-ENODEV); diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index c386681..e05104f 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -482,11 +482,6 @@ struct fpga_manager *fpga_mgr_get(struct device *dev) } EXPORT_SYMBOL_GPL(fpga_mgr_get); -static int fpga_mgr_of_node_match(struct device *dev, const void *data) -{ - return dev->of_node == data; -} - /** * of_fpga_mgr_get - Given a device node, get a reference to a fpga mgr. * @@ -498,8 +493,7 @@ struct fpga_manager *of_fpga_mgr_get(struct device_node *node) { struct device *dev; - dev = class_find_device(fpga_mgr_class, NULL, node, - fpga_mgr_of_node_match); + dev = class_find_device_by_of_node(fpga_mgr_class, node); if (!dev) return ERR_PTR(-ENODEV); diff --git a/drivers/mux/core.c b/drivers/mux/core.c index d1271c1..1fb2238 100644 --- a/drivers/mux/core.c +++ b/drivers/mux/core.c @@ -405,17 +405,12 @@ int mux_control_deselect(struct mux_control *mux) } EXPORT_SYMBOL_GPL(mux_control_deselect); -static int of_dev_node_match(struct device *dev, const void *data) -{ - return dev->of_node == data; -} - /* Note this function returns a reference to the mux_chip dev. */ static struct mux_chip *of_find_mux_chip_by_node(struct device_node *np) { struct device *dev; - dev = class_find_device(&mux_class, NULL, np, of_dev_node_match); + dev = class_find_device_by_of_node(&mux_class, np); return dev ? to_mux_chip(dev) : NULL; } diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index bd04fe7..ce94087 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -262,11 +262,6 @@ static struct class mdio_bus_class = { }; #if IS_ENABLED(CONFIG_OF_MDIO) -/* Helper function for of_mdio_find_bus */ -static int of_mdio_bus_match(struct device *dev, const void *mdio_bus_np) -{ - return dev->of_node == mdio_bus_np; -} /** * of_mdio_find_bus - Given an mii_bus node, find the mii_bus. * @mdio_bus_np: Pointer to the mii_bus. @@ -287,9 +282,7 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np) if (!mdio_bus_np) return NULL; - d = class_find_device(&mdio_bus_class, NULL, mdio_bus_np, - of_mdio_bus_match); - + d = class_find_device_by_of_node(&mdio_bus_class, mdio_bus_np); return d ? to_mii_bus(d) : NULL; } EXPORT_SYMBOL(of_mdio_find_bus); diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 0ead116..1b40277 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -442,16 +442,11 @@ struct regulator_init_data *regulator_of_get_init_data(struct device *dev, return NULL; } -static int of_node_match(struct device *dev, const void *data) -{ - return dev->of_node == data; -} - struct regulator_dev *of_find_regulator_by_node(struct device_node *np) { struct device *dev; - dev = class_find_device(®ulator_class, NULL, np, of_node_match); + dev = class_find_device_by_of_node(®ulator_class, np); return dev ? dev_to_rdev(dev) : NULL; } diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 3da1121..a256be5 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -3554,21 +3554,14 @@ EXPORT_SYMBOL_GPL(of_find_spi_device_by_node); #endif /* IS_ENABLED(CONFIG_OF) */ #if IS_ENABLED(CONFIG_OF_DYNAMIC) -static int __spi_of_controller_match(struct device *dev, const void *data) -{ - return dev->of_node == data; -} - /* the spi controllers are not using spi_bus, so we find it with another way */ static struct spi_controller *of_find_spi_controller_by_node(struct device_node *node) { struct device *dev; - dev = class_find_device(&spi_master_class, NULL, node, - __spi_of_controller_match); + dev = class_find_device_by_of_node(&spi_master_class, node); if (!dev && IS_ENABLED(CONFIG_SPI_SLAVE)) - dev = class_find_device(&spi_slave_class, NULL, node, - __spi_of_controller_match); + dev = class_find_device_by_of_node(&spi_slave_class, node); if (!dev) return NULL; diff --git a/include/linux/device.h b/include/linux/device.h index bb14c7f..9228502 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -497,6 +497,18 @@ static inline struct device *class_find_device_by_name(struct class *class, return class_find_device(class, NULL, name, device_match_name); } +/** + * class_find_device_by_of_node : device iterator for locating a particular device + * matching the of_node. + * @class: class type + * @np: of_node of the device to match. + */ +static inline struct device * +class_find_device_by_of_node(struct class *class, const struct device_node *np) +{ + return class_find_device(class, NULL, np, device_match_of_node); +} + struct class_attribute { struct attribute attr; ssize_t (*show)(struct class *class, struct class_attribute *attr, From patchwork Fri Jun 14 17:54:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166889 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352805ilk; Fri, 14 Jun 2019 10:55:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZbrHqFg6RtlDM/WqxsLwPKCjxacWFB6ef6DQV3yfaUjXgrE1IQbI04mN3qNXC2LYdeGhP X-Received: by 2002:a17:902:23:: with SMTP id 32mr32894295pla.34.1560534916883; Fri, 14 Jun 2019 10:55:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534916; cv=none; d=google.com; s=arc-20160816; b=OOKYWtIiMilTDG1fqWPdrPjuA7FyhsitykxhCmNKGUYdvLtk851YanvIqufQiZNt7v aJ94qlgnaZKQXF2pkfNf2EECo0Y/Jwn+ppmVbdR2JAt7W+Hfuiw/vYiWThTXxWItoNwh HmieJCqWzfNWvhd+MJPrKFRLrEYE7tNlpUJw03jQvBZQ/+eKK/5QhWzSGhiQfUW78+O9 eoviwcuPTWndokKttyX604Bfp0sG74AXytuUHcUASyRDl5rmVDNg59fYQpeLV4Xp9azk GzOCmP9Y0xIo60qFRANEWzkij168BcXIn+bbK0OEr8ZvYHbOsADPB7INbo2QzXkb/M3a IT6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=h0kGJpVTJtrorQAAz0dAdG1rVev8KpUba2RYVymoMYI=; b=py64b6lblil1GEppOTMPqI5uTO3IpSF5mjl8Z+Nb+dBRsfNobgXHD1P9yjej27ZiuQ GIVk/GaAAI+ZqaU58SiEIGophXYNWzo8kqVnIigajuUba27zvAwfFNQQTAubbRzNcbPa kfXIWLR5TusjTxP16aknVJXvn3r/fOo/o0g/zi9cryzE9dwDSifG00N4A2JsRWOvC6pY pnOO501LPmHoDdgQI992xqi6h73s6GTxnZM7AA3SgeszQfOZVvmw++aQFR1pE0gJn4RE yNXYcAai9ZPSsxRQNsg9eHRcrYPyCJpH1ceBwTHYPfLoPVP5sbRleE/DL6yUMw2YY1lS czWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s13si3122309pgp.95.2019.06.14.10.55.16; Fri, 14 Jun 2019 10:55:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727569AbfFNRzP (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:15 -0400 Received: from foss.arm.com ([217.140.110.172]:39548 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727483AbfFNRzO (ORCPT ); Fri, 14 Jun 2019 13:55:14 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9CCD8ED1; Fri, 14 Jun 2019 10:55:13 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B50993F718; Fri, 14 Jun 2019 10:55:12 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Heikki Krogerus , linux-usb@vger.kernel.org Subject: [PATCH v2 14/28] drivers: Introduce class_find_device_by_fwnode() helper Date: Fri, 14 Jun 2019 18:54:09 +0100 Message-Id: <1560534863-15115-15-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a wrapper to class_find_device() to search for a device by the fwnode pointer, reusing the generic match function. Also convert the existing users to make use of the new helper. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: Heikki Krogerus Cc: linux-usb@vger.kernel.org Signed-off-by: Suzuki K Poulose --- drivers/usb/roles/class.c | 8 +------- drivers/usb/typec/class.c | 8 +------- include/linux/device.h | 13 +++++++++++++ 3 files changed, 15 insertions(+), 14 deletions(-) -- 2.7.4 diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c index 07aaa96..5cd87d8 100644 --- a/drivers/usb/roles/class.c +++ b/drivers/usb/roles/class.c @@ -85,11 +85,6 @@ enum usb_role usb_role_switch_get_role(struct usb_role_switch *sw) } EXPORT_SYMBOL_GPL(usb_role_switch_get_role); -static int switch_fwnode_match(struct device *dev, const void *fwnode) -{ - return dev_fwnode(dev) == fwnode; -} - static void *usb_role_switch_match(struct device_connection *con, int ep, void *data) { @@ -99,8 +94,7 @@ static void *usb_role_switch_match(struct device_connection *con, int ep, if (!fwnode_property_present(con->fwnode, con->id)) return NULL; - dev = class_find_device(role_class, NULL, con->fwnode, - switch_fwnode_match); + dev = class_find_device_by_fwnode(role_class, con->fwnode); } else { dev = class_find_device_by_name(role_class, con->endpoint[ep]); } diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 18a0687..af4fb73 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -205,11 +205,6 @@ static void typec_altmode_put_partner(struct altmode *altmode) put_device(&adev->dev); } -static int typec_port_fwnode_match(struct device *dev, const void *fwnode) -{ - return dev_fwnode(dev) == fwnode; -} - static void *typec_port_match(struct device_connection *con, int ep, void *data) { struct device *dev; @@ -219,8 +214,7 @@ static void *typec_port_match(struct device_connection *con, int ep, void *data) * we need to return ERR_PTR(-PROBE_DEFER) when there is no device. */ if (con->fwnode) - return class_find_device(typec_class, NULL, con->fwnode, - typec_port_fwnode_match); + return class_find_device_by_fwnode(typec_class, con->fwnode); dev = class_find_device_by_name(typec_class, con->endpoint[ep]); diff --git a/include/linux/device.h b/include/linux/device.h index 9228502..52ac911 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -509,6 +509,19 @@ class_find_device_by_of_node(struct class *class, const struct device_node *np) return class_find_device(class, NULL, np, device_match_of_node); } +/** + * class_find_device_by_fwnode : device iterator for locating a particular device + * matching the fwnode. + * @class: class type + * @fwnode: fwnode of the device to match. + */ +static inline struct device * +class_find_device_by_fwnode(struct class *class, + const struct fwnode_handle *fwnode) +{ + return class_find_device(class, NULL, fwnode, device_match_fwnode); +} + struct class_attribute { struct attribute attr; ssize_t (*show)(struct class *class, struct class_attribute *attr, From patchwork Fri Jun 14 17:54:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166891 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352872ilk; Fri, 14 Jun 2019 10:55:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAuycJI8zYETUbGbFEGPLgB7g0OoRcWjyOo11pglu+n3iklEjVLUvrwI57jAjOivGJHzyU X-Received: by 2002:a65:638e:: with SMTP id h14mr14723797pgv.86.1560534920543; Fri, 14 Jun 2019 10:55:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534920; cv=none; d=google.com; s=arc-20160816; b=JcQFD0pcr1Kz1aX0IDBsSPgLrkD/t32AvRwowEV4n/idU4MIY+2ovsUv/FNvhMT36Q L1aWRQE8zrc189/U6eUAqmsjGcybIC6cl4ORF8dmHkXBTX/gP/O+zY2BjgXTDrs3NSSm HNnIxyZrkc2V7Bkq7dZJeAyJZ7VdyteonC9apnaqeL9HVTc9c4yAPT5pUph57iTl3VQU tQq+svAc3TGFN0+ncBDKu+PMIEAbBiHeCDvGhS1EGPVt30D3eE337ESlLHum6UPpgm7K vSKo99F4g2HKJAU7teGGyBt0zo3s62jCw8XQsgxtx5WFDCuDvSh3dqPBtOYu0NKA1gS/ +Gvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=PJOXJ4AEstkjQkUtl2Woi9MAirGoeOo/1SGSV5Cd1Zg=; b=Ik8Y7XHAPnhBDImEC4ELToInzYZK3ubYo4WZymQ27UI9ID1tIDDd35dlHrzxPGkQgh 3fN6VqHu+yshiGkq3lph3rzxifJWxBFvG4BFiOGjX5NKQHBRkkv+egNstXI892fXDrMf aIWJ9J3hCg9gdkItYby8wIa2yRTXozG1PjbfTjL0xvCJwrSsQT6Vrq3W6v321EnLOEXY FJ1SCt63JRVkSAkZCQIRZB/VuoJyMDcQ/we+azJRedlDHG650+y/XtP00ZFz2YYIOW4r NoVC3AtSyXFrgPBUeVnE61QAcPrmqvbwECStSoiGxYrd1iCP3vrEK1hzOufD+bHOPMW8 Dypg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s13si3122309pgp.95.2019.06.14.10.55.20; Fri, 14 Jun 2019 10:55:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727605AbfFNRzT (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:19 -0400 Received: from foss.arm.com ([217.140.110.172]:39556 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727547AbfFNRzP (ORCPT ); Fri, 14 Jun 2019 13:55:15 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EE08E106F; Fri, 14 Jun 2019 10:55:14 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D03763F718; Fri, 14 Jun 2019 10:55:13 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Heiko Carstens , Harald Freudenberger , Tomas Winkler , Arnd Bergmann Subject: [PATCH v2 15/28] drivers: Introduce class_find_device_by_devt() helper Date: Fri, 14 Jun 2019 18:54:10 +0100 Message-Id: <1560534863-15115-16-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a wrapper to class_find_device() to search for a device by the device type, reusing the generic match function. Also convert the existing users. Cc: Heiko Carstens Cc: Harald Freudenberger Cc: Tomas Winkler Cc: Arnd Bergmann Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Acked-by: Harald Freudenberger Signed-off-by: Suzuki K Poulose --- drivers/base/core.c | 9 +-------- drivers/misc/mei/main.c | 9 +-------- drivers/s390/crypto/zcrypt_api.c | 11 +---------- drivers/tty/tty_io.c | 8 +------- include/linux/device.h | 12 ++++++++++++ 5 files changed, 16 insertions(+), 33 deletions(-) -- 2.7.4 diff --git a/drivers/base/core.c b/drivers/base/core.c index 053ee2e..e9746cf 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2839,13 +2839,6 @@ struct device *device_create_with_groups(struct class *class, } EXPORT_SYMBOL_GPL(device_create_with_groups); -static int __match_devt(struct device *dev, const void *data) -{ - const dev_t *devt = data; - - return dev->devt == *devt; -} - /** * device_destroy - removes a device that was created with device_create() * @class: pointer to the struct class that this device was registered with @@ -2858,7 +2851,7 @@ void device_destroy(struct class *class, dev_t devt) { struct device *dev; - dev = class_find_device(class, NULL, &devt, __match_devt); + dev = class_find_device_by_devt(class, devt); if (dev) { put_device(dev); device_unregister(dev); diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index ad02097..572502a 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c @@ -858,13 +858,6 @@ static ssize_t dev_state_show(struct device *device, } static DEVICE_ATTR_RO(dev_state); -static int match_devt(struct device *dev, const void *data) -{ - const dev_t *devt = data; - - return dev->devt == *devt; -} - /** * dev_set_devstate: set to new device state and notify sysfs file. * @@ -880,7 +873,7 @@ void mei_set_devstate(struct mei_device *dev, enum mei_dev_state state) dev->dev_state = state; - clsdev = class_find_device(mei_class, NULL, &dev->cdev.dev, match_devt); + clsdev = class_find_device_by_devt(mei_class, dev->cdev.dev); if (clsdev) { sysfs_notify(&clsdev->kobj, NULL, "dev_state"); put_device(clsdev); diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c index 38a5a47..150f623 100644 --- a/drivers/s390/crypto/zcrypt_api.c +++ b/drivers/s390/crypto/zcrypt_api.c @@ -133,12 +133,6 @@ struct zcdn_device { static int zcdn_create(const char *name); static int zcdn_destroy(const char *name); -/* helper function, matches the devt value for find_zcdndev_by_devt() */ -static int __match_zcdn_devt(struct device *dev, const void *data) -{ - return dev->devt == *((dev_t *) data); -} - /* * Find zcdn device by name. * Returns reference to the zcdn device which needs to be released @@ -158,10 +152,7 @@ static inline struct zcdn_device *find_zcdndev_by_name(const char *name) */ static inline struct zcdn_device *find_zcdndev_by_devt(dev_t devt) { - struct device *dev = - class_find_device(zcrypt_class, NULL, - (void *) &devt, - __match_zcdn_devt); + struct device *dev = class_find_device_by_devt(zcrypt_class, devt); return dev ? to_zcdn_dev(dev) : NULL; } diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 033ac7e..202f640 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -2950,17 +2950,11 @@ void do_SAK(struct tty_struct *tty) EXPORT_SYMBOL(do_SAK); -static int dev_match_devt(struct device *dev, const void *data) -{ - const dev_t *devt = data; - return dev->devt == *devt; -} - /* Must put_device() after it's unused! */ static struct device *tty_get_device(struct tty_struct *tty) { dev_t devt = tty_devnum(tty); - return class_find_device(tty_class, NULL, &devt, dev_match_devt); + return class_find_device_by_devt(tty_class, devt); } diff --git a/include/linux/device.h b/include/linux/device.h index 52ac911..2effcc2 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -522,6 +522,18 @@ class_find_device_by_fwnode(struct class *class, return class_find_device(class, NULL, fwnode, device_match_fwnode); } +/** + * class_find_device_by_devt : device iterator for locating a particular device + * matching the device type. + * @class: class type + * @devt: device type of the device to match. + */ +static inline struct device *class_find_device_by_devt(struct class *class, + dev_t devt) +{ + return class_find_device(class, NULL, &devt, device_match_devt); +} + struct class_attribute { struct attribute attr; ssize_t (*show)(struct class *class, struct class_attribute *attr, From patchwork Fri Jun 14 17:54:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166890 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352846ilk; Fri, 14 Jun 2019 10:55:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXtHFUB9zVDdsVAxxrM4CpMmKQvEZFhqcKUIu5mGCXIHKKWjdL4/BzHM1UWne9aXNdiaJl X-Received: by 2002:a17:90a:8d0d:: with SMTP id c13mr11803188pjo.137.1560534918986; Fri, 14 Jun 2019 10:55:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534918; cv=none; d=google.com; s=arc-20160816; b=L1J64z6F1PFKH+RNLUObqPIRqh8dmp78Tb9GFCTxeP1Uj/HTA1GG2epaLSuLsKwvfr tQ94HfvUKFBdApkph1vcijLsNOWhOJzraYV+2UaH7dPe6xTT2Y9U9v1PCthUQ6TRq57L wr647MYG7dHk/SV0xWvRqdIWUOXmFJYr/2t00hAE+o6PaAzASHFnnq2BjPRQJUuf6+r+ blozest42vbBSgzR6pWcQ4lvtGuP258S0gvScvm83jI2iet0l0A/3A2sWH6Xh1DfwlEs KHekOj4i3fgE+PiLfy+Sq4NASt0SXkLkus9jRKKr8VGI7uuFfi5xnFsqUixzLKZw/0Hq PxCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=c9o3GtHO217nUgCv6NA4hyWW1vCgV80gFdh2FfcxvOo=; b=Q/vjxH5pC5nwv2U/t0DbFNCnpbDYbwZUMuVAgPZ2kkeuRRVCoXJuSRFu2DkllcnrTd TUf7dEB5ATXLID8a512f3WT+wunwBpDHmQhgF2uOJ6EX6MTjGQltN2DSAUJAzrogrmIj vegsi0T/RiKk+ShGwYziHsziEMyfh8WZJO4J9UtuF4mVRoac5WZzfDZttHIWpG4eU6za xAIJ2Sj6pAuY9i5C6biyNCvZIc4EKi1f55AkprCEojwNYHEaLnGVCoW3KN2Rl7VSzqlg KDAm8w2lnH1LCuhe0/MuhJzOg3cR7feUo/2T3eHUrAK4mjxMSRvImW1MVSyjjXhHUZXO ULaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s13si3122309pgp.95.2019.06.14.10.55.18; Fri, 14 Jun 2019 10:55:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727065AbfFNRzS (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:18 -0400 Received: from foss.arm.com ([217.140.110.172]:39574 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727483AbfFNRzQ (ORCPT ); Fri, 14 Jun 2019 13:55:16 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D2E6AD6E; Fri, 14 Jun 2019 10:55:15 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2CF1C3F718; Fri, 14 Jun 2019 10:55:15 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com Subject: [PATCH v2 16/28] drivers: Introduce class_find_device_by_acpi_dev() helper Date: Fri, 14 Jun 2019 18:54:11 +0100 Message-Id: <1560534863-15115-17-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a wrapper to class_find_device() to search for a device by the ACPI COMPANION device, reusing the generic match function. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- include/linux/device.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) -- 2.7.4 diff --git a/include/linux/device.h b/include/linux/device.h index 2effcc2..b1b8c90 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -534,6 +534,27 @@ static inline struct device *class_find_device_by_devt(struct class *class, return class_find_device(class, NULL, &devt, device_match_devt); } +#ifdef CONFIG_ACPI +struct acpi_device; +/** + * class_find_device_by_acpi_dev : device iterator for locating a particular + * device matching the ACPI_COMPANION device. + * @class: class type + * @adev: ACPI_COMPANION device to match. + */ +static inline struct device * +class_find_device_by_acpi_dev(struct class *class, const struct acpi_device *adev) +{ + return class_find_device(class, NULL, adev, device_match_acpi_dev); +} +#else +static inline struct device * +class_find_device_by_acpi_dev(struct class *class, const void *adev) +{ + return NULL; +} +#endif + struct class_attribute { struct attribute attr; ssize_t (*show)(struct class *class, struct class_attribute *attr, From patchwork Fri Jun 14 17:54:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166893 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352918ilk; Fri, 14 Jun 2019 10:55:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqykNyCETXi+w9VHvrla0DLvlFhJWK0hOH2doDCq/Y0a6lsQk/3GkKcQZvJC4nNLp0T0Lh8N X-Received: by 2002:a17:90a:7148:: with SMTP id g8mr5010692pjs.51.1560534924107; Fri, 14 Jun 2019 10:55:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534924; cv=none; d=google.com; s=arc-20160816; b=ugDthTfoxa+tRNm8x4d1pUXmNG9udVpAnh5HlpsbbeUu/TJI8jyXV3IsieHMzr+1+C pYr8pOUV8F+Ld1u0gjh9960vunVObtFs2FPpS2uWd0u2WUkKKsuoPeHlxYLy2HzRr5lW hKZaX7Dv2I8Tm4Vyal7BpoCG7teVIzE4KraT7pQ6PNwWTIpaXk3dZLp4KLAoLrVsMhb/ iLn15tYh2mG8wshjvjO8TOG5bZtqZ8MD5SXBmgmOIlepL7aNwWL5O2Tndv0ibVrLrqiF NnTVGgI7Vca5aWJ+Fa3HRoh1uqGf/0X1RFCaBHy2RUyK0ObCm6uaREF9wBKbp6VIoRyb 14jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=W3DsgUeBHTdilKrP6W9xjtJ/393d55VJNz2p5QcN8qA=; b=hsb2ZL+AsH/F9MbcglI6agUv8S6tnXbgEEIGBR+1URkPMPFoyIh3FKEHhJygRPulVj kZ5COnIr9ItfOFzNkAkaRP21ONbLXjerzSM9ALA5YWdY8KBjjxhQKVaSt/xmuDgSc8DZ M3LLmZKGUDlQ+ZLziNvWoXC0FFvYBPcwF9tr4WS9dzcgDgbbsdo5DpoQo7o3wFc0z9i3 0TSqQL2UEYdOr5DsFV2J2MsCdNqts6CIaEpAapfuo8/3pp9lFCQBx93mZRoXzR4/S2zp qKXEuNCcTDS+lIJdOxEhoaO9pZS/7KsVqZaR03wZlGr0MZqmFZ1WSnI0wuJrfNcrxaNd dt1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h4si3050048pgs.269.2019.06.14.10.55.23; Fri, 14 Jun 2019 10:55:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727644AbfFNRzW (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:22 -0400 Received: from foss.arm.com ([217.140.110.172]:39582 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727604AbfFNRzU (ORCPT ); Fri, 14 Jun 2019 13:55:20 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B91BED6E; Fri, 14 Jun 2019 10:55:18 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 155873F718; Fri, 14 Jun 2019 10:55:15 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Maarten Lankhorst , Maxime Ripard , dri-devel@lists.freedesktop.org, David Airlie , Daniel Vetter , devicetree@vger.kernel.org, Florian Fainelli , Frank Rowand , Heiko Stuebner , Liam Girdwood , linux-i2c@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-spi@vger.kernel.org, Mathieu Poirier , Rob Herring , Srinivas Kandagatla , Takashi Iwai , Wolfram Sang Subject: [PATCH v2 17/28] drivers: Introduce bus_find_device_by_of_node() helper Date: Fri, 14 Jun 2019 18:54:12 +0100 Message-Id: <1560534863-15115-18-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a wrapper to bus_find_device() to search for a device by the of_node pointer, reusing the generic match function. Also convert the existing users to make use of the new helper. Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: dri-devel@lists.freedesktop.org Cc: David Airlie Cc: Daniel Vetter Cc: devicetree@vger.kernel.org Cc: Florian Fainelli Cc: Frank Rowand Cc: Heiko Stuebner Cc: Liam Girdwood Cc: linux-i2c@vger.kernel.org Cc: linux-rockchip@lists.infradead.org Cc: linux-spi@vger.kernel.org Cc: Mathieu Poirier Cc: Rob Herring Cc: Srinivas Kandagatla Cc: Takashi Iwai Cc: Wolfram Sang Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- drivers/gpu/drm/drm_mipi_dsi.c | 7 +------ drivers/hwtracing/coresight/of_coresight.c | 11 ++--------- drivers/i2c/i2c-core-of.c | 7 +------ drivers/nvmem/core.c | 7 +------ drivers/of/of_mdio.c | 8 +------- drivers/of/platform.c | 7 +------ drivers/spi/spi.c | 9 ++------- include/linux/device.h | 12 ++++++++++++ sound/soc/rockchip/rk3399_gru_sound.c | 9 ++------- 9 files changed, 23 insertions(+), 54 deletions(-) -- 2.7.4 diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index ad19df0..bd2498b 100644 --- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c @@ -93,11 +93,6 @@ static struct bus_type mipi_dsi_bus_type = { .pm = &mipi_dsi_device_pm_ops, }; -static int of_device_match(struct device *dev, const void *data) -{ - return dev->of_node == data; -} - /** * of_find_mipi_dsi_device_by_node() - find the MIPI DSI device matching a * device tree node @@ -110,7 +105,7 @@ struct mipi_dsi_device *of_find_mipi_dsi_device_by_node(struct device_node *np) { struct device *dev; - dev = bus_find_device(&mipi_dsi_bus_type, NULL, np, of_device_match); + dev = bus_find_device_by_of_node(&mipi_dsi_bus_type, np); return dev ? to_mipi_dsi_device(dev) : NULL; } diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c index 3fc200e..f417f76 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -18,11 +18,6 @@ #include -static int of_dev_node_match(struct device *dev, const void *data) -{ - return dev->of_node == data; -} - static struct device * of_coresight_get_endpoint_device(struct device_node *endpoint) { @@ -32,8 +27,7 @@ of_coresight_get_endpoint_device(struct device_node *endpoint) * If we have a non-configurable replicator, it will be found on the * platform bus. */ - dev = bus_find_device(&platform_bus_type, NULL, - endpoint, of_dev_node_match); + dev = bus_find_device_by_of_node(&platform_bus_type, endpoint); if (dev) return dev; @@ -41,8 +35,7 @@ of_coresight_get_endpoint_device(struct device_node *endpoint) * We have a configurable component - circle through the AMBA bus * looking for the device that matches the endpoint node. */ - return bus_find_device(&amba_bustype, NULL, - endpoint, of_dev_node_match); + return bus_find_device_by_of_node(&amba_bustype, endpoint); } static inline bool of_coresight_legacy_ep_is_input(struct device_node *ep) diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c index 2eb59a2..74a4126 100644 --- a/drivers/i2c/i2c-core-of.c +++ b/drivers/i2c/i2c-core-of.c @@ -112,11 +112,6 @@ void of_i2c_register_devices(struct i2c_adapter *adap) of_node_put(bus); } -static int of_dev_node_match(struct device *dev, const void *data) -{ - return dev->of_node == data; -} - static int of_dev_or_parent_node_match(struct device *dev, const void *data) { if (dev->of_node == data) @@ -134,7 +129,7 @@ struct i2c_client *of_find_i2c_device_by_node(struct device_node *node) struct device *dev; struct i2c_client *client; - dev = bus_find_device(&i2c_bus_type, NULL, node, of_dev_node_match); + dev = bus_find_device_by_of_node(&i2c_bus_type, node); if (!dev) return NULL; diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index ac5d945..057d1ff 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -76,11 +76,6 @@ static struct bus_type nvmem_bus_type = { .name = "nvmem", }; -static int of_nvmem_match(struct device *dev, const void *nvmem_np) -{ - return dev->of_node == nvmem_np; -} - static struct nvmem_device *of_nvmem_find(struct device_node *nvmem_np) { struct device *d; @@ -88,7 +83,7 @@ static struct nvmem_device *of_nvmem_find(struct device_node *nvmem_np) if (!nvmem_np) return NULL; - d = bus_find_device(&nvmem_bus_type, NULL, nvmem_np, of_nvmem_match); + d = bus_find_device_by_of_node(&nvmem_bus_type, nvmem_np); if (!d) return NULL; diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index 44f5349..000b957 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c @@ -280,12 +280,6 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) } EXPORT_SYMBOL(of_mdiobus_register); -/* Helper function for of_phy_find_device */ -static int of_phy_match(struct device *dev, const void *phy_np) -{ - return dev->of_node == phy_np; -} - /** * of_phy_find_device - Give a PHY node, find the phy_device * @phy_np: Pointer to the phy's device tree node @@ -301,7 +295,7 @@ struct phy_device *of_phy_find_device(struct device_node *phy_np) if (!phy_np) return NULL; - d = bus_find_device(&mdio_bus_type, NULL, phy_np, of_phy_match); + d = bus_find_device_by_of_node(&mdio_bus_type, phy_np); if (d) { mdiodev = to_mdio_device(d); if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 008d79e..de11905 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -37,11 +37,6 @@ static const struct of_device_id of_skipped_node_table[] = { {} /* Empty terminated list */ }; -static int of_dev_node_match(struct device *dev, const void *data) -{ - return dev->of_node == data; -} - /** * of_find_device_by_node - Find the platform_device associated with a node * @np: Pointer to device tree node @@ -55,7 +50,7 @@ struct platform_device *of_find_device_by_node(struct device_node *np) { struct device *dev; - dev = bus_find_device(&platform_bus_type, NULL, np, of_dev_node_match); + dev = bus_find_device_by_of_node(&platform_bus_type, np); return dev ? to_platform_device(dev) : NULL; } EXPORT_SYMBOL(of_find_device_by_node); diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index a256be5..cc4d83e 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -3538,16 +3538,11 @@ EXPORT_SYMBOL_GPL(spi_write_then_read); /*-------------------------------------------------------------------------*/ #if IS_ENABLED(CONFIG_OF) -static int __spi_of_device_match(struct device *dev, const void *data) -{ - return dev->of_node == data; -} - /* must call put_device() when done with returned spi_device device */ struct spi_device *of_find_spi_device_by_node(struct device_node *node) { - struct device *dev = bus_find_device(&spi_bus_type, NULL, node, - __spi_of_device_match); + struct device *dev = bus_find_device_by_of_node(&spi_bus_type, node); + return dev ? to_spi_device(dev) : NULL; } EXPORT_SYMBOL_GPL(of_find_spi_device_by_node); diff --git a/include/linux/device.h b/include/linux/device.h index b1b8c90..35f51d6 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -189,6 +189,18 @@ static inline struct device *bus_find_device_by_name(struct bus_type *bus, return bus_find_device(bus, start, name, device_match_name); } +/** + * bus_find_device_by_of_node : device iterator for locating a particular device + * matching the of_node. + * @bus: bus type + * @np: of_node of the device to match. + */ +static inline struct device * +bus_find_device_by_of_node(struct bus_type *bus, const struct device_node *np) +{ + return bus_find_device(bus, NULL, np, device_match_of_node); +} + struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id, struct device *hint); int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c index c04c9ed..2fb7f8e 100644 --- a/sound/soc/rockchip/rk3399_gru_sound.c +++ b/sound/soc/rockchip/rk3399_gru_sound.c @@ -405,11 +405,6 @@ static const struct dailink_match_data dailink_match[] = { }, }; -static int of_dev_node_match(struct device *dev, const void *data) -{ - return dev->of_node == data; -} - static int rockchip_sound_codec_node_match(struct device_node *np_codec) { struct device *dev; @@ -421,8 +416,8 @@ static int rockchip_sound_codec_node_match(struct device_node *np_codec) continue; if (dailink_match[i].bus_type) { - dev = bus_find_device(dailink_match[i].bus_type, NULL, - np_codec, of_dev_node_match); + dev = bus_find_device_by_of_node(dailink_match[i].bus_type, + np_codec); if (!dev) continue; put_device(dev); From patchwork Fri Jun 14 17:54:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166892 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352910ilk; Fri, 14 Jun 2019 10:55:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFBvlly+VarruWvbmnO15igWrmegCOz6lgPHS0xM2vGZWFu9eK+9FFUX3LQZjPiao0E3ak X-Received: by 2002:a17:90a:9a83:: with SMTP id e3mr12048633pjp.105.1560534923692; Fri, 14 Jun 2019 10:55:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534923; cv=none; d=google.com; s=arc-20160816; b=poZhhND54mitB2niZckQVWt+FRLZOgxL4bkzY2DHPwDhN5Ta7pRXtDE62564mP6oOf ZC52D/l01d7FcnqkL+2/HDXz2AGjs7Jg2LZcm6YqPERguxgjXq/NVBGP1xwGscdHw2PM JljNwfGI9RmrgINlv6Bred/9HKhxDjjSt7rw6AFLuUHMi+81fMylG127Fcq1dIbn0lrl 32b5rpaqcJWO2RCdpQFZz9RrxwLgwuwbgNcgItqOyJI6qoM47CiqKYvrunzYJomLwdS6 TJOE3gAQbyt0THcqiiihXuI5l8zmem+FR3pba4hWBd4FFxCq50kUlmP21/DwjkzeoZYz OVkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=zvCb0+Vr+zopZND2fzyVfHjYH7um2/patXC/Iy+jYqs=; b=aik1FjcqzPjg3I8JgVpcvKUNp+wcMaLEi3s5CuTWTlRrV+B/lC0wQwvb/zFqCdUkOk jPvMf1XMraL8cvGtT4eme8DZj5/EazbdUxDaQnME8z6BKXF740l+he7Wc/l8XZYSejKl hafs31xnHO4GofB3zNZYKijy37U3yAwaqDxHshRulU7PLnKP0OqRzrXNe6BCjjUzcVAZ xzvJGOc7yFACnG9BuZJpltVu5TfY4UQ4Vu7wxSQ/hCVI3m7ZV/PPiFsOQZA4g1sgOVWI vaDpbuH3zrqikOAT0pfLS8m3tl9KemuVhdk4il5vijKW7LjKdO+OeRdJHAhC/eG/qGn0 py8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h4si3050048pgs.269.2019.06.14.10.55.23; Fri, 14 Jun 2019 10:55:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727622AbfFNRzW (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:22 -0400 Received: from foss.arm.com ([217.140.110.172]:39612 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727326AbfFNRzU (ORCPT ); Fri, 14 Jun 2019 13:55:20 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D4175106F; Fri, 14 Jun 2019 10:55:19 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EC49C3F718; Fri, 14 Jun 2019 10:55:18 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, "David S. Miller" , Doug Ledford Subject: [PATCH v2 18/28] drivers: Introduce bus_find_device_by_fwnode() helper Date: Fri, 14 Jun 2019 18:54:13 +0100 Message-Id: <1560534863-15115-19-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a wrapper to bus_find_device() to search for a device by the fwnode pointer, reusing the generic match function. Also convert the existing users to make use of the new helper. Cc: "David S. Miller" Cc: Doug Ledford Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- drivers/base/devcon.c | 8 +------- drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 8 +------- drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 8 +------- include/linux/device.h | 12 ++++++++++++ 4 files changed, 15 insertions(+), 21 deletions(-) -- 2.7.4 diff --git a/drivers/base/devcon.c b/drivers/base/devcon.c index ac026d5..5a888eaa 100644 --- a/drivers/base/devcon.c +++ b/drivers/base/devcon.c @@ -107,19 +107,13 @@ static struct bus_type *generic_match_buses[] = { NULL, }; -static int device_fwnode_match(struct device *dev, const void *fwnode) -{ - return dev_fwnode(dev) == fwnode; -} - static void *device_connection_fwnode_match(struct device_connection *con) { struct bus_type *bus; struct device *dev; for (bus = generic_match_buses[0]; bus; bus++) { - dev = bus_find_device(bus, NULL, (void *)con->fwnode, - device_fwnode_match); + dev = bus_find_device_by_fwnode(bus, con->fwnode); if (dev && !strncmp(dev_name(dev), con->id, strlen(con->id))) return dev; diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c index 3afd3e9..6779b7d 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c @@ -4498,19 +4498,13 @@ static const struct acpi_device_id hns_roce_acpi_match[] = { }; MODULE_DEVICE_TABLE(acpi, hns_roce_acpi_match); -static int hns_roce_node_match(struct device *dev, const void *fwnode) -{ - return dev->fwnode == fwnode; -} - static struct platform_device *hns_roce_find_pdev(struct fwnode_handle *fwnode) { struct device *dev; /* get the 'device' corresponding to the matching 'fwnode' */ - dev = bus_find_device(&platform_bus_type, NULL, - fwnode, hns_roce_node_match); + dev = bus_find_device_by_fwnode(&platform_bus_type, fwnode); /* get the platform device */ return dev ? to_platform_device(dev) : NULL; } diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c index bb6586d..ed3829a 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c @@ -754,17 +754,11 @@ struct dsaf_misc_op *hns_misc_op_get(struct dsaf_device *dsaf_dev) return (void *)misc_op; } -static int hns_dsaf_dev_match(struct device *dev, const void *fwnode) -{ - return dev->fwnode == fwnode; -} - struct platform_device *hns_dsaf_find_platform_device(struct fwnode_handle *fwnode) { struct device *dev; - dev = bus_find_device(&platform_bus_type, NULL, - fwnode, hns_dsaf_dev_match); + dev = bus_find_device_by_fwnode(&platform_bus_type, fwnode); return dev ? to_platform_device(dev) : NULL; } diff --git a/include/linux/device.h b/include/linux/device.h index 35f51d6..576d84f 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -201,6 +201,18 @@ bus_find_device_by_of_node(struct bus_type *bus, const struct device_node *np) return bus_find_device(bus, NULL, np, device_match_of_node); } +/** + * bus_find_device_by_fwnode : device iterator for locating a particular device + * matching the fwnode. + * @bus: bus type + * @fwnode: fwnode of the device to match. + */ +static inline struct device * +bus_find_device_by_fwnode(struct bus_type *bus, const struct fwnode_handle *fwnode) +{ + return bus_find_device(bus, NULL, fwnode, device_match_fwnode); +} + struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id, struct device *hint); int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, From patchwork Fri Jun 14 17:54:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166894 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352952ilk; Fri, 14 Jun 2019 10:55:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzILDUILPxtO1k1/kSUInx4WNsi3ZKmeUWWL1krRFzecg4u9eqKcFQbJWMsYsODkT0mZ7y4 X-Received: by 2002:a65:408d:: with SMTP id t13mr36535208pgp.373.1560534926388; Fri, 14 Jun 2019 10:55:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534926; cv=none; d=google.com; s=arc-20160816; b=HSocisKyQPX+aR2CzeRXRl+zjweQBaPbPahGVqdQTmmJeEvQhXMZ3R3A7amF+F31UI sGW9B13fH3nwYXamrSXoC7C0yRtWi40dhhJ4zFHs0L+IXf19tcl5NUqReszoBhHsktjl Q61Lc4OA4FJkDUXRMYoc9AqsVbNBTOI+3QkGDyFXQGGtqHkhKGAMwdWr37J5D1SKsa6o dpcS8OPaRWddNWlXSHvgNjsLZVxumwdQut/X65DqehqRgZAEf+QIgk1JSC35rZf68des MIgSLpDrwBC5qondGCel5ZcGCIZGPUVBWXtsVLF23hso0KwWej4Wl+uPpxNItwA6a1th gkOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=HkRSe7byq8ac8wfHcV5q1yxa3h5hcwcUPG5gTTebTFg=; b=aC6ckCDsJV7UJnq9/dspfg6unYIgZ+a9O4Ko2LX+A2xVVtu/UJg+qIn7VQ/NVkv6Mt lqcPGv04KBFdZFCkxuyc69/pPBfr3gpFpp1JZ2fpCO+FG+ycHuislLdMnyTCSGkYQ0Q8 nR/2p7V9r7m4EY4L/+usq/vlHomb/UHrZP318Mven8ovF70qGFb+aC7O+/x222z/l4m/ sCbA3WCQqP3JPfcObtHtC8/R0YPu0Tbj3aU0EPQmMpQIQyAydq7JSes3ho4FS1sM2P9M 9gOAgeSGeBKsu4hUQ0tes5wVkwxD9aksEEsjH/SACv40o5YjJQL7FYA5gCuAdcsQHNNw kLzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9si3064713pfd.110.2019.06.14.10.55.26; Fri, 14 Jun 2019 10:55:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727662AbfFNRzY (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:24 -0400 Received: from foss.arm.com ([217.140.110.172]:39624 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727611AbfFNRzW (ORCPT ); Fri, 14 Jun 2019 13:55:22 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3124DCFC; Fri, 14 Jun 2019 10:55:21 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1358C3F718; Fri, 14 Jun 2019 10:55:19 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, linux-usb@vger.kernel.org, Oliver Neukum , Sebastian Andrzej Siewior , Alexander Shishkin Subject: [PATCH v2 19/28] drivers: Introduce bus_find_device_by_devt() helper Date: Fri, 14 Jun 2019 18:54:14 +0100 Message-Id: <1560534863-15115-20-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a wrapper to bus_find_device() to search for a device by the device type, reusing the generic match function. Also convert the existing users to make use of the new helper. Cc: linux-usb@vger.kernel.org Cc: Oliver Neukum Cc: Sebastian Andrzej Siewior Cc: Alexander Shishkin Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/intel_th/core.c | 10 +--------- drivers/usb/core/devio.c | 8 +------- include/linux/device.h | 12 ++++++++++++ 3 files changed, 14 insertions(+), 16 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c index 5592289..d5c1821 100644 --- a/drivers/hwtracing/intel_th/core.c +++ b/drivers/hwtracing/intel_th/core.c @@ -789,12 +789,6 @@ static int intel_th_populate(struct intel_th *th) return 0; } -static int match_devt(struct device *dev, const void *data) -{ - dev_t devt = (dev_t)(unsigned long)(void *)data; - return dev->devt == devt; -} - static int intel_th_output_open(struct inode *inode, struct file *file) { const struct file_operations *fops; @@ -802,9 +796,7 @@ static int intel_th_output_open(struct inode *inode, struct file *file) struct device *dev; int err; - dev = bus_find_device(&intel_th_bus, NULL, - (void *)(unsigned long)inode->i_rdev, - match_devt); + dev = bus_find_device_by_devt(&intel_th_bus, inode->i_rdev); if (!dev || !dev->driver) return -ENODEV; diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 7bd7de7..4e83623 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -947,17 +947,11 @@ static int parse_usbdevfs_streams(struct usb_dev_state *ps, return ret; } -static int match_devt(struct device *dev, const void *data) -{ - return dev->devt == (dev_t)(unsigned long)(void *)data; -} - static struct usb_device *usbdev_lookup_by_devt(dev_t devt) { struct device *dev; - dev = bus_find_device(&usb_bus_type, NULL, - (void *) (unsigned long) devt, match_devt); + dev = bus_find_device_by_devt(&usb_bus_type, devt); if (!dev) return NULL; return to_usb_device(dev); diff --git a/include/linux/device.h b/include/linux/device.h index 576d84f..3c244ac 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -213,6 +213,18 @@ bus_find_device_by_fwnode(struct bus_type *bus, const struct fwnode_handle *fwno return bus_find_device(bus, NULL, fwnode, device_match_fwnode); } +/** + * bus_find_device_by_devt : device iterator for locating a particular device + * matching the device type. + * @bus: bus type + * @devt: device type of the device to match. + */ +static inline struct device *bus_find_device_by_devt(struct bus_type *bus, + dev_t devt) +{ + return bus_find_device(bus, NULL, &devt, device_match_devt); +} + struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id, struct device *hint); int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, From patchwork Fri Jun 14 17:54:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166895 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2352982ilk; Fri, 14 Jun 2019 10:55:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/IROPwWYjqXsU5JqVc90RzWzEe4DPA8GJRrwHFGJM08kVKbw+Ch044xjRyDyRzI3YYidW X-Received: by 2002:a17:90b:d8a:: with SMTP id bg10mr12407797pjb.92.1560534929157; Fri, 14 Jun 2019 10:55:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534929; cv=none; d=google.com; s=arc-20160816; b=k/bLiPI1wFA5aRWVhAo83lx/RfUpO6fjUgEYTYDH2wfB5efaG6rVLA61mNkC5xBzdP iZx7quuX8UAPa5Vu/NIi1+SGoVCYkoNHLRjRScpO0xlxsYSjDwNl9/aBB2I9phBI1osg 5CAiXQUaufPSukEYDNzxgUhn06zooBz6bxUxDfpi6mc1E/ReidPI6E6zKOq5UJuuSJ1b 1n0Qx+YzDLJaXUswipzBGhCUHtji8N8poJFSNQ902yoxwvFZ18u8f3Gh/BiuXC9YKQYf NuwNdMSW6jwCU1bFmOnkodN2GeV/RpxaymoTVA8UC5DNl+mp/4M0cjj7L0n2eH8ViEf7 DnrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=9sfNlzy7aTx+2mkcDItYe5HTG3N5ZkRlrrK2epdYtZA=; b=aUAAwkgUc++mtGeP8qublZgk81QHU1cJq/Utsdyj3hLOJmyyIg7c2CtGO2wiabDsoc TUEuWpNssIbRBZ6zlhmODq7gLVh3XUy2cAw8pGUODymLNwII6gbaX2KfN97s3bcgfPpi 9ISxoiZ8SM2iQS/n507Vi8cHEORQRYmlGB0V1xZBubmQNukCIrDpBqhwMoPeaMw4o2De n3qz3hAeRSSjeHF2+k7dd/xQ2NPoBGHPEyEF6luGGyBKV2DNUgr3E1hppJIlueH7gOQ3 q27OGgX40jdKZUthD/fD3a9jtFGHVbNKt4seAFwSUrt98nB8aWSzNRAJ0fN95KbSLcN2 DbWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9si3064713pfd.110.2019.06.14.10.55.28; Fri, 14 Jun 2019 10:55:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727705AbfFNRz1 (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:27 -0400 Received: from foss.arm.com ([217.140.110.172]:39640 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727639AbfFNRzX (ORCPT ); Fri, 14 Jun 2019 13:55:23 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 677D53EF; Fri, 14 Jun 2019 10:55:22 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 64BB33F718; Fri, 14 Jun 2019 10:55:21 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Bjorn Helgaas , "James E.J. Bottomley" , "Martin K. Petersen" Subject: [PATCH v2 20/28] drivers: Introduce bus_find_next_device() helper Date: Fri, 14 Jun 2019 18:54:15 +0100 Message-Id: <1560534863-15115-21-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a wrapper for bus_find_device() to find the next devices on the given bus from the "start" device. Also convert the existing users to make use of the new helper. Cc: Bjorn Helgaas Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- drivers/pci/probe.c | 7 +------ drivers/scsi/scsi_proc.c | 9 ++------- include/linux/device.h | 10 ++++++++++ 3 files changed, 13 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index f9ef7ad..3504695 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -64,11 +64,6 @@ static struct resource *get_pci_domain_busn_res(int domain_nr) return &r->res; } -static int find_anything(struct device *dev, const void *data) -{ - return 1; -} - /* * Some device drivers need know if PCI is initiated. * Basically, we think PCI is not initiated when there @@ -79,7 +74,7 @@ int no_pci_devices(void) struct device *dev; int no_devices; - dev = bus_find_device(&pci_bus_type, NULL, NULL, find_anything); + dev = bus_find_next_device(&pci_bus_type, NULL); no_devices = (dev == NULL); put_device(dev); return no_devices; diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c index c074631..5b31322 100644 --- a/drivers/scsi/scsi_proc.c +++ b/drivers/scsi/scsi_proc.c @@ -372,15 +372,10 @@ static ssize_t proc_scsi_write(struct file *file, const char __user *buf, return err; } -static int always_match(struct device *dev, const void *data) -{ - return 1; -} - static inline struct device *next_scsi_device(struct device *start) { - struct device *next = bus_find_device(&scsi_bus_type, start, NULL, - always_match); + struct device *next = bus_find_next_device(&scsi_bus_type, start); + put_device(start); return next; } diff --git a/include/linux/device.h b/include/linux/device.h index 3c244ac..1c137ab 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -225,6 +225,16 @@ static inline struct device *bus_find_device_by_devt(struct bus_type *bus, return bus_find_device(bus, NULL, &devt, device_match_devt); } +/** + * bus_find_next_device - Find the next device after a given device in a + * given bus. + */ +static inline struct device * +bus_find_next_device(struct bus_type *bus,struct device *cur) +{ + return bus_find_device(bus, cur, NULL, device_match_any); +} + struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id, struct device *hint); int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, From patchwork Fri Jun 14 17:54:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166901 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2353293ilk; Fri, 14 Jun 2019 10:55:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1xwRWKwaULyXR2amviihoaIXVbe5JVB+b7LAQ6bmRfidqTm7e44vKpUIk7Tpu50JwNzPJ X-Received: by 2002:a63:cc4e:: with SMTP id q14mr36516742pgi.84.1560534948903; Fri, 14 Jun 2019 10:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534948; cv=none; d=google.com; s=arc-20160816; b=wix992diHY2aDrdAn3I3dJ9SHMPSqXMJ7FdtTp+XUwajCIAXiTB2/fszMGietYCCs3 eWYAXJh01M+0s0LBUAlztFXUaR2SM5uIXHhY+7TOUdxVin5xA/6c9RNjM1V+/MoIE2bs 96usDQHVb9OJpszj3rYwmQK+WI0Kak9+abbpQKp3WE0+YAxHTbXgD6BSqCuzA7bxwRiV d06LfOf5v96iByMTYrqUeaCOi/bKJsEFl7s4CrJnZ5wDefzEYliuvNZX3Od6P3WBvqlk 6HczTwPq2EUHMBYeTDamvFE1QVk9L9xmBqBol8RNLWA1JZOaTwMMSSo371dJ/jOvX379 B0lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=WQXkzum2t7zXlAlYFaVqaHaPQwSrqAnXUZrLxpCchOo=; b=on2FYEkaKic9I0PAZAM7gmS4XRFPhvSvovIMmeVqckOS4GiUSBIErkiIPm7yTKQ9bE UmGWMfxUouVBUl0gn53lxHVo1sJoh4I6V/pe/D/06zVKtjWs+os11XA1VSueqdPxMBTs tjOFnd5kj8xSGAT1ta0gYAw+8+jJY9KrFrGVO0GNm2poXva7XSQDYSkIQJFOCCaSWFuq tPG8NpOFadrby8/u5NcDHM0v1UXRO7mxyVbcjuC4/2Xw9a6r1djKPdPiE/v9IZ2EGpml hxCwDVuizYcjs9zQQZ0vng/hmFdwwgY1SkKtJUD4EAIqr6ESUZT5iY2TYIjevifk+Uqc cPzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v204si3133934pgb.80.2019.06.14.10.55.48; Fri, 14 Jun 2019 10:55:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727686AbfFNRz1 (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:27 -0400 Received: from foss.arm.com ([217.140.110.172]:39656 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727655AbfFNRzY (ORCPT ); Fri, 14 Jun 2019 13:55:24 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B8A45D6E; Fri, 14 Jun 2019 10:55:23 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9AF603F718; Fri, 14 Jun 2019 10:55:22 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Mika Westerberg , Wolfram Sang , linux-i2c@vger.kernel.org, Mark Brown Subject: [PATCH v2 21/28] drivers: Introduce bus_find_device_by_acpi_dev() helper Date: Fri, 14 Jun 2019 18:54:16 +0100 Message-Id: <1560534863-15115-22-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a wrapper to bus_find_device() to search for a device by the ACPI COMPANION device, reusing the generic match function. Also convert the existing users to make use of the new helper. Cc: Mika Westerberg Cc: Wolfram Sang Cc: linux-i2c@vger.kernel.org Cc: Mark Brown Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- drivers/i2c/i2c-core-acpi.c | 8 +------- drivers/spi/spi.c | 8 +------- include/linux/device.h | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+), 14 deletions(-) -- 2.7.4 diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index 8af35f11..7c6435c 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -328,11 +328,6 @@ static int i2c_acpi_find_match_adapter(struct device *dev, const void *data) return ACPI_HANDLE(dev) == (acpi_handle)data; } -static int i2c_acpi_find_match_device(struct device *dev, const void *data) -{ - return ACPI_COMPANION(dev) == data; -} - static struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle) { struct device *dev; @@ -346,8 +341,7 @@ static struct i2c_client *i2c_acpi_find_client_by_adev(struct acpi_device *adev) { struct device *dev; - dev = bus_find_device(&i2c_bus_type, NULL, adev, - i2c_acpi_find_match_device); + dev = bus_find_device_by_acpi_dev(&i2c_bus_type, adev); return dev ? i2c_verify_client(dev) : NULL; } diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index cc4d83e..8737d69 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -3627,11 +3627,6 @@ static int spi_acpi_controller_match(struct device *dev, const void *data) return ACPI_COMPANION(dev->parent) == data; } -static int spi_acpi_device_match(struct device *dev, const void *data) -{ - return ACPI_COMPANION(dev) == data; -} - static struct spi_controller *acpi_spi_find_controller_by_adev(struct acpi_device *adev) { struct device *dev; @@ -3651,8 +3646,7 @@ static struct spi_device *acpi_spi_find_device_by_adev(struct acpi_device *adev) { struct device *dev; - dev = bus_find_device(&spi_bus_type, NULL, adev, spi_acpi_device_match); - + dev = bus_find_device_by_acpi_dev(&spi_bus_type, adev); return dev ? to_spi_device(dev) : NULL; } diff --git a/include/linux/device.h b/include/linux/device.h index 1c137ab..6768e2b 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -235,6 +235,28 @@ bus_find_next_device(struct bus_type *bus,struct device *cur) return bus_find_device(bus, cur, NULL, device_match_any); } +#ifdef CONFIG_ACPI +struct acpi_device; + +/** + * bus_find_device_by_acpi_dev : device iterator for locating a particular device + * matching the ACPI COMPANION device. + * @bus: bus type + * @adev: ACPI COMPANION device to match. + */ +static inline struct device * +bus_find_device_by_acpi_dev(struct bus_type *bus, const struct acpi_device *adev) +{ + return bus_find_device(bus, NULL, adev, device_match_acpi_dev); +} +#else +static inline struct device * +bus_find_device_by_acpi_dev(struct bus_type *bus, const void *adev) +{ + return NULL; +} +#endif + struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id, struct device *hint); int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, From patchwork Fri Jun 14 17:54:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166902 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2353365ilk; Fri, 14 Jun 2019 10:55:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAVTeX5VO7UNVWBwAPOuRXRRab+YGKy9xzGx4EvpNggjc/NQ+5AsCnUxq1dqBhcQD5iYsg X-Received: by 2002:a62:1c92:: with SMTP id c140mr100273482pfc.258.1560534953699; Fri, 14 Jun 2019 10:55:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534953; cv=none; d=google.com; s=arc-20160816; b=AffrKtoWAbqKZL7HVLSKmh7109KtWksWU8Zpz9Q2/jAB9m249VpDh79OB24ttnM6v2 9NzU0PjbHbRP6vB5r4LsvWyxA7iI3H/fmB7hhM3wgI99/fC0vTsaUuHDq64vVcXh3R52 lRawvPaWsURBMr+WQMHdMYMb1lD1oFPqBsCeRRP3E2huSgfajQ5ZElSrRPJDqZIEDZ7A AZDuLhAZofXUwiLDjEs4WLrCY6UMZxMgXYdcgG0L2Iem8Ib+AD5EsKj9HsvWhJzVPjiG FvdCYxRCQs6uMKSAe1LkIYUhpfXq7ZTLmICvbyvizEegPgoFrlWGCo14Mg8fvwnMToC9 ybaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=nZzR5D/cF3amy0YKwfz7bRoj8p/i7dESOAEszHYSDoo=; b=sZAxtwIp7LV8Djr/PdXVo9UVxLDCA4Nx581EMIdgqpgfUVYHle1X87xx10GLQ+V1zm AI/UyCRBhj4JyNpvsUx3XMm92UM6c4bIWqeVNse85E3K2mSwQl0igfF1GPsj/yneV9b1 mueXMAgOAGee0jx22Omb++mw284LPgWZIIqdxxnyKMuLcC3E6PvRg28bqu3Cx7ALDr3w KHDh3GL2AykDaEWtFn/UHdM5+VnJM4A4A7GLtXooc/DgMj4+YuXrUfwndNr6tXQu3RAw 3gBI24EOQG6DEyIKn/cK5TtIqPVgT7NHG+Tc7CUhak4g0aSSo62Ry+trOQSjwrMRGlqb g/xw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t24si3143658pgm.502.2019.06.14.10.55.53; Fri, 14 Jun 2019 10:55:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727208AbfFNRzw (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:52 -0400 Received: from foss.arm.com ([217.140.110.172]:39668 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727611AbfFNRz0 (ORCPT ); Fri, 14 Jun 2019 13:55:26 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1686F11B3; Fri, 14 Jun 2019 10:55:25 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EC39D3F718; Fri, 14 Jun 2019 10:55:23 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Lee Jones , Arnd Bergmann , Heiko Carstens , Peter Oberparleiter Subject: [PATCH v2 22/28] drivers: Introduce driver_find_device_by_name() helper Date: Fri, 14 Jun 2019 18:54:17 +0100 Message-Id: <1560534863-15115-23-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a wrapper to driver_find_device() to search for a device by name, similar to the other iterators, reusing the generic match function. Also convert the existing users to make use of the new helper. Cc: Lee Jones Cc: Arnd Bergmann Cc: Heiko Carstens Cc: Peter Oberparleiter Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- drivers/s390/cio/ccwgroup.c | 10 +--------- drivers/s390/cio/device.c | 17 +---------------- include/linux/device.h | 12 ++++++++++++ 3 files changed, 14 insertions(+), 25 deletions(-) -- 2.7.4 diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c index ea176157..d843e36 100644 --- a/drivers/s390/cio/ccwgroup.c +++ b/drivers/s390/cio/ccwgroup.c @@ -608,13 +608,6 @@ void ccwgroup_driver_unregister(struct ccwgroup_driver *cdriver) } EXPORT_SYMBOL(ccwgroup_driver_unregister); -static int __ccwgroupdev_check_busid(struct device *dev, const void *id) -{ - char *bus_id = id; - - return (strcmp(bus_id, dev_name(dev)) == 0); -} - /** * get_ccwgroupdev_by_busid() - obtain device from a bus id * @gdrv: driver the device is owned by @@ -631,8 +624,7 @@ struct ccwgroup_device *get_ccwgroupdev_by_busid(struct ccwgroup_driver *gdrv, { struct device *dev; - dev = driver_find_device(&gdrv->driver, NULL, bus_id, - __ccwgroupdev_check_busid); + dev = driver_find_device_by_name(&gdrv->driver, bus_id); return dev ? to_ccwgroupdev(dev) : NULL; } diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index f27536b..df29d7e 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c @@ -1649,20 +1649,6 @@ int ccw_device_force_console(struct ccw_device *cdev) EXPORT_SYMBOL_GPL(ccw_device_force_console); #endif -/* - * get ccw_device matching the busid, but only if owned by cdrv - */ -static int -__ccwdev_check_busid(struct device *dev, const void *id) -{ - char *bus_id; - - bus_id = id; - - return (strcmp(bus_id, dev_name(dev)) == 0); -} - - /** * get_ccwdev_by_busid() - obtain device from a bus id * @cdrv: driver the device is owned by @@ -1679,8 +1665,7 @@ struct ccw_device *get_ccwdev_by_busid(struct ccw_driver *cdrv, { struct device *dev; - dev = driver_find_device(&cdrv->driver, NULL, (void *)bus_id, - __ccwdev_check_busid); + dev = driver_find_device_by_name(&cdrv->driver, bus_id); return dev ? to_ccwdev(dev) : NULL; } diff --git a/include/linux/device.h b/include/linux/device.h index 6768e2b..0d3958e 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -425,6 +425,18 @@ struct device *driver_find_device(struct device_driver *drv, struct device *start, const void *data, int (*match)(struct device *dev, const void *data)); +/** + * driver_find_device_by_name - device iterator for locating a particular device + * of a specific name. + * @driver: the driver we're iterating + * @name: name of the device to match + */ +static inline struct device *driver_find_device_by_name(struct device_driver *drv, + const char *name) +{ + return driver_find_device(drv, NULL, name, device_match_name); +} + void driver_deferred_probe_add(struct device *dev); int driver_deferred_probe_check_state(struct device *dev); From patchwork Fri Jun 14 17:54:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166903 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2353420ilk; Fri, 14 Jun 2019 10:55:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1OO3Jir2MNbFBVDxfooR2aVxsxqK5gmjQmGoWsm0qdEMg/bGQsS9SYjSgGuUM+nFd847r X-Received: by 2002:a17:902:2a6b:: with SMTP id i98mr9687250plb.75.1560534957613; Fri, 14 Jun 2019 10:55:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534957; cv=none; d=google.com; s=arc-20160816; b=riwaQxJS3EIZSzuEPC7zhX1ZbcM3UTu5kM/jsqFwGFnFYLwPWGc6W1vF5Xgf4vfd65 HZ20elNSoq9zgZzsJHc/a2zSnz7iIibWg9K2cef+qwfS+v6c1XvTDMcM8xbug4BzkQcY 2RHMStGouFNg6BR6fnu6MmqRAUbtAjqE/+HQvWDwqnci4jIHgSPhHwgs7TogMIPzzdWX VIa1C4svWr/CznFbVDGBGX6GUTYgr3FeeXMjOP98YZz4ccUiorWSyMxJHYSDIZAug48v ctoCgwXxvCPDP1yAa0CnctD6HBnK+SQppTEUQUsKPSO+d1KBsBzx2XnB9FdM3G7du9Y+ 2b7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=vSetV/954vHFstIkRtuzO6E0HcW4CdkezyXXO8JEOqM=; b=jjhJ/cuaXu4aLMBfaZcoMTvwTqTz7bT/SWULCB+UGOKiO8VLH0J/RPAfTVI5eKSGQA rbZQ2Kf+z/HKYO47cDqLfYsEycWDUl6v41q7LFw8RatK/pmAPPb1VVU3QnLWBKEN7HFP cRcY7qw6dP6K+X6yqiPzZJMVdV5bzJJXxfgmOOJISIOAqon4hj3luzu8eiE38uqC/78j zhWx1Fe0mLCPLmXqUzH4l3TqtFf3ud82Mq3VoeriTSR9tZYGtlEeEU8Z0JPPJNjkKoiq s4n8pPsa465MOwsgbQHlz/ZsD8glupDas6k7OCdq49NPc1S3Qo39m1FPtM6QxSEE/YiQ ZiGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t24si3143658pgm.502.2019.06.14.10.55.57; Fri, 14 Jun 2019 10:55:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727805AbfFNRzu (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:50 -0400 Received: from foss.arm.com ([217.140.110.172]:39682 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727675AbfFNRz0 (ORCPT ); Fri, 14 Jun 2019 13:55:26 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 318493EF; Fri, 14 Jun 2019 10:55:26 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 49C813F718; Fri, 14 Jun 2019 10:55:25 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Lee Jones , Thor Thayer Subject: [PATCH v2 23/28] drivers: Introduce driver_find_device_by_of_node() helper Date: Fri, 14 Jun 2019 18:54:18 +0100 Message-Id: <1560534863-15115-24-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a wrapper to driver_find_device() to search for a device by the of_node pointer, reusing the generic match function. Also convert the existing users to make use of the new helper. Cc: Lee Jones Cc: Thor Thayer Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Acked-by: Thor Thayer Signed-off-by: Suzuki K Poulose --- drivers/amba/tegra-ahb.c | 11 +---------- drivers/mfd/altera-sysmgr.c | 14 ++------------ include/linux/device.h | 13 +++++++++++++ 3 files changed, 16 insertions(+), 22 deletions(-) -- 2.7.4 diff --git a/drivers/amba/tegra-ahb.c b/drivers/amba/tegra-ahb.c index aa64eec..57d3b2e 100644 --- a/drivers/amba/tegra-ahb.c +++ b/drivers/amba/tegra-ahb.c @@ -134,22 +134,13 @@ static inline void gizmo_writel(struct tegra_ahb *ahb, u32 value, u32 offset) } #ifdef CONFIG_TEGRA_IOMMU_SMMU -static int tegra_ahb_match_by_smmu(struct device *dev, const void *data) -{ - struct tegra_ahb *ahb = dev_get_drvdata(dev); - const struct device_node *dn = data; - - return (ahb->dev->of_node == dn) ? 1 : 0; -} - int tegra_ahb_enable_smmu(struct device_node *dn) { struct device *dev; u32 val; struct tegra_ahb *ahb; - dev = driver_find_device(&tegra_ahb_driver.driver, NULL, dn, - tegra_ahb_match_by_smmu); + dev = driver_find_device_by_of_node(&tegra_ahb_driver.driver, dn); if (!dev) return -EPROBE_DEFER; ahb = dev_get_drvdata(dev); diff --git a/drivers/mfd/altera-sysmgr.c b/drivers/mfd/altera-sysmgr.c index 2ee14d8..d2a13a5 100644 --- a/drivers/mfd/altera-sysmgr.c +++ b/drivers/mfd/altera-sysmgr.c @@ -88,16 +88,6 @@ static struct regmap_config altr_sysmgr_regmap_cfg = { }; /** - * sysmgr_match_phandle - * Matching function used by driver_find_device(). - * Return: True if match is found, otherwise false. - */ -static int sysmgr_match_phandle(struct device *dev, const void *data) -{ - return dev->of_node == (const struct device_node *)data; -} - -/** * altr_sysmgr_regmap_lookup_by_phandle * Find the sysmgr previous configured in probe() and return regmap property. * Return: regmap if found or error if not found. @@ -117,8 +107,8 @@ struct regmap *altr_sysmgr_regmap_lookup_by_phandle(struct device_node *np, if (!sysmgr_np) return ERR_PTR(-ENODEV); - dev = driver_find_device(&altr_sysmgr_driver.driver, NULL, - (void *)sysmgr_np, sysmgr_match_phandle); + dev = driver_find_device_by_of_node(&altr_sysmgr_driver.driver, + (void *)sysmgr_np); of_node_put(sysmgr_np); if (!dev) return ERR_PTR(-EPROBE_DEFER); diff --git a/include/linux/device.h b/include/linux/device.h index 0d3958e..f929671 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -437,6 +437,19 @@ static inline struct device *driver_find_device_by_name(struct device_driver *dr return driver_find_device(drv, NULL, name, device_match_name); } +/** + * driver_find_device_by_of_node- device iterator for locating a particular device + * by of_node pointer. + * @driver: the driver we're iterating + * @np: of_node pointer to match. + */ +static inline struct device * +driver_find_device_by_of_node(struct device_driver *drv, + const struct device_node *np) +{ + return driver_find_device(drv, NULL, np, device_match_of_node); +} + void driver_deferred_probe_add(struct device *dev); int driver_deferred_probe_check_state(struct device *dev); From patchwork Fri Jun 14 17:54:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166896 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2353015ilk; Fri, 14 Jun 2019 10:55:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvjKrbiG8k9uJ8wBHZneucIrBXbIUntFZYSW2Hoz8gG7Th8CtlsHCY9x8rsXXpzW9t3vlo X-Received: by 2002:a17:902:6a4:: with SMTP id 33mr92691003plh.338.1560534931366; Fri, 14 Jun 2019 10:55:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534931; cv=none; d=google.com; s=arc-20160816; b=D2OCcRB4Im3oynmo3EL3BVuUx/FyMJ9HBMzbjcocZYNzHPY1GISWWktHvm8GICaWsd xHgiydmkjzfcO5K1oc9RY7WmGukuLQLVUE6RTTjNuVRarjFgu9uof0Dxu5r3lpJCsl4A N8m9+Jpb73yvxAIG8XuhkzHETiRSWanfU/T6ZNVG3q09CI3jtNBozqIX93+M5+ziNJAS ya2itFYJlbGQ0631aJPc9WfDrPJttkkFdH8SQqrC8jV/61rhAnl1vwLPrynVAvHHGOnQ wrle6wX73Zn87DSHsOoX/Ty0M0brwFD50lF+Oh0xrh3rxnseRf22UdZciLna5GNWwqjR +Yhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=lz4DU0OJwe3BiALHT7jkeYZIdJRvt6nZpNaxC/3oo5c=; b=VNXfDzPkVuwLCimGqxNN0rdoI/rSSv7WP7gHInCkf6/419a4axXPvR2IXzl86DmTll brH0lYB1dz8RE/eWOHUye8uJaiyGUWTjObziWJWlrxTZBGu3U5LIYi9JEiUjrYqh9mD0 HRiXoYhulUPCGWHtCBI7hh+ioaD8sqodfVUdiID+b/yJfupC6k/RFmyNkRtz+Oy5x5pR JFShR5TkM/TmVciR6tO6l/RyFudY+dJSy3LBDN4eiA5ANNuCaQ70ozgXh4XtZ/P/6sVq JvvpFRfdoTE7SsaLTZDTuB5ooqYCHXGfnKeunKKWkvMpwkVrTuaGf8NeyZwSbhGChU8F oPiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f69si2888095pjg.43.2019.06.14.10.55.31; Fri, 14 Jun 2019 10:55:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727722AbfFNRz3 (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:29 -0400 Received: from foss.arm.com ([217.140.110.172]:39694 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727700AbfFNRz1 (ORCPT ); Fri, 14 Jun 2019 13:55:27 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 67A60D6E; Fri, 14 Jun 2019 10:55:27 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 64D113F718; Fri, 14 Jun 2019 10:55:26 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Will Deacon , Robin Murphy , Joerg Roedel Subject: [PATCH v2 24/28] drivers: Introduce driver_find_device_by_fwnode() helper Date: Fri, 14 Jun 2019 18:54:19 +0100 Message-Id: <1560534863-15115-25-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a wrapper to driver_find_device() to search for a device by the fwnode pointer, reusing the generic match function. Also convert the existing users to make use of the new helper. Cc: Will Deacon Cc: Robin Murphy Cc: Joerg Roedel Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- drivers/iommu/arm-smmu-v3.c | 9 ++------- drivers/iommu/arm-smmu.c | 9 ++------- include/linux/device.h | 13 +++++++++++++ 3 files changed, 17 insertions(+), 14 deletions(-) -- 2.7.4 diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index d787856..6b956a03 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -2023,16 +2023,11 @@ arm_smmu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova) static struct platform_driver arm_smmu_driver; -static int arm_smmu_match_node(struct device *dev, const void *data) -{ - return dev->fwnode == data; -} - static struct arm_smmu_device *arm_smmu_get_by_fwnode(struct fwnode_handle *fwnode) { - struct device *dev = driver_find_device(&arm_smmu_driver.driver, NULL, - fwnode, arm_smmu_match_node); + struct device *dev = driver_find_device_by_fwnode(&arm_smmu_driver.driver, + fwnode); put_device(dev); return dev ? dev_get_drvdata(dev) : NULL; } diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 3af579a..0d63a9e 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1419,16 +1419,11 @@ static bool arm_smmu_capable(enum iommu_cap cap) } } -static int arm_smmu_match_node(struct device *dev, const void *data) -{ - return dev->fwnode == data; -} - static struct arm_smmu_device *arm_smmu_get_by_fwnode(struct fwnode_handle *fwnode) { - struct device *dev = driver_find_device(&arm_smmu_driver.driver, NULL, - fwnode, arm_smmu_match_node); + struct device *dev = driver_find_device_by_fwnode(&arm_smmu_driver.driver, + fwnode); put_device(dev); return dev ? dev_get_drvdata(dev) : NULL; } diff --git a/include/linux/device.h b/include/linux/device.h index f929671..2cf49f7 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -450,6 +450,19 @@ driver_find_device_by_of_node(struct device_driver *drv, return driver_find_device(drv, NULL, np, device_match_of_node); } +/** + * driver_find_device_by_fwnode- device iterator for locating a particular device + * by fwnode pointer. + * @driver: the driver we're iterating + * @fwnode: fwnode pointer to match. + */ +static inline struct device * +driver_find_device_by_fwnode(struct device_driver *drv, + const struct fwnode_handle *fwnode) +{ + return driver_find_device(drv, NULL, fwnode, device_match_fwnode); +} + void driver_deferred_probe_add(struct device *dev); int driver_deferred_probe_check_state(struct device *dev); From patchwork Fri Jun 14 17:54:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166900 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2353214ilk; Fri, 14 Jun 2019 10:55:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMMGlUs6Vlulzxsj7EMc9jHwiVaJlhtl76xESfaCFwf3RGhmPOqPo6dcgMpcHy4FLr9ysp X-Received: by 2002:a17:90a:aa0d:: with SMTP id k13mr11691671pjq.53.1560534943794; Fri, 14 Jun 2019 10:55:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534943; cv=none; d=google.com; s=arc-20160816; b=gRs1v2Gi09uemH9UrEiu0Ob3i1Z9UjsnNuyeFkHsgo7dKvlzxxrlr7pQVkyC97zE/T 9WCCrqjkn41d9jApPNR1NJO8NHqst76NXWKBagwk/u4dUyDBjRWXn8KymRshgbLoQkfJ 6LGtJDsY3DaNiexi8gjcejvNqIuFBGUZ0ZTHYaPHToYuCB492/zjdoS1uxIdLmVYz7oX Y3rvRmqUrAFfV8wMabVRHKFvpr+AJezBDQSNoDINfUaeVdDedtDVGBx7MCPVOOe4M7XA QKHZsaw/FNzTIHiArAet+ipkFgUESD2DjFcw9aBX4QntqXgmeTFb1SSveJ+Ypasz+xje 5ntA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=bdhbIHED1qJJrUzfoe4QyRezW1w6cANL/6hbJSWjxJg=; b=CWlBXpxrUBvJiZ8OoyxeRdBAcWCvZKYLfbKvIOzKShsZmSRyMMYoDNXrY3Vzxu3327 BLjEMsugDOhCDU71Oy6VimcxWnnSSrCdvASnIBt9+M4bg0QaUZix/EkNZZBtdTYd8s0y 9Ns0fsd+3PpriSKCSo16O0Vy8jR8Og/7z/BywQuAOeq8xCpCzk5CRPgxRCk2mJeLKiW/ oeJwdh5hxSFhWlMkyvGbdsWeOykG27N8brNy1s+A4mp9AhTVrwuHZcBJVfaO6SPCVrp9 GhOAPd4SfRK8ap16ctBbKIC4P26UpQno4j2J83FUzn3wLCU63oPIOrEf5AyOImPHG+s9 NEhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v204si3133934pgb.80.2019.06.14.10.55.43; Fri, 14 Jun 2019 10:55:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727351AbfFNRzm (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:42 -0400 Received: from foss.arm.com ([217.140.110.172]:39702 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727715AbfFNRz2 (ORCPT ); Fri, 14 Jun 2019 13:55:28 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 555EECFC; Fri, 14 Jun 2019 10:55:28 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9AB0D3F718; Fri, 14 Jun 2019 10:55:27 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com Subject: [PATCH v2 25/28] drivers: Introduce driver_find_device_by_devt() helper Date: Fri, 14 Jun 2019 18:54:20 +0100 Message-Id: <1560534863-15115-26-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a wrapper to driver_find_device() to search for a device by the device type, reusing the generic match function. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- include/linux/device.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.7.4 diff --git a/include/linux/device.h b/include/linux/device.h index 2cf49f7..f7f6a43 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -463,6 +463,18 @@ driver_find_device_by_fwnode(struct device_driver *drv, return driver_find_device(drv, NULL, fwnode, device_match_fwnode); } +/** + * driver_find_device_by_devt- device iterator for locating a particular device + * by devt. + * @driver: the driver we're iterating + * @devt: devt pointer to match. + */ +static inline struct device *driver_find_device_by_devt(struct device_driver *drv, + dev_t devt) +{ + return driver_find_device(drv, NULL, &devt, device_match_devt); +} + void driver_deferred_probe_add(struct device *dev); int driver_deferred_probe_check_state(struct device *dev); From patchwork Fri Jun 14 17:54:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166897 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2353053ilk; Fri, 14 Jun 2019 10:55:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKW9rQo37XLnyJ0Dm28VLW7VWQ2b5w+IlaMMRBPE0pgXksm0kJoggsantc/UtnPiBpNK8K X-Received: by 2002:a63:3148:: with SMTP id x69mr22046008pgx.226.1560534933708; Fri, 14 Jun 2019 10:55:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534933; cv=none; d=google.com; s=arc-20160816; b=qfkiGjRl+G88qXfxOHMYzT7srtwfoM4lYXUVGVuMUVFkW5mGnJsIQqi9vdZqD8+NC9 jv64O1nudJ4XoNc1if+drwPUFlsHdG5RD9kkjX9qtbo+frTFc1fhWKQdkyHl4PxEXvOe 52GmRyFp7N2z4qaLdSu5hHhP14kIKvKytAVwW/ORZQS61K2xTAso0xtd1kFKa4MIebwr ZhvszhVGGr4wlfXkOwEZ1tilHclKSlxByhgU+9/TF4uATAfNXGZym/eduCOktHMSmp3w AuHACBBqJ18ZTSeXjRSyQcXAAV6eIcMW/GTrnwBdTEw9Zylkx2fmnHLNcT9fGWaMfjGX +jMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=OIRFityxyPuE3q+Zg6zeunHcVDeFB+t5cGCSH7owJx0=; b=NJRR/p93SaO79B5DlNZRcv13GdbMFJUE7K2FQxrQahAfVHaSBTyv7LMteztv+8f9tX dgmGhErH5Y/wQdhDGIqSgltBL5MbobcwvqxY2yJQQ7RASDbjGDh52JTENGBitmwwXnw5 8DnnFLWkb2bGBzSsZnCYC3BsB5kUJZYFOLkl45iAN/DeAfPzIEvL2A71ee9fk0CJamQ5 gnQrymmxXbFz5p9BRBK5yUmP+KlvDIJ3mcqRaVBN9UuFgK4+wUmNYxWj9uYg+ZYyltHv FtrCyJf2+OtEOQb3wp0ot5SrvaDoaD8cLpBLWG1emDWqmj4k1/KO8CnDmNfU5NGSl72b 2Jzw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f69si2888095pjg.43.2019.06.14.10.55.33; Fri, 14 Jun 2019 10:55:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726800AbfFNRzc (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:32 -0400 Received: from foss.arm.com ([217.140.110.172]:39710 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727700AbfFNRza (ORCPT ); Fri, 14 Jun 2019 13:55:30 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8BDD03EF; Fri, 14 Jun 2019 10:55:29 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 88F823F718; Fri, 14 Jun 2019 10:55:28 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Elie Morisse , Nehal Shah , Shyam Sundar S K Subject: [PATCH v2 26/28] drivers: Introduce driver_find_next_device() helper Date: Fri, 14 Jun 2019 18:54:21 +0100 Message-Id: <1560534863-15115-27-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a wrapper for driver_find_device() to find the next device for a given driver from the "start" device. Also convert the existing users to make use of the new helper. Cc: Elie Morisse Cc: Nehal Shah Cc: Shyam Sundar S K Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- drivers/i2c/busses/i2c-amd-mp2-pci.c | 8 +------- drivers/s390/cio/ccwgroup.c | 8 +------- include/linux/device.h | 6 ++++++ 3 files changed, 8 insertions(+), 14 deletions(-) -- 2.7.4 diff --git a/drivers/i2c/busses/i2c-amd-mp2-pci.c b/drivers/i2c/busses/i2c-amd-mp2-pci.c index c7fe3b4..5e4800d 100644 --- a/drivers/i2c/busses/i2c-amd-mp2-pci.c +++ b/drivers/i2c/busses/i2c-amd-mp2-pci.c @@ -457,18 +457,12 @@ static struct pci_driver amd_mp2_pci_driver = { }; module_pci_driver(amd_mp2_pci_driver); -static int amd_mp2_device_match(struct device *dev, const void *data) -{ - return 1; -} - struct amd_mp2_dev *amd_mp2_find_device(void) { struct device *dev; struct pci_dev *pci_dev; - dev = driver_find_device(&amd_mp2_pci_driver.driver, NULL, NULL, - amd_mp2_device_match); + dev = driver_find_next_device(&amd_mp2_pci_driver.driver, NULL); if (!dev) return NULL; diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c index d843e36..0005ec9 100644 --- a/drivers/s390/cio/ccwgroup.c +++ b/drivers/s390/cio/ccwgroup.c @@ -581,11 +581,6 @@ int ccwgroup_driver_register(struct ccwgroup_driver *cdriver) } EXPORT_SYMBOL(ccwgroup_driver_register); -static int __ccwgroup_match_all(struct device *dev, const void *data) -{ - return 1; -} - /** * ccwgroup_driver_unregister() - deregister a ccw group driver * @cdriver: driver to be deregistered @@ -597,8 +592,7 @@ void ccwgroup_driver_unregister(struct ccwgroup_driver *cdriver) struct device *dev; /* We don't want ccwgroup devices to live longer than their driver. */ - while ((dev = driver_find_device(&cdriver->driver, NULL, NULL, - __ccwgroup_match_all))) { + while ((dev = driver_find_next_device(&cdriver->driver, NULL))) { struct ccwgroup_device *gdev = to_ccwgroupdev(dev); ccwgroup_ungroup(gdev); diff --git a/include/linux/device.h b/include/linux/device.h index f7f6a43..77f817d 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -475,6 +475,12 @@ static inline struct device *driver_find_device_by_devt(struct device_driver *dr return driver_find_device(drv, NULL, &devt, device_match_devt); } +static inline struct device *driver_find_next_device(struct device_driver *drv, + struct device *start) +{ + return driver_find_device(drv, start, NULL, device_match_any); +} + void driver_deferred_probe_add(struct device *dev); int driver_deferred_probe_check_state(struct device *dev); From patchwork Fri Jun 14 17:54:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166899 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2353136ilk; Fri, 14 Jun 2019 10:55:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvKvqBKQIWwpaPkl4yJeCJC2+X5uquXSBloruwX0X4rIS4MRvkF34M68foN53OqZsuNmAL X-Received: by 2002:a17:90a:b296:: with SMTP id c22mr12718686pjr.28.1560534939459; Fri, 14 Jun 2019 10:55:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534939; cv=none; d=google.com; s=arc-20160816; b=rwOMgrnzRWW3zveKzgiZDygjT/Z2yht7LlZAnba3us8rniSeKcTg4JGgDY51cxpdZe e9betWMr5Qbe6uOTn5mtp4nnLQInHPkrKN/8LfzEVIirujAfTDAGCXpRGT8GvHwQCXb/ JDDAgb7hJMplzzTk+kMelk7wVn1YCxZeuptRoKa8SNisQBEKrvh19g65e7wWCHEHZAfC 5LRDG2aL5yIztlxwhsT7EBJ4xsMTzfju97D1K4jXuyxiT98hSSkMh59S/ZYzW39GB6EC tBrRh7fltjULBGbl3ut8yZp44pdNCvRS4PkiqNNrsXLUpbbPqJ3tCt9rnqtOpG4rSulB rBvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=5EsNvNsiV1dmZv/FdlLYAZ6gZbdnKgb0t8sdcrvxhxM=; b=zmsVXoGANcp45nWEu+15uiFwTS47JGehCgf5/Caa19YRYPh2TLnv0zFORaFmPtYs9U +j+4ehmM8J9eA6gccNRp/f8HXkfnCvy2rvtlyUByIIKpMnH0LJ2oo/ux+Wv5uxnP9uzI 1wxd3YCAQOIvRN5O2ElQr5HODhGjSXiBoLnX0ABu6IDlQmQnCr6tsYKLrx6GWCU1lPE8 O0hmFuq4j+ZQ4H/PnWPYS5sEnDXu3TPXgfUieCFW/9ol390QXY3BoyWelXbEU+0yTL2s InDl9x+07kgijrbNFOT3RpnguuYlVhxD/a+EdwpNW1eAXz/x00+6RC6GiD9CvAyuL6jG zLAQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a1si3162354pgj.143.2019.06.14.10.55.39; Fri, 14 Jun 2019 10:55:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727777AbfFNRzh (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:37 -0400 Received: from foss.arm.com ([217.140.110.172]:39722 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727727AbfFNRza (ORCPT ); Fri, 14 Jun 2019 13:55:30 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 70D63D6E; Fri, 14 Jun 2019 10:55:30 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BF1EA3F718; Fri, 14 Jun 2019 10:55:29 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com Subject: [PATCH v2 27/28] drivers: Introduce driver_find_device_by_acpi_dev() helper Date: Fri, 14 Jun 2019 18:54:22 +0100 Message-Id: <1560534863-15115-28-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a wrapper to driver_find_device() to search for a device by the ACPI COMPANION device, reusing the generic match function. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Suzuki K Poulose --- include/linux/device.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) -- 2.7.4 diff --git a/include/linux/device.h b/include/linux/device.h index 77f817d..a2a8ac2 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -481,6 +481,27 @@ static inline struct device *driver_find_next_device(struct device_driver *drv, return driver_find_device(drv, start, NULL, device_match_any); } +#ifdef CONFIG_ACPI +/** + * driver_find_device_by_acpi_dev : device iterator for locating a particular + * device matching the ACPI_COMPANION device. + * @driver: the driver we're iterating + * @adev: ACPI_COMPANION device to match. + */ +static inline struct device * +driver_find_device_by_acpi_dev(struct device_driver *drv, + const struct acpi_device *adev) +{ + return driver_find_device(drv, NULL, adev, device_match_acpi_dev); +} +#else +static inline struct device * +driver_find_device_by_acpi_dev(struct device_driver *drv, const void *adev) +{ + return NULL; +} +#endif + void driver_deferred_probe_add(struct device *dev); int driver_deferred_probe_check_state(struct device *dev); From patchwork Fri Jun 14 17:54:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 166898 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2353091ilk; Fri, 14 Jun 2019 10:55:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLELEBLlMTMkuzD1REx2T/bP8C1xOd+ni/RtJ+30/PdwiQErpq2qVeRK8+nesKqeRMUcZS X-Received: by 2002:a63:4e07:: with SMTP id c7mr37369685pgb.350.1560534936124; Fri, 14 Jun 2019 10:55:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560534936; cv=none; d=google.com; s=arc-20160816; b=D90H5R8HmqOHECxSBebGl8Fyt/KyolFTfgz7D6PH4oJH56xWCfI4z/GTLMyUVupe91 INxEwq+/KqZVH981Sz2517rTYF6C/hZ90NZnwK80DEK5E8tWCQR3ljzarI7xO4MzuOwj +927SWsF5o79E5htAtEmFQbINdFLGboq1PopwU4qjEB0mE/q5mw+t5UMOB2rKYASVMuZ j82u+kSM+KIfCJGmfWKZdRQhJXbqwcsYu1ZT2pHWRv9+SOwLatVE3IP+I31aLsVWINd/ +gCZZFh9BTCrLA8K2X6XALpNaUgAM2Y5el8S0nP1bXaFF2NazoTYyBFrIEhPBN23BHEL fBvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=0UDwGiiLdQl3rWyCFjN/Z2Bk9tuVbE3XkJtagVlWj9A=; b=RUXmcIk2bqQwPhZgUhaLdrpnuJa0r8hIhe5+hyMELlQWP+OIZWR7JxxBdM05tDyMJf 9vsGDgoG0GPUJNHJMy6q1tDKkrXNw/4O6xJ7IrVideCDL28x1gLLigncpmEZOurdjFa5 CG6b2cRQH2X5tZ5iAXGvoIgjUG+UCPxLsiU3wgBqyWxxkHn6Blec0nkw7gpYBrQrOaaO fTQQnoe692tb7kjOjWU7Q8sVmPwuDLK67ouoQcYpDySiLEnf+Y73H+9EIvYzPbP3GOC6 D/JiWn2N7dgiHSmN5zliyRt06IIutMfwKgZuGkIheKaDqSDg9ifzwmyY1b4zP7cbyFy/ J3yQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e36si2867016plb.180.2019.06.14.10.55.35; Fri, 14 Jun 2019 10:55:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727757AbfFNRze (ORCPT + 17 others); Fri, 14 Jun 2019 13:55:34 -0400 Received: from foss.arm.com ([217.140.110.172]:39728 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727742AbfFNRzc (ORCPT ); Fri, 14 Jun 2019 13:55:32 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DD59311B3; Fri, 14 Jun 2019 10:55:31 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A44413F718; Fri, 14 Jun 2019 10:55:30 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Eric Anholt , =?utf-8?q?Heiko_St=C3=BCbner?= , Inki Dae , Sandy Huang , Seung-Woo Kim Subject: [PATCH v2 28/28] platform: Add platform_find_device_by_driver() helper Date: Fri, 14 Jun 2019 18:54:23 +0100 Message-Id: <1560534863-15115-29-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> References: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Provide a helper to lookup platform devices by matching device driver in order to avoid drivers trying to use platform bus internals. Cc: Eric Anholt Cc: Greg Kroah-Hartman Cc: "Heiko Stübner" Cc: Inki Dae Cc: "Rafael J. Wysocki" Cc: Sandy Huang Cc: Seung-Woo Kim Tested-by: Heiko Stuebner Signed-off-by: Suzuki K Poulose --- drivers/base/platform.c | 14 ++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_drv.c | 9 +++------ drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 3 +-- drivers/gpu/drm/vc4/vc4_drv.c | 3 +-- include/linux/platform_device.h | 3 +++ 5 files changed, 22 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 4d17298..158ac24 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -1197,6 +1197,20 @@ struct bus_type platform_bus_type = { }; EXPORT_SYMBOL_GPL(platform_bus_type); +/** + * platform_find_device_by_driver - Find a platform device with a given + * driver. + * @start: The device to start the search from. + * @drv: The device driver to look for. + */ +struct device *platform_find_device_by_driver(struct device *start, + const struct device_driver *drv) +{ + return bus_find_device(&platform_bus_type, start, drv, + (void *)platform_match); +} +EXPORT_SYMBOL_GPL(platform_find_device_by_driver); + int __init platform_bus_init(void) { int error; diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index ba8932a..b357e0d 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -244,9 +244,7 @@ static struct component_match *exynos_drm_match_add(struct device *dev) if (!info->driver || !(info->flags & DRM_COMPONENT_DRIVER)) continue; - while ((d = bus_find_device(&platform_bus_type, p, - &info->driver->driver, - (void *)platform_bus_type.match))) { + while ((d = platform_find_device_by_driver(p, &info->driver->driver))) { put_device(p); if (!(info->flags & DRM_FIMC_DEVICE) || @@ -414,9 +412,8 @@ static void exynos_drm_unregister_devices(void) if (!info->driver || !(info->flags & DRM_VIRTUAL_DEVICE)) continue; - while ((dev = bus_find_device(&platform_bus_type, NULL, - &info->driver->driver, - (void *)platform_bus_type.match))) { + while ((dev = platform_find_device_by_driver(NULL, + &info->driver->driver))) { put_device(dev); platform_device_unregister(to_platform_device(dev)); } diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index 53d2c5b..38dc263 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -330,8 +330,7 @@ static struct component_match *rockchip_drm_match_add(struct device *dev) struct device *p = NULL, *d; do { - d = bus_find_device(&platform_bus_type, p, &drv->driver, - (void *)platform_bus_type.match); + d = platform_find_device_by_driver(p, &drv->driver); put_device(p); p = d; diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c index 6d9be20..d159eb5 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.c +++ b/drivers/gpu/drm/vc4/vc4_drv.c @@ -236,8 +236,7 @@ static void vc4_match_add_drivers(struct device *dev, struct device_driver *drv = &drivers[i]->driver; struct device *p = NULL, *d; - while ((d = bus_find_device(&platform_bus_type, p, drv, - (void *)platform_bus_type.match))) { + while ((d = platform_find_device_by_driver(p, drv))) { put_device(p); component_match_add(dev, match, compare_dev, d); p = d; diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index beb25f2..c9c9d9e 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -51,6 +51,9 @@ extern struct device platform_bus; extern void arch_setup_pdev_archdata(struct platform_device *); extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int); +extern struct device * +platform_find_device_by_driver(struct device *start, + const struct device_driver *drv); extern void __iomem * devm_platform_ioremap_resource(struct platform_device *pdev, unsigned int index);