* [PATCH v2 00/28] drivers: Consolidate device lookup helpers
@ 2019-06-14 17:53 Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 06/28] drivers: Add generic helper to match by of_node Suzuki K Poulose
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Suzuki K Poulose @ 2019-06-14 17:53 UTC (permalink / raw)
To: linux-kernel
Cc: Andrew Lunn, Shyam Sundar S K, rafael, Will Deacon, Ulf Hansson,
dri-devel, Pavel Machek, Stefan Schmidt, Wolfram Sang, linux-acpi,
Doug Ledford, Jiri Slaby, Tomas Winkler, Dan Murphy, gregkh,
linux-usb, Seung-Woo Kim, linux-spi, Joe Perches, linux-wpan,
Alexandre Belloni, David Airlie, Rafael J . Wysocki ,
Thierry Reding, Srinivas Kandagatla, linux-
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 <atull@kernel.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexander Aring <alex.aring@gmail.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Andreas Noever <andreas.noever@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Corey Minyard <minyard@acm.org>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Dan Murphy <dmurphy@ti.com>
Cc: David Airlie <airlied@linux.ie>
Cc: David Kershner <david.kershner@unisys.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Doug Ledford <dledford@redhat.com>
Cc: dri-devel@lists.freedesktop.org
Cc: Elie Morisse <syniurge@gmail.com>
Cc: Eric Anholt <eric@anholt.net>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Grant Likely <grant.likely@arm.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Joe Perches <joe@perches.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Len Brown <lenb@kernel.org
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Michael Jamet <michael.jamet@intel.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Moritz Fischer <mdf@kernel.org>
Cc: Nehal Shah <nehal-bakulchandra.shah@amd.com>
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Peter Rosin <peda@axentia.se>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Sebastian Ott <sebott@linux.ibm.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Shyam Sundar S K <shyam-sundar.s-k@amd.com>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Stefan Schmidt <stefan@datenfreihafen.org>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Thor Thayer <thor.thayer@linux.intel.com>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
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
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 06/28] drivers: Add generic helper to match by of_node
2019-06-14 17:53 [PATCH v2 00/28] drivers: Consolidate device lookup helpers Suzuki K Poulose
@ 2019-06-14 17:54 ` Suzuki K Poulose
2019-06-14 20:31 ` Wolfram Sang
2019-06-14 17:54 ` [PATCH v2 09/28] drivers: Add generic match helper by ACPI_COMPANION device Suzuki K Poulose
` (2 subsequent siblings)
3 siblings, 1 reply; 13+ messages in thread
From: Suzuki K Poulose @ 2019-06-14 17:54 UTC (permalink / raw)
To: linux-kernel
Cc: gregkh, rafael, suzuki.poulose, Alan Tull, Andrew Lunn,
Daniel Vetter, David Airlie, David S. Miller, devicetree,
dri-devel, Florian Fainelli, Frank Rowand, Heiner Kallweit,
Jiri Slaby, Jonathan Hunter, Lee Jones, Liam Girdwood, linux-fpga,
linux-i2c, linux-spi, Maarten Lankhorst, Mark Brown,
Mathieu Poirier <mathieu.poiri
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 <atull@kernel.org>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: devicetree@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-fpga@vger.kernel.org
Cc: linux-i2c@vger.kernel.org
Cc: linux-spi@vger.kernel.org
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Moritz Fischer <mdf@kernel.org>
Cc: Peter Rosin <peda@axentia.se>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Thor Thayer <thor.thayer@linux.intel.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
drivers/base/core.c | 6 ++++++
drivers/fpga/of-fpga-region.c | 7 +------
include/linux/device.h | 2 ++
3 files changed, 9 insertions(+), 6 deletions(-)
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,
--
2.7.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 09/28] drivers: Add generic match helper by ACPI_COMPANION device
2019-06-14 17:53 [PATCH v2 00/28] drivers: Consolidate device lookup helpers Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 06/28] drivers: Add generic helper to match by of_node Suzuki K Poulose
@ 2019-06-14 17:54 ` Suzuki K Poulose
2019-06-17 22:07 ` Rafael J. Wysocki
2019-06-14 17:54 ` [PATCH v2 17/28] drivers: Introduce bus_find_device_by_of_node() helper Suzuki K Poulose
2019-06-24 3:23 ` [PATCH v2 00/28] drivers: Consolidate device lookup helpers Greg KH
3 siblings, 1 reply; 13+ messages in thread
From: Suzuki K Poulose @ 2019-06-14 17:54 UTC (permalink / raw)
To: linux-kernel
Cc: gregkh, rafael, suzuki.poulose, Len Brown, linux-acpi, linux-spi,
Mark Brown
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 <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
Cc: linux-spi@vger.kernel.org
Cc: Mark Brown <broonie@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
drivers/base/core.c | 6 ++++++
include/linux/device.h | 1 +
2 files changed, 7 insertions(+)
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));
--
2.7.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 17/28] drivers: Introduce bus_find_device_by_of_node() helper
2019-06-14 17:53 [PATCH v2 00/28] drivers: Consolidate device lookup helpers Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 06/28] drivers: Add generic helper to match by of_node Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 09/28] drivers: Add generic match helper by ACPI_COMPANION device Suzuki K Poulose
@ 2019-06-14 17:54 ` Suzuki K Poulose
2019-06-14 20:32 ` Wolfram Sang
2019-07-09 16:19 ` Rob Herring
2019-06-24 3:23 ` [PATCH v2 00/28] drivers: Consolidate device lookup helpers Greg KH
3 siblings, 2 replies; 13+ messages in thread
From: Suzuki K Poulose @ 2019-06-14 17:54 UTC (permalink / raw)
To: linux-kernel
Cc: gregkh, rafael, suzuki.poulose, Maarten Lankhorst, Maxime Ripard,
dri-devel, David Airlie, Daniel Vetter, devicetree,
Florian Fainelli, Frank Rowand, Heiko Stuebner, Liam Girdwood,
linux-i2c, linux-rockchip, linux-spi, Mathieu Poirier,
Rob Herring, Srinivas Kandagatla, Takashi Iwai, Wolfram Sang
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 <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: dri-devel@lists.freedesktop.org
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: devicetree@vger.kernel.org
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-i2c@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
Cc: linux-spi@vger.kernel.org
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
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(-)
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 <asm/smp_plat.h>
-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);
--
2.7.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 06/28] drivers: Add generic helper to match by of_node
2019-06-14 17:54 ` [PATCH v2 06/28] drivers: Add generic helper to match by of_node Suzuki K Poulose
@ 2019-06-14 20:31 ` Wolfram Sang
2019-06-17 9:59 ` Suzuki K Poulose
0 siblings, 1 reply; 13+ messages in thread
From: Wolfram Sang @ 2019-06-14 20:31 UTC (permalink / raw)
To: Suzuki K Poulose
Cc: linux-kernel, gregkh, rafael, Alan Tull, Andrew Lunn,
Daniel Vetter, David Airlie, David S. Miller, devicetree,
dri-devel, Florian Fainelli, Frank Rowand, Heiner Kallweit,
Jiri Slaby, Jonathan Hunter, Lee Jones, Liam Girdwood, linux-fpga,
linux-i2c, linux-spi, Maarten Lankhorst, Mark Brown,
Mathieu Poirier <mathieu
[-- Attachment #1: Type: text/plain, Size: 245 bytes --]
> +
> +int device_match_of_node(struct device *dev, const void *np)
> +{
> + return dev->of_node == np;
> +}
> +EXPORT_SYMBOL_GPL(device_match_of_node);
Is it an option to 'static inline' this simple function in the header,
saving the EXPORT?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 17/28] drivers: Introduce bus_find_device_by_of_node() helper
2019-06-14 17:54 ` [PATCH v2 17/28] drivers: Introduce bus_find_device_by_of_node() helper Suzuki K Poulose
@ 2019-06-14 20:32 ` Wolfram Sang
2019-07-09 16:19 ` Rob Herring
1 sibling, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2019-06-14 20:32 UTC (permalink / raw)
To: Suzuki K Poulose
Cc: devicetree, Florian Fainelli, Mathieu Poirier, rafael,
Maxime Ripard, gregkh, Takashi Iwai, linux-kernel, dri-devel,
Liam Girdwood, David Airlie, Rob Herring, Srinivas Kandagatla,
linux-i2c, linux-rockchip, linux-spi, Frank Rowand
[-- Attachment #1.1: Type: text/plain, Size: 1264 bytes --]
On Fri, Jun 14, 2019 at 06:54:12PM +0100, Suzuki K Poulose wrote:
> 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 <maarten.lankhorst@linux.intel.com>
> Cc: Maxime Ripard <maxime.ripard@bootlin.com>
> Cc: dri-devel@lists.freedesktop.org
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: devicetree@vger.kernel.org
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: Liam Girdwood <lgirdwood@gmail.com>
> Cc: linux-i2c@vger.kernel.org
> Cc: linux-rockchip@lists.infradead.org
> Cc: linux-spi@vger.kernel.org
> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> Cc: Takashi Iwai <tiwai@suse.com>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Acked-by: Wolfram Sang <wsa@the-dreams.de> # for the I2C parts
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 159 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 06/28] drivers: Add generic helper to match by of_node
2019-06-14 20:31 ` Wolfram Sang
@ 2019-06-17 9:59 ` Suzuki K Poulose
2019-06-17 10:06 ` Wolfram Sang
0 siblings, 1 reply; 13+ messages in thread
From: Suzuki K Poulose @ 2019-06-17 9:59 UTC (permalink / raw)
To: wsa
Cc: linux-kernel, gregkh, rafael, atull, andrew, daniel, airlied,
davem, devicetree, dri-devel, f.fainelli, frowand.list,
hkallweit1, jslaby, jonathanh, lee.jones, lgirdwood, linux-fpga,
linux-i2c, linux-spi, maarten.lankhorst, broonie, mathieu.poirier,
maxime.ripard, mdf, peda, robh+dt, srinivas.kandagatla,
thierry.reding, thor.thayer, ulf.hansson, joe
Hi
On 14/06/2019 21:31, Wolfram Sang wrote:
>> +
>> +int device_match_of_node(struct device *dev, const void *np)
>> +{
>> + return dev->of_node == np;
>> +}
>> +EXPORT_SYMBOL_GPL(device_match_of_node);
>
> Is it an option to 'static inline' this simple function in the header,
> saving the EXPORT?
>
No. This is supposed to be passed on as a call back function pointer
for the APIs. Having it as a static inline, would simply replicate
the same function through the driver subsystems, which is one of the
issues that series is trying to solve. Also, by having them exported,
we can convert the new specialized device lookup functions,
*_find_device_by_<property> to be static inlines.
Suzuki
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 06/28] drivers: Add generic helper to match by of_node
2019-06-17 9:59 ` Suzuki K Poulose
@ 2019-06-17 10:06 ` Wolfram Sang
0 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2019-06-17 10:06 UTC (permalink / raw)
To: Suzuki K Poulose
Cc: linux-kernel, gregkh, rafael, atull, andrew, daniel, airlied,
davem, devicetree, dri-devel, f.fainelli, frowand.list,
hkallweit1, jslaby, jonathanh, lee.jones, lgirdwood, linux-fpga,
linux-i2c, linux-spi, maarten.lankhorst, broonie, mathieu.poirier,
maxime.ripard, mdf, peda, robh+dt, srinivas.kandagatla,
thierry.reding, thor.thayer, ulf.hansson, joe
[-- Attachment #1: Type: text/plain, Size: 156 bytes --]
> > Is it an option to 'static inline' this simple function in the header,
> > saving the EXPORT?
> >
>
> No.
OK, thanks for the explanation!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 09/28] drivers: Add generic match helper by ACPI_COMPANION device
2019-06-14 17:54 ` [PATCH v2 09/28] drivers: Add generic match helper by ACPI_COMPANION device Suzuki K Poulose
@ 2019-06-17 22:07 ` Rafael J. Wysocki
2019-06-18 8:38 ` Suzuki K Poulose
0 siblings, 1 reply; 13+ messages in thread
From: Rafael J. Wysocki @ 2019-06-17 22:07 UTC (permalink / raw)
To: Suzuki K Poulose
Cc: Linux Kernel Mailing List, Greg Kroah-Hartman, Rafael J. Wysocki,
Len Brown, ACPI Devel Maling List, linux-spi, Mark Brown
On Fri, Jun 14, 2019 at 7:55 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>
> 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 <lenb@kernel.org>
> Cc: linux-acpi@vger.kernel.org
> Cc: linux-spi@vger.kernel.org
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Please fold this change into the patch adding users of device_match_acpi_dev().
> ---
> drivers/base/core.c | 6 ++++++
> include/linux/device.h | 1 +
> 2 files changed, 7 insertions(+)
>
> 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));
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 09/28] drivers: Add generic match helper by ACPI_COMPANION device
2019-06-17 22:07 ` Rafael J. Wysocki
@ 2019-06-18 8:38 ` Suzuki K Poulose
2019-06-18 8:40 ` Rafael J. Wysocki
0 siblings, 1 reply; 13+ messages in thread
From: Suzuki K Poulose @ 2019-06-18 8:38 UTC (permalink / raw)
To: rafael; +Cc: linux-kernel, gregkh, lenb, linux-acpi, linux-spi, broonie
Hi Rafael,
On 17/06/2019 23:07, Rafael J. Wysocki wrote:
> On Fri, Jun 14, 2019 at 7:55 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>>
>> 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 <lenb@kernel.org>
>> Cc: linux-acpi@vger.kernel.org
>> Cc: linux-spi@vger.kernel.org
>> Cc: Mark Brown <broonie@kernel.org>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>
> Please fold this change into the patch adding users of device_match_acpi_dev().
There are variants of this by class/bus/driver and all of them are introduced
as separate patches with the respective users. If we do for this, we have to
do the same for other matches as well.
i.e, [ device_match_by_attr + class_find_device_by_attr & users +
driver_find_device_by_attr & users + bus_find_device_by_attr & users ]
And that becomes a large chunk, which could make the review painful.
If you would still like that approach, I could do that in the next revision.
Cheers
Suzuki
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 09/28] drivers: Add generic match helper by ACPI_COMPANION device
2019-06-18 8:38 ` Suzuki K Poulose
@ 2019-06-18 8:40 ` Rafael J. Wysocki
0 siblings, 0 replies; 13+ messages in thread
From: Rafael J. Wysocki @ 2019-06-18 8:40 UTC (permalink / raw)
To: Suzuki K Poulose
Cc: Rafael J. Wysocki, Linux Kernel Mailing List, Greg Kroah-Hartman,
Len Brown, ACPI Devel Maling List, linux-spi, Mark Brown
On Tue, Jun 18, 2019 at 10:38 AM Suzuki K Poulose
<suzuki.poulose@arm.com> wrote:
>
> Hi Rafael,
>
> On 17/06/2019 23:07, Rafael J. Wysocki wrote:
> > On Fri, Jun 14, 2019 at 7:55 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
> >>
> >> 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 <lenb@kernel.org>
> >> Cc: linux-acpi@vger.kernel.org
> >> Cc: linux-spi@vger.kernel.org
> >> Cc: Mark Brown <broonie@kernel.org>
> >> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> >> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> >> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> >
> > Please fold this change into the patch adding users of device_match_acpi_dev().
>
> There are variants of this by class/bus/driver and all of them are introduced
> as separate patches with the respective users. If we do for this, we have to
> do the same for other matches as well.
>
> i.e, [ device_match_by_attr + class_find_device_by_attr & users +
> driver_find_device_by_attr & users + bus_find_device_by_attr & users ]
>
> And that becomes a large chunk, which could make the review painful.
>
> If you would still like that approach, I could do that in the next revision.
Yes, please.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 00/28] drivers: Consolidate device lookup helpers
2019-06-14 17:53 [PATCH v2 00/28] drivers: Consolidate device lookup helpers Suzuki K Poulose
` (2 preceding siblings ...)
2019-06-14 17:54 ` [PATCH v2 17/28] drivers: Introduce bus_find_device_by_of_node() helper Suzuki K Poulose
@ 2019-06-24 3:23 ` Greg KH
3 siblings, 0 replies; 13+ messages in thread
From: Greg KH @ 2019-06-24 3:23 UTC (permalink / raw)
To: Suzuki K Poulose
Cc: Andrew Lunn, Shyam Sundar S K, rafael, Will Deacon, Ulf Hansson,
dri-devel, Pavel Machek, Stefan Schmidt, Wolfram Sang, linux-acpi,
Doug Ledford, Jiri Slaby, Tomas Winkler, Dan Murphy, linux-usb,
Seung-Woo Kim, linux-kernel, linux-spi, Joe Perches, linux-wpan,
Alexandre Belloni, David Airlie, Rafael J . Wysocki ,
Thierry Reding, Srinivas Kandagatla, linu
On Fri, Jun 14, 2019 at 06:53:55PM +0100, Suzuki K Poulose wrote:
> 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.
I've applied the first 6 patches of this series to my tree now. Let's
see how that goes, and this should give you a more solid base to redo
the rest of the series off of.
thanks,
greg k-h
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 17/28] drivers: Introduce bus_find_device_by_of_node() helper
2019-06-14 17:54 ` [PATCH v2 17/28] drivers: Introduce bus_find_device_by_of_node() helper Suzuki K Poulose
2019-06-14 20:32 ` Wolfram Sang
@ 2019-07-09 16:19 ` Rob Herring
1 sibling, 0 replies; 13+ messages in thread
From: Rob Herring @ 2019-07-09 16:19 UTC (permalink / raw)
To: Suzuki K Poulose
Cc: linux-kernel, gregkh, rafael, suzuki.poulose, Maarten Lankhorst,
Maxime Ripard, dri-devel, David Airlie, Daniel Vetter, devicetree,
Florian Fainelli, Frank Rowand, Heiko Stuebner, Liam Girdwood,
linux-i2c, linux-rockchip, linux-spi, Mathieu Poirier,
Srinivas Kandagatla, Takashi Iwai, Wolfram Sang
On Fri, 14 Jun 2019 18:54:12 +0100, Suzuki K Poulose wrote:
> 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 <maarten.lankhorst@linux.intel.com>
> Cc: Maxime Ripard <maxime.ripard@bootlin.com>
> Cc: dri-devel@lists.freedesktop.org
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: devicetree@vger.kernel.org
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: Liam Girdwood <lgirdwood@gmail.com>
> Cc: linux-i2c@vger.kernel.org
> Cc: linux-rockchip@lists.infradead.org
> Cc: linux-spi@vger.kernel.org
> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> Cc: Takashi Iwai <tiwai@suse.com>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
> 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(-)
>
Reviewed-by: Rob Herring <robh@kernel.org>
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2019-07-09 16:19 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-14 17:53 [PATCH v2 00/28] drivers: Consolidate device lookup helpers Suzuki K Poulose
2019-06-14 17:54 ` [PATCH v2 06/28] drivers: Add generic helper to match by of_node Suzuki K Poulose
2019-06-14 20:31 ` Wolfram Sang
2019-06-17 9:59 ` Suzuki K Poulose
2019-06-17 10:06 ` Wolfram Sang
2019-06-14 17:54 ` [PATCH v2 09/28] drivers: Add generic match helper by ACPI_COMPANION device Suzuki K Poulose
2019-06-17 22:07 ` Rafael J. Wysocki
2019-06-18 8:38 ` Suzuki K Poulose
2019-06-18 8:40 ` Rafael J. Wysocki
2019-06-14 17:54 ` [PATCH v2 17/28] drivers: Introduce bus_find_device_by_of_node() helper Suzuki K Poulose
2019-06-14 20:32 ` Wolfram Sang
2019-07-09 16:19 ` Rob Herring
2019-06-24 3:23 ` [PATCH v2 00/28] drivers: Consolidate device lookup helpers Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).