From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Return-Path: From: Suzuki K Poulose Subject: [PATCH v2 00/28] drivers: Consolidate device lookup helpers Date: Fri, 14 Jun 2019 18:53:55 +0100 Message-Id: <1560534863-15115-1-git-send-email-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Alan Tull , Alessandro Zummo , Alexander Aring , Alexander Shishkin , Alexandre Belloni , Andreas Noever , Andrew Lunn , Arnd Bergmann , Bjorn Helgaas , Corey Minyard , Daniel Vetter , Dan Murphy , David Airlie , David Kershner , "David S. Miller" , Doug Ledford , dri-devel@lists.freedesktop.org, Elie Morisse , Eric Anholt , Felipe Balbi , Florian Fainelli , Frank Rowand , Grant Likely , Grygorii Strashko , Harald Freudenberger , Hartmut Knaack , Heikki Krogerus , Heiko Carstens , =?UTF-8?q?Heiko=20St=C3=BCbner?= , Heiner Kallweit , Inki Dae , Jacek Anaszewski , "James E.J. Bottomley" , Jason Gunthorpe , Jiri Slaby , Joe Perches , Joerg Roedel , Jonathan Cameron , Jonathan Hunter , Lee Jones , Len Brown , Liam Girdwood , Maarten Lankhorst , Mark Brown , "Martin K. Petersen" , Mathieu Poirier , Maxime Coquelin , Maxime Ripard , Michael Jamet , Mika Westerberg , Moritz Fischer , Nehal Shah , Oliver Neukum , Pavel Machek , Peter Oberparleiter , Peter Rosin , "Rafael J. Wysocki" , "Rafael J . Wysocki " , Rob Herring , Robin Murphy , Russell King , Sandy Huang , Sebastian Andrzej Siewior , Sebastian Ott , Seung-Woo Kim , Shyam Sundar S K , Srinivas Kandagatla , Stefan Schmidt , Takashi Iwai , Thierry Reding , Thor Thayer , Tomas Winkler , Ulf Hansson , Will Deacon , Wolfram Sang , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-fpga@vger.kernel.org, linux-i2c@vger.kernel.org, linux-leds@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-rtc@vger.kernel.org, linux-spi@vger.kernel.org, linux-usb@vger.kernel.org, linux-wpan@vger.kernel.org List-ID: 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: a) [Patches 03-05] Unify the prototype for "match" functions accepted by the device lookup APIs. b) [Patches 06-11] Introduce generic match functions to match devices by the generic attributes of a device (e.g, name, fwnode, of_node and devt). c) [Patches 12-27] 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 {bus/class/driver}_find_device_by_acpi_dev {bus/class/driver}_find_next_device and converts the existing users to switch to the new helpers. d) [Patch 28] 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. Applies on v5.2-rc4, available at [0] [0] git://linux-arm.org/linux-skp.git driver-cleanup/v2 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 Changes since v1: - Drop start parameter for *_find_device_by_devt(). - Fix build warnings for s390 - Add *_find_device_by_acpi_dev() wrappers. - Group wrappers and the consumers into single patch, reducing the total patches to 28 from 57. (Rafael). - Better description for acpi cleanup patch. - Added tags from 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 (28): staging: most-core: Use bus_find_device_by_name mfd: Remove unused helper syscon_regmap_lookup_by_pdevname 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 device type 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 class_find_device_by_name() helper drivers: Introduce class_find_device_by_of_node() helper drivers: Introduce class_find_device_by_fwnode() helper drivers: Introduce class_find_device_by_devt() helper drivers: Introduce class_find_device_by_acpi_dev() helper drivers: Introduce bus_find_device_by_of_node() helper drivers: Introduce bus_find_device_by_fwnode() helper drivers: Introduce bus_find_device_by_devt() helper drivers: Introduce bus_find_next_device() helper drivers: Introduce bus_find_device_by_acpi_dev() helper drivers: Introduce driver_find_device_by_name() helper drivers: Introduce driver_find_device_by_of_node() helper drivers: Introduce driver_find_device_by_fwnode() helper drivers: Introduce driver_find_device_by_devt() helper drivers: Introduce driver_find_next_device() helper drivers: Introduce driver_find_device_by_acpi_dev() helper 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 | 11 +- drivers/base/bus.c | 28 +-- drivers/base/core.c | 45 +++- drivers/base/devcon.c | 8 +- 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/fpga/fpga-bridge.c | 8 +- drivers/fpga/fpga-mgr.c | 8 +- drivers/fpga/of-fpga-region.c | 7 +- drivers/gpu/drm/drm_mipi_dsi.c | 7 +- drivers/gpu/drm/exynos/exynos_drm_drv.c | 9 +- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 3 +- drivers/gpu/drm/tegra/dc.c | 4 +- drivers/gpu/drm/vc4/vc4_drv.c | 3 +- drivers/hwtracing/coresight/coresight.c | 6 +- drivers/hwtracing/coresight/of_coresight.c | 11 +- drivers/hwtracing/intel_th/core.c | 11 +- drivers/hwtracing/stm/core.c | 9 +- drivers/i2c/busses/i2c-amd-mp2-pci.c | 8 +- drivers/i2c/i2c-core-acpi.c | 10 +- drivers/i2c/i2c-core-of.c | 9 +- drivers/iio/inkern.c | 2 +- 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/mfd/syscon.c | 21 -- drivers/misc/mei/main.c | 9 +- drivers/mux/core.c | 7 +- drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 8 +- 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/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/pci/search.c | 4 +- drivers/regulator/of_regulator.c | 7 +- drivers/rtc/interface.c | 11 +- drivers/s390/cio/ccwgroup.c | 18 +- drivers/s390/cio/chsc_sch.c | 2 +- drivers/s390/cio/css.c | 4 +- drivers/s390/cio/device.c | 21 +- drivers/s390/cio/scm.c | 4 +- drivers/s390/crypto/ap_bus.c | 8 +- drivers/s390/crypto/zcrypt_api.c | 22 +- drivers/scsi/scsi_proc.c | 9 +- drivers/spi/spi.c | 28 +-- drivers/staging/most/core.c | 9 +- drivers/thunderbolt/switch.c | 4 +- drivers/tty/tty_io.c | 8 +- drivers/usb/core/devio.c | 8 +- drivers/usb/core/usb.c | 4 +- drivers/usb/phy/phy-am335x-control.c | 4 +- drivers/usb/phy/phy-isp1301.c | 4 +- drivers/usb/roles/class.c | 16 +- drivers/usb/typec/class.c | 16 +- drivers/visorbus/visorbus_main.c | 4 +- include/linux/device.h | 247 ++++++++++++++++++++- include/linux/mfd/syscon.h | 6 - include/linux/platform_device.h | 3 + net/ieee802154/core.c | 7 +- sound/soc/rockchip/rk3399_gru_sound.c | 9 +- 73 files changed, 407 insertions(+), 482 deletions(-) -- 2.7.4