From patchwork Wed Jun 5 15:13:37 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: 10978717 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 A73C292A for ; Thu, 6 Jun 2019 07:04:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9506422BF1 for ; Thu, 6 Jun 2019 07:04:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 867E128786; Thu, 6 Jun 2019 07:04:36 +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 7E9F822BF1 for ; Thu, 6 Jun 2019 07:04:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 052D989690; Thu, 6 Jun 2019 07:03:50 +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.101.70]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F7B589C84 for ; Wed, 5 Jun 2019 15:14:18 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6C43615A2; Wed, 5 Jun 2019 08:14: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 1550D3F246; Wed, 5 Jun 2019 08:14:04 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Subject: [PATCH 00/13] drivers: Introduce generic device lookup helpers Date: Wed, 5 Jun 2019 16:13:37 +0100 Message-Id: <1559747630-28065-1-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 06 Jun 2019 07:03:45 +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 , Shyam Sundar S K , rafael@kernel.org, Will Deacon , Ulf Hansson , dri-devel@lists.freedesktop.org, Pavel Machek , Stefan Schmidt , Wolfram Sang , linux-acpi@vger.kernel.org, Doug Ledford , Jiri Slaby , Tomas Winkler , Dan Murphy , gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, Seung-Woo Kim , linux-spi@vger.kernel.org, Joe Perches , linux-wpan@vger.kernel.org, Alexandre Belloni , David Airlie , "Rafael J . Wysocki " , Thierry Reding , Srinivas Kandagatla , linux-i2c@vger.kernel.org, "Rafael J. Wysocki" , Jonathan Hunter , linux-rockchip@lists.infradead.org, Len Brown , Corey Minyard , suzuki.poulose@arm.com, Jacek Anaszewski , Bjorn Helgaas , Mika Westerberg , Mathieu Poirier , Oliver Neukum , Peter Oberparleiter , "David S. Miller" , Maxime Coquelin , Hartmut Knaack , Jonathan Cameron , Heiner Kallweit , Thor Thayer , Heikki Krogerus , Alexander Shishkin , linux-fpga@vger.kernel.org, Heiko Carstens , Elie Morisse , Frank Rowand , linux-rtc@vger.kernel.org, Florian Fainelli , David Kershner , Grygorii Strashko , Arnd Bergmann , "James E.J. Bottomley" , Mark Brown , Harald Freudenberger , Felipe Balbi , "Martin K. Petersen" , Liam Girdwood , Grant Likely , Peter Rosin , Alexander Aring , Sebastian Ott , Maxime Ripard , Sebastian Andrzej Siewior , Andreas Noever , Lee Jones , linux-leds@vger.kernel.org, Russell King , Jason Gunthorpe , Nehal Shah , devicetree@vger.kernel.org, Alan Tull , Michael Jamet , Rob Herring , Alessandro Zummo , Takashi Iwai , Moritz Fischer , Robin Murphy 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. Additionally the prototype for the "match" functions accepted by the above APIs have a minute difference which prevents us otherwise sharing the match functions. i.e, int (*match)(struct device *dev, void *data) for {bus/driver}_find_device() vs int (*match)(struct device *dev, const void *) for class_find_device() If we promote the former to accept a "const void*" parameter, we could share one single match function for all the helpers. This series achieves the following: 1) Unify the prototype for "match" functions accepted by the device lookup APIs. 2) Introduce generic match functions to match devices by the generic attributes of a device (e.g, name, fwnode, of_node and devt). Also, in order to prevent creation of such match functions in the future, we introduce wrapper functions for the look up APIs, which automatically uses the appropriate match functions. i.e, {bus/class/driver}_find_device_by_name {bus/class/driver}_find_device_by_of_node {bus/class/driver}_find_device_by_fwnode {bus/class/driver}_find_device_by_devt Additionally, this series also adds wrapper for finding a device by matching a device driver for platform bus devices - platform_find_device_by_driver() to avoid a few drivers hard coding the platform bus specific details. This is part 1 of revised version of the series posted here [0], to allow for better management of the merging. Part 2 of the series, where these new helpers are consumed by the individual driver subsystems will be posted once this is series is merged. The entire tree with both the parts in is available at [1] [0] https://marc.info/?i=1559577023-558-1-git-send-email-suzuki.poulose@arm.com [1] git://linux-arm.org/linux-skp.git driver-cleanup/v1 Cc: Alan Tull Cc: Alessandro Zummo Cc: Alexander Aring Cc: Alexander Shishkin Cc: Alexandre Belloni Cc: Andreas Noever Cc: Andrew Lunn Cc: Arnd Bergmann Cc: Bjorn Helgaas Cc: Corey Minyard Cc: Daniel Vetter Cc: Dan Murphy Cc: David Airlie Cc: David Kershner Cc: "David S. Miller" Cc: Doug Ledford Cc: dri-devel@lists.freedesktop.org Cc: Elie Morisse Cc: Eric Anholt Cc: Felipe Balbi Cc: Florian Fainelli Cc: Frank Rowand Cc: Grant Likely Cc: Greg Kroah-Hartman Cc: Grygorii Strashko Cc: Harald Freudenberger Cc: Hartmut Knaack 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: Jonathan Cameron Cc: Jonathan Hunter Cc: Lee Jones Cc: Len Brown Cc: Maarten Lankhorst Cc: Mark Brown Cc: "Martin K. Petersen" Cc: Mathieu Poirier Cc: Maxime Coquelin Cc: Maxime Ripard Cc: Michael Jamet 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: Rafael J. Wysocki" Cc: Rob Herring Cc: Robin Murphy Cc: Russell King Cc: Sandy Huang Cc: Sebastian Andrzej Siewior Cc: Sebastian Ott Cc: Seung-Woo Kim Cc: Shyam Sundar S K Cc: Srinivas Kandagatla Cc: Stefan Schmidt Cc: Takashi Iwai Cc: Thierry Reding Cc: Thor Thayer Cc: Tomas Winkler Cc: Ulf Hansson Cc: Will Deacon Cc: Wolfram Sang Cc: devicetree@vger.kernel.org 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 Suzuki K Poulose (13): acpi: utils: Cleanup acpi_dev_match_cb bus_find_device: Unify the match callback with class_find_device driver_find_device: Unify the match function with class_find_device() drivers: Add generic helper to match by of_node drivers: Add generic helper to match by fwnode drivers: Add generic helper to match by devt drivers: Add generic match helper by ACPI_COMPANION device drivers: Add generic helper to match by name drivers: Add generic helper to match any device drivers: Introduce variants of class_find_device() drivers: Introduce variants for bus_find_device() drivers: Introduce variants of driver_find_device() platform: Add platform_find_device_by_driver() helper arch/powerpc/platforms/pseries/ibmebus.c | 4 +- drivers/acpi/acpi_lpss.c | 4 +- drivers/acpi/sleep.c | 2 +- drivers/acpi/utils.c | 11 +- drivers/amba/tegra-ahb.c | 4 +- drivers/base/bus.c | 28 +-- drivers/base/core.c | 36 ++++ drivers/base/devcon.c | 2 +- drivers/base/driver.c | 4 +- drivers/base/platform.c | 14 ++ drivers/char/ipmi/ipmi_msghandler.c | 8 +- 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/gpu/drm/tegra/dc.c | 4 +- drivers/hwtracing/coresight/coresight.c | 6 +- drivers/hwtracing/coresight/of_coresight.c | 2 +- drivers/hwtracing/intel_th/core.c | 5 +- drivers/i2c/busses/i2c-amd-mp2-pci.c | 2 +- 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/iommu/arm-smmu-v3.c | 2 +- drivers/iommu/arm-smmu.c | 2 +- drivers/mfd/altera-sysmgr.c | 4 +- drivers/mfd/syscon.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/ccwgroup.c | 2 +- drivers/s390/cio/chsc_sch.c | 2 +- drivers/s390/cio/css.c | 4 +- drivers/s390/cio/device.c | 6 +- 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/staging/most/core.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 | 188 ++++++++++++++++++++- include/linux/platform_device.h | 3 + sound/soc/rockchip/rk3399_gru_sound.c | 2 +- 54 files changed, 320 insertions(+), 123 deletions(-)