From patchwork Tue Jul 23 22:18:31 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: 11056195 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE1041399 for ; Wed, 24 Jul 2019 06:55:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC770286E0 for ; Wed, 24 Jul 2019 06:55:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE94C28770; Wed, 24 Jul 2019 06:55:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C144C286E0 for ; Wed, 24 Jul 2019 06:55:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 62B156E47A; Wed, 24 Jul 2019 06:55:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 4326C6E37F for ; Tue, 23 Jul 2019 22:19:07 +0000 (UTC) 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 AACE4337; Tue, 23 Jul 2019 15:19:06 -0700 (PDT) Received: from dawn-kernel.cambridge.arm.com (unknown [10.1.197.116]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 017E63F694; Tue, 23 Jul 2019 15:18:57 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Subject: [PATCH v3 0/7] drivers: Add generic device lookup helpers Date: Tue, 23 Jul 2019 23:18:31 +0100 Message-Id: <20190723221838.12024-1-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 24 Jul 2019 06:54:25 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Alexander Aring , Heikki Krogerus , Jacek Anaszewski , rafael@kernel.org, Alexander Shishkin , linux-fpga@vger.kernel.org, Heiko Carstens , Alexandre Belloni , dri-devel@lists.freedesktop.org, Peter Oberparleiter , "Rafael J. Wysocki" , Elie Morisse , Srinivas Kandagatla , linux-i2c@vger.kernel.org, Pavel Machek , Shyam Sundar S K , Frank Rowand , linux-leds@vger.kernel.org, linux-rtc@vger.kernel.org, Maxime Ripard , Florian Fainelli , linux-acpi@vger.kernel.org, Jason Gunthorpe , Lee Jones , Suzuki K Poulose , David Airlie , Doug Ledford , Sebastian Andrzej Siewior , Stefan Schmidt , Wolfram Sang , Jiri Slaby , linux-rockchip@lists.infradead.org, Tomas Winkler , Nehal Shah , Len Brown , devicetree@vger.kernel.org, Maxime Coquelin , Arnd Bergmann , Alan Tull , Will Deacon , "James E.J. Bottomley" , Peter Rosin , Robin Murphy , Mark Brown , Harald Freudenberger , Dan Murphy , Bjorn Helgaas , Takashi Iwai , Mika Westerberg , linux-arm-kernel@lists.infradead.org, Alessandro Zummo , Mathieu Poirier , "Martin K. Petersen" , gregkh@linuxfoundation.org, Thor Thayer , linux-usb@vger.kernel.org, Seung-Woo Kim , Liam Girdwood , Ulf Hansson , linux-spi@vger.kernel.org, Rob Herring , Oliver Neukum , Joe Perches , Moritz Fischer , linux-wpan@vger.kernel.org, "David S. Miller" , Heiner Kallweit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP We have device iterators to find a particular device matching a criteria for a given bus/class/driver. i.e, {bus,class,driver}_find_device() APIs. The matching criteria is a function pointer for the APIs. Often the lookup is based on a generic property of a device (e.g, name, fwnode, of node pointer or device type) rather than a driver specific information. However, each driver writes up its own "match" function, spilling the similar match functions all over the driver subsystems. This series adds device match helpers by generic device properties of a device. Using these generic match functions, introduce wrappers to the existing *_find_device() helpers and converts the existing users to use the new wrappers. i.e, {bus/class/driver}_find_device_by_name() {bus/class/driver}_find_device_by_fwnode() {bus/class/driver}_find_device_by_devt() {bus/class/driver}_find_device_by_acpi_dev() Also adds a wrapper for finding a platform device by driver, to avoid spilling the platform_bus internals in the individual drivers. Applies on 5.3-rc1. [0] git://linux-arm.org/linux-skp.git driver-cleanup/v3 RFC[1] https://marc.info/?i=1559577023-558-1-git-send-email-suzuki.poulose@arm.com V1 [2] https://marc.info/?i=1559747630-28065-1-git-send-email-suzuki.poulose@arm.com V2 [3] https://marc.info/?i=1560534863-15115-1-git-send-email-suzuki.poulose@arm.com Changes since v2: - Merge the device match helper introduction patch with the variants of the helpers, for better review. - Use platform_find_device_by_driver for mcde drm driver. Cc: Alan Tull Cc: Alessandro Zummo Cc: Alexander Aring Cc: Alexander Shishkin Cc: Alexandre Belloni Cc: Andrew Lunn Cc: Arnd Bergmann Cc: Bjorn Helgaas Cc: Daniel Vetter Cc: Dan Murphy Cc: David Airlie Cc: "David S. Miller" Cc: devicetree@vger.kernel.org Cc: Doug Ledford Cc: dri-devel@lists.freedesktop.org Cc: Elie Morisse Cc: Eric Anholt Cc: Florian Fainelli Cc: Frank Rowand Cc: Greg Kroah-Hartman Cc: Harald Freudenberger Cc: Heikki Krogerus Cc: Heiko Carstens Cc: "Heiko Stübner" Cc: Heiko Stuebner Cc: Heiner Kallweit Cc: Inki Dae Cc: Jacek Anaszewski Cc: "James E.J. Bottomley" Cc: Jason Gunthorpe Cc: Jiri Slaby Cc: Joe Perches Cc: Joerg Roedel Cc: Lee Jones Cc: Len Brown Cc: Liam Girdwood Cc: linux-acpi@vger.kernel.org Cc: linux-fpga@vger.kernel.org Cc: linux-i2c@vger.kernel.org Cc: linux-leds@vger.kernel.org Cc: linux-rockchip@lists.infradead.org Cc: linux-rtc@vger.kernel.org Cc: linux-spi@vger.kernel.org Cc: linux-usb@vger.kernel.org Cc: linux-wpan@vger.kernel.org Cc: Maarten Lankhorst Cc: Mark Brown Cc: "Martin K. Petersen" Cc: Mathieu Poirier Cc: Maxime Coquelin Cc: Maxime Ripard Cc: Mika Westerberg Cc: Moritz Fischer Cc: Nehal Shah Cc: Oliver Neukum Cc: Pavel Machek Cc: Peter Oberparleiter Cc: Peter Rosin Cc: "Rafael J. Wysocki" Cc: "Rafael J. Wysocki" Cc: Rob Herring Cc: Robin Murphy Cc: Sandy Huang Cc: Sebastian Andrzej Siewior Cc: Seung-Woo Kim Cc: Shyam Sundar S K Cc: Srinivas Kandagatla Cc: Stefan Schmidt Cc: Takashi Iwai Cc: Thor Thayer Cc: Tomas Winkler Cc: Ulf Hansson Cc: Will Deacon Cc: Wolfram Sang Suzuki K Poulose (7): drivers: Introduce device lookup variants by name drivers: Introduce device lookup variants by of_node drivers: Introduce device lookup variants by fwnode drivers: Introduce device lookup variants by device type drivers: Introduce device lookup variants by ACPI_COMPANION device drivers: Add generic helper to match any device platform: Add platform_find_device_by_driver() helper drivers/amba/tegra-ahb.c | 11 +- drivers/base/bus.c | 24 -- drivers/base/core.c | 39 ++- drivers/base/devcon.c | 8 +- drivers/base/platform.c | 14 ++ drivers/fpga/fpga-bridge.c | 8 +- drivers/fpga/fpga-mgr.c | 8 +- drivers/gpu/drm/drm_mipi_dsi.c | 7 +- drivers/gpu/drm/exynos/exynos_drm_drv.c | 9 +- drivers/gpu/drm/mcde/mcde_drv.c | 3 +- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 3 +- drivers/gpu/drm/vc4/vc4_drv.c | 3 +- .../hwtracing/coresight/coresight-platform.c | 11 +- drivers/hwtracing/coresight/coresight-priv.h | 2 - drivers/hwtracing/coresight/coresight.c | 4 +- drivers/hwtracing/intel_th/core.c | 10 +- drivers/hwtracing/stm/core.c | 9 +- drivers/i2c/busses/i2c-amd-mp2-pci.c | 8 +- drivers/i2c/i2c-core-acpi.c | 11 +- drivers/i2c/i2c-core-of.c | 7 +- drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 8 +- drivers/iommu/arm-smmu-v3.c | 9 +- drivers/iommu/arm-smmu.c | 9 +- drivers/leds/led-class.c | 9 +- drivers/mfd/altera-sysmgr.c | 14 +- drivers/misc/mei/main.c | 9 +- drivers/mux/core.c | 7 +- .../ethernet/hisilicon/hns/hns_dsaf_misc.c | 8 +- drivers/net/phy/mdio_bus.c | 9 +- drivers/nvmem/core.c | 7 +- drivers/of/of_mdio.c | 8 +- drivers/of/platform.c | 7 +- drivers/pci/probe.c | 7 +- drivers/regulator/of_regulator.c | 7 +- drivers/rtc/interface.c | 11 +- drivers/s390/cio/ccwgroup.c | 18 +- drivers/s390/cio/device.c | 15 +- drivers/s390/crypto/zcrypt_api.c | 22 +- drivers/scsi/scsi_proc.c | 9 +- drivers/spi/spi.c | 28 +-- drivers/tty/tty_io.c | 8 +- drivers/usb/core/devio.c | 8 +- drivers/usb/roles/class.c | 16 +- drivers/usb/typec/class.c | 16 +- include/linux/device.h | 237 +++++++++++++++++- include/linux/platform_device.h | 3 + net/ieee802154/core.c | 7 +- sound/soc/rockchip/rk3399_gru_sound.c | 9 +- 48 files changed, 341 insertions(+), 383 deletions(-) Signed-off-by: Greg Kroah-Hartman