linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 01/57] drivers: s390/cio: Use driver_for_each_device
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-14 13:32   ` Suzuki K Poulose
  2019-06-17  9:21   ` Sebastian Ott
  2019-06-03 15:49 ` [RFC PATCH 02/57] drivers: ipmi: Drop device reference Suzuki K Poulose
                   ` (55 subsequent siblings)
  56 siblings, 2 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Sebastian Ott,
	Peter Oberparleiter, Heiko Carstens

The cio driver use driver_find_device() to find all devices
to release them before the driver is unregistered. Instead,
it could easily use a lighter driver_for_each_device() helper
to iterate over all the devices.

Cc: Sebastian Ott <sebott@linux.ibm.com>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/s390/cio/ccwgroup.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index 4ebf6d4..a006945 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -581,9 +581,12 @@ 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_release_device(struct device *dev, void *unused)
 {
-	return 1;
+	struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
+
+	ccwgroup_ungroup(gdev);
+	return 0;
 }
 
 /**
@@ -594,16 +597,11 @@ static int __ccwgroup_match_all(struct device *dev, void *data)
  */
 void ccwgroup_driver_unregister(struct ccwgroup_driver *cdriver)
 {
-	struct device *dev;
+	int ret;
 
 	/* We don't want ccwgroup devices to live longer than their driver. */
-	while ((dev = driver_find_device(&cdriver->driver, NULL, NULL,
-					 __ccwgroup_match_all))) {
-		struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
-
-		ccwgroup_ungroup(gdev);
-		put_device(dev);
-	}
+	ret = driver_for_each_device(&cdriver->driver, NULL, NULL,
+				     ccwgroup_release_device);
 	driver_unregister(&cdriver->driver);
 }
 EXPORT_SYMBOL(ccwgroup_driver_unregister);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 02/57] drivers: ipmi: Drop device reference
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
  2019-06-03 15:49 ` [RFC PATCH 01/57] drivers: s390/cio: Use driver_for_each_device Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 17:01   ` Corey Minyard
  2019-06-03 19:09   ` Greg KH
  2019-06-03 15:49 ` [RFC PATCH 03/57] drivers: coresight: Drop device references found via bus_find_device Suzuki K Poulose
                   ` (54 subsequent siblings)
  56 siblings, 2 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Corey Minyard, Arnd Bergmann

Drop the reference to a device found via bus_find_device()

Cc: Corey Minyard <minyard@acm.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/char/ipmi/ipmi_si_platform.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/char/ipmi/ipmi_si_platform.c b/drivers/char/ipmi/ipmi_si_platform.c
index f2a91c4..ff82353 100644
--- a/drivers/char/ipmi/ipmi_si_platform.c
+++ b/drivers/char/ipmi/ipmi_si_platform.c
@@ -442,6 +442,7 @@ void ipmi_remove_platform_device_by_name(char *name)
 				      pdev_match_name))) {
 		struct platform_device *pdev = to_platform_device(dev);
 
+		put_device(dev);
 		platform_device_unregister(pdev);
 	}
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 03/57] drivers: coresight: Drop device references found via bus_find_device
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
  2019-06-03 15:49 ` [RFC PATCH 01/57] drivers: s390/cio: Use driver_for_each_device Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 02/57] drivers: ipmi: Drop device reference Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 19:08   ` Greg KH
  2019-06-03 15:49 ` [RFC PATCH 04/57] drivers: Add generic match helper to match the device of_node Suzuki K Poulose
                   ` (53 subsequent siblings)
  56 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Mathieu Poirier

We must drop references to the device found via bus_find_device().

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/hwtracing/coresight/coresight.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
index 4b13028..37ccd67 100644
--- a/drivers/hwtracing/coresight/coresight.c
+++ b/drivers/hwtracing/coresight/coresight.c
@@ -540,7 +540,7 @@ struct coresight_device *coresight_get_enabled_sink(bool deactivate)
 
 	dev = bus_find_device(&coresight_bustype, NULL, &deactivate,
 			      coresight_enabled_sink);
-
+	put_device(dev);
 	return dev ? to_coresight_device(dev) : NULL;
 }
 
@@ -581,7 +581,7 @@ struct coresight_device *coresight_get_sink_by_id(u32 id)
 
 	dev = bus_find_device(&coresight_bustype, NULL, &id,
 			      coresight_sink_by_id);
-
+	put_device(dev);
 	return dev ? to_coresight_device(dev) : NULL;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 04/57] drivers: Add generic match helper to match the device of_node
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (2 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 03/57] drivers: coresight: Drop device references found via bus_find_device Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 05/57] drm: mipi_dsi: Use bus_find_device_by_of_node() helper Suzuki K Poulose
                   ` (52 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Ulf Hansson, Joe Perches

Instead of spilling the match function to check the of_node for
a given value, lets add a common helper. Also add a wrapper to
find device by of_node pointer for bus.

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 ++++++
 include/linux/device.h | 17 +++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index fd7511e..d20699c 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, void *np)
+{
+	return dev->of_node == np;
+}
+EXPORT_SYMBOL_GPL(device_match_of_node);
diff --git a/include/linux/device.h b/include/linux/device.h
index e85264f..fe16be4 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, 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,
@@ -171,6 +173,21 @@ struct device *bus_find_device(struct bus_type *bus, struct device *start,
 struct device *bus_find_device_by_name(struct bus_type *bus,
 				       struct device *start,
 				       const char *name);
+
+/**
+ * bus_find_device_by_of_node : device iterator for locating a particular device
+ * matching the of_node.
+ * @bus: bus type
+ * @start: Device to begin with
+ * @np: of_node of the device to match.
+ */
+static inline struct device *bus_find_device_by_of_node(struct bus_type *bus,
+							struct device *start,
+							struct device_node *np)
+{
+	return bus_find_device(bus, start, 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,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 05/57] drm: mipi_dsi: Use bus_find_device_by_of_node() helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (3 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 04/57] drivers: Add generic match helper to match the device of_node Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 06/57] drivers: i2c: i2c-core: Use bus_find_device_by_of_node helper Suzuki K Poulose
                   ` (51 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Maarten Lankhorst, Maxime Ripard,
	dri-devel, David Airlie, Daniel Vetter

Switch to using the bus_find_device_by_of_node() 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>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/gpu/drm/drm_mipi_dsi.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index 80b7550..4c5a397 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, 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, NULL, np);
 
 	return dev ? to_mipi_dsi_device(dev) : NULL;
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 06/57] drivers: i2c: i2c-core: Use bus_find_device_by_of_node helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (4 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 05/57] drm: mipi_dsi: Use bus_find_device_by_of_node() helper Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 07/57] drivers: nvmem: " Suzuki K Poulose
                   ` (50 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Wolfram Sang, linux-i2c

Switch to using the bus_find_device_by_of_node helper.

Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-i2c@vger.kernel.org
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/i2c/i2c-core-of.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c
index 406e5f6..b0b3fe1 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, void *data)
-{
-	return dev->of_node == data;
-}
-
 static int of_dev_or_parent_node_match(struct device *dev, 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, NULL, node);
 	if (!dev)
 		return NULL;
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 07/57] drivers: nvmem: Use bus_find_device_by_of_node helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (5 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 06/57] drivers: i2c: i2c-core: Use bus_find_device_by_of_node helper Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 08/57] drivers: spi: " Suzuki K Poulose
                   ` (49 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Srinivas Kandagatla

Switch to using the bus_find_device_by_of_node helper

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/nvmem/core.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index c7892c3..63947d3 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, 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, NULL, nvmem_np);
 
 	if (!d)
 		return NULL;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 08/57] drivers: spi: Use bus_find_device_by_of_node helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (6 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 07/57] drivers: nvmem: " Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 16:04   ` Mark Brown
  2019-06-03 15:49 ` [RFC PATCH 09/57] drivers: sound: rockchip: rk3399: " Suzuki K Poulose
                   ` (48 subsequent siblings)
  56 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Mark Brown, linux-spi

Switch to using the bus_find_device_by_of_node helper

Cc: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/spi/spi.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 5e75944..ecdd602 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, 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, NULL, node);
+
 	return dev ? to_spi_device(dev) : NULL;
 }
 EXPORT_SYMBOL_GPL(of_find_spi_device_by_node);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 09/57] drivers: sound: rockchip: rk3399: Use bus_find_device_by_of_node helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (7 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 08/57] drivers: spi: " Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 16:02   ` Mark Brown
  2019-06-03 15:49 ` [RFC PATCH 10/57] drivers: coresight: " Suzuki K Poulose
                   ` (47 subsequent siblings)
  56 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Heiko Stuebner, Takashi Iwai,
	Mark Brown, Liam Girdwood, linux-rockchip

Switch to using the bus_find_device_by_of_node helper

Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-rockchip@lists.infradead.org
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 sound/soc/rockchip/rk3399_gru_sound.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c
index 3d0cc6e..677c92c 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, 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,
+							 NULL, np_codec);
 			if (!dev)
 				continue;
 			put_device(dev);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 10/57] drivers: coresight: Use bus_find_device_by_of_node helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (8 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 09/57] drivers: sound: rockchip: rk3399: " Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 11/57] of: mdio: " Suzuki K Poulose
                   ` (46 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Mathieu Poirier

Switch to using the bus_find_device_by_of_node helper

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/hwtracing/coresight/of_coresight.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c
index 7045930..9b7a0c0 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, 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, NULL, 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, NULL, endpoint);
 }
 
 static inline bool of_coresight_legacy_ep_is_input(struct device_node *ep)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 11/57] of: mdio: Use bus_find_device_by_of_node helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (9 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 10/57] drivers: coresight: " Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 16:00   ` Andrew Lunn
  2019-06-03 15:49 ` [RFC PATCH 12/57] of: platform: " Suzuki K Poulose
                   ` (45 subsequent siblings)
  56 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Andrew Lunn, Florian Fainelli,
	Rob Herring, Frank Rowand

Switch to using the bus_find_device_by_of_node helper

Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/of/of_mdio.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index de61573..f15cf8e 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -281,12 +281,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, 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
@@ -302,7 +296,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, NULL, phy_np);
 	if (d) {
 		mdiodev = to_mdio_device(d);
 		if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 12/57] of: platform: Use bus_find_device_by_of_node helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (10 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 11/57] of: mdio: " Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-10 20:44   ` Rob Herring
  2019-06-03 15:49 ` [RFC PATCH 13/57] drivers: Add generic helper for matching device by fwnode Suzuki K Poulose
                   ` (44 subsequent siblings)
  56 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Frank Rowand, Rob Herring, devicetree

Switch to using the bus_find_device_by_of_node helper

Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/of/platform.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 04ad312..b1e3a51 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, 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, NULL, np);
 	return dev ? to_platform_device(dev) : NULL;
 }
 EXPORT_SYMBOL(of_find_device_by_node);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 13/57] drivers: Add generic helper for matching device by fwnode
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (11 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 12/57] of: platform: " Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 14/57] drivers: devcon: Use bus_find_device_by_fwnode helper Suzuki K Poulose
                   ` (43 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Ulf Hansson

Instead of spilling the match function to check the device fwnode
everywhere, let us add a generic helper which can be reused by all.
Also adds a wrapper for bus_find_device to find a device by fwnode.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/base/core.c    |  6 ++++++
 include/linux/device.h | 15 +++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index d20699c..141c4f8 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3334,3 +3334,9 @@ int device_match_of_node(struct device *dev, void *np)
 	return dev->of_node == np;
 }
 EXPORT_SYMBOL_GPL(device_match_of_node);
+
+int device_match_fwnode(struct device *dev, 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 fe16be4..54be931 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, void *np);
+int device_match_fwnode(struct device *dev, void *fwnode);
 
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 		     int (*fn)(struct device *dev, void *data));
@@ -188,6 +189,20 @@ static inline struct device *bus_find_device_by_of_node(struct bus_type *bus,
 	return bus_find_device(bus, start, np, device_match_of_node);
 }
 
+/**
+ * bus_find_device_by_fwnode : device iterator for locating a particular device
+ * matching the fwnode.
+ * @bus: bus type
+ * @start: Device to begin with
+ * @fwnode: fwnode of the device to match.
+ */
+static inline struct device *bus_find_device_by_fwnode(struct bus_type *bus,
+						       struct device *start,
+						       struct fwnode_handle *fwnode)
+{
+	return bus_find_device(bus, start, 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,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 14/57] drivers: devcon: Use bus_find_device_by_fwnode helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (12 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 13/57] drivers: Add generic helper for matching device by fwnode Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 15/57] net: hisilicon: hnfs:Use " Suzuki K Poulose
                   ` (42 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose

Switch to using the bus_find_device_by_fwnode helper

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/devcon.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/base/devcon.c b/drivers/base/devcon.c
index 04db9ae..d9bcf77 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, 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, NULL, con->fwnode);
 		if (dev && !strncmp(dev_name(dev), con->id, strlen(con->id)))
 			return dev;
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 15/57] net: hisilicon: hnfs:Use bus_find_device_by_fwnode helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (13 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 14/57] drivers: devcon: Use bus_find_device_by_fwnode helper Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 16/57] net: hns_roce: Use " Suzuki K Poulose
                   ` (41 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, David S. Miller

Switch to using the bus_find_device_by_fwnode helper

Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
index 09c16d8..b801ab7 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, 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, NULL, fwnode);
 	return dev ? to_platform_device(dev) : NULL;
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 16/57] net: hns_roce: Use bus_find_device_by_fwnode helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (14 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 15/57] net: hisilicon: hnfs:Use " Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 16:05   ` Jason Gunthorpe
  2019-06-03 15:49 ` [RFC PATCH 17/57] drivers: Add generic match by device type helper Suzuki K Poulose
                   ` (40 subsequent siblings)
  56 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Doug Ledford, Jason Gunthorpe

Switch to using the bus_find_device_by_fwnode helper

Cc: Doug Ledford <dledford@redhat.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
index 4c5d0f1..0985078 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
@@ -4497,19 +4497,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, 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, NULL, fwnode);
 	/* get the platform device */
 	return dev ? to_platform_device(dev) : NULL;
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 17/57] drivers: Add generic match by device type helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (15 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 16/57] net: hns_roce: Use " Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 18/57] drivers: intel_th: Use bus_find_device_by_devt helper Suzuki K Poulose
                   ` (39 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Ulf Hansson

Add a generic helper routine to match the device type of
a given device.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/base/core.c    |  6 ++++++
 include/linux/device.h | 15 +++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 141c4f8..9df812f 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3340,3 +3340,9 @@ int device_match_fwnode(struct device *dev, void *fwnode)
 	return dev_fwnode(dev) == fwnode;
 }
 EXPORT_SYMBOL_GPL(device_match_fwnode);
+
+int device_match_devt(struct device *dev, 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 54be931..83c0745 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, void *np);
 int device_match_fwnode(struct device *dev, void *fwnode);
+int device_match_devt(struct device *dev, void *pdevt);
 
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 		     int (*fn)(struct device *dev, void *data));
@@ -203,6 +204,20 @@ static inline struct device *bus_find_device_by_fwnode(struct bus_type *bus,
 	return bus_find_device(bus, start, fwnode, device_match_fwnode);
 }
 
+/**
+ * bus_find_device_by_devt : device iterator for locating a particular device
+ * matching the device type.
+ * @bus: bus type
+ * @start: Device to begin with
+ * @devt: device type of the device to match.
+ */
+static inline struct device *bus_find_device_by_devt(struct bus_type *bus,
+						     struct device *start,
+						     dev_t devt)
+{
+	return bus_find_device(bus, start, &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,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 18/57] drivers: intel_th: Use bus_find_device_by_devt helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (16 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 17/57] drivers: Add generic match by device type helper Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 19/57] drivers: usb: core: " Suzuki K Poulose
                   ` (38 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Alexander Shishkin

Switch to using the bus_find_device_by_devt helper

Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/hwtracing/intel_th/core.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c
index 033dce5..a85e236 100644
--- a/drivers/hwtracing/intel_th/core.c
+++ b/drivers/hwtracing/intel_th/core.c
@@ -789,13 +789,6 @@ static int intel_th_populate(struct intel_th *th)
 	return 0;
 }
 
-static int match_devt(struct device *dev, void *data)
-{
-	dev_t devt = (dev_t)(unsigned long)data;
-
-	return dev->devt == devt;
-}
-
 static int intel_th_output_open(struct inode *inode, struct file *file)
 {
 	const struct file_operations *fops;
@@ -803,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, NULL, inode->i_rdev);
 	if (!dev || !dev->driver)
 		return -ENODEV;
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 19/57] drivers: usb: core: Use bus_find_device_by_devt helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (17 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 18/57] drivers: intel_th: Use bus_find_device_by_devt helper Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 20/57] platform: Add a helper to find device by driver Suzuki K Poulose
                   ` (37 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Oliver Neukum,
	Sebastian Andrzej Siewior, linux-usb

Switch to using the bus_find_device_by_devt helper

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Oliver Neukum <oneukum@suse.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-usb@vger.kernel.org
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/usb/core/devio.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index fa783531..28358a3 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, void *data)
-{
-	return dev->devt == (dev_t) (unsigned long) 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, NULL, devt);
 	if (!dev)
 		return NULL;
 	return to_usb_device(dev);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 20/57] platform: Add a helper to find device by driver
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (18 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 19/57] drivers: usb: core: " Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-04 13:29   ` Heiko Stuebner
  2019-06-03 15:49 ` [RFC PATCH 21/57] drivers: Add generic match helper by ACPI_COMPANION device Suzuki K Poulose
                   ` (36 subsequent siblings)
  56 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Inki Dae, Seung-Woo Kim,
	Sandy Huang, Heiko Stübner, Eric Anholt

There are a couple of places where we reuse platform specific
match to find a device. Instead of spilling the global varilable
everywhere, let us provide a helper to do the same.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: Eric Anholt <eric@anholt.net>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 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(-)

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 4d17298..daca44f 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, (void *)drv,
+			       (int (*)(struct device *, 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 cb938d3..4eb4fb8 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -338,8 +338,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 cc46485..a82b3ec 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -52,6 +52,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 dev*,
+			       const struct device_driver *drv);
 extern void __iomem *
 devm_platform_ioremap_resource(struct platform_device *pdev,
 			       unsigned int index);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 21/57] drivers: Add generic match helper by ACPI_COMPANION device
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (19 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 20/57] platform: Add a helper to find device by driver Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 22/57] drivers: i2c: Use generic helper to match device by acpi_dev Suzuki K Poulose
                   ` (35 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose

Add a generic helper to match a device by the acpi device.

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 9df812f..db19185 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3335,6 +3335,12 @@ int device_match_of_node(struct device *dev, void *np)
 }
 EXPORT_SYMBOL_GPL(device_match_of_node);
 
+int device_match_acpi_dev(struct device *dev, void *adev)
+{
+	return ACPI_COMPANION(dev) == adev;
+}
+EXPORT_SYMBOL(device_match_acpi_dev);
+
 int device_match_fwnode(struct device *dev, void *fwnode)
 {
 	return dev_fwnode(dev) == fwnode;
diff --git a/include/linux/device.h b/include/linux/device.h
index 83c0745..6ad1a27 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, void *np);
+int device_match_acpi_dev(struct device *dev, void *adev);
 int device_match_fwnode(struct device *dev, void *fwnode);
 int device_match_devt(struct device *dev, void *pdevt);
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 22/57] drivers: i2c: Use generic helper to match device by acpi_dev
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (20 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 21/57] drivers: Add generic match helper by ACPI_COMPANION device Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-04  9:27   ` Mika Westerberg
  2019-06-06 20:03   ` Wolfram Sang
  2019-06-03 15:49 ` [RFC PATCH 23/57] drivers: spi: Use bus_find_device_by_acpi_dev match helper Suzuki K Poulose
                   ` (34 subsequent siblings)
  56 siblings, 2 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Mika Westerberg, Wolfram Sang, linux-i2c

Switch to the generic helper to match device by acpi_dev.

Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
cc: linux-i2c@vger.kernel.org
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/i2c/i2c-core-acpi.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index d840955..e28165b 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, void *data)
 	return ACPI_HANDLE(dev) == (acpi_handle)data;
 }
 
-static int i2c_acpi_find_match_device(struct device *dev, 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(&i2c_bus_type, NULL, adev, device_match_acpi_dev);
 	return dev ? i2c_verify_client(dev) : NULL;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 23/57] drivers: spi: Use bus_find_device_by_acpi_dev match helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (21 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 22/57] drivers: i2c: Use generic helper to match device by acpi_dev Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 16:04   ` Mark Brown
  2019-06-03 15:49 ` [RFC PATCH 24/57] drivers: staging: most-core: Use bus_find_device_by_name Suzuki K Poulose
                   ` (33 subsequent siblings)
  56 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Mark Brown, linux-spi

Switch to the generic helper bus_find_device_by_acpi_dev.

Cc: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/spi/spi.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index ecdd602..5224ded 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -3634,11 +3634,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, void *data)
-{
-	return ACPI_COMPANION(dev) == data;
-}
-
 static struct spi_controller *acpi_spi_find_controller_by_adev(struct acpi_device *adev)
 {
 	struct device *dev;
@@ -3658,8 +3653,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(&spi_bus_type, NULL, adev, device_match_acpi_dev);
 	return dev ? to_spi_device(dev) : NULL;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 24/57] drivers: staging: most-core: Use bus_find_device_by_name
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (22 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 23/57] drivers: spi: Use bus_find_device_by_acpi_dev match helper Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 25/57] drivers: Add generic match by name helper Suzuki K Poulose
                   ` (32 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose

Use bus_find_device_by_name() helper.

Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/staging/most/core.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

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);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 25/57] drivers: Add generic match by name helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (23 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 24/57] drivers: staging: most-core: Use bus_find_device_by_name Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 26/57] drivers: acpi: Clean up acpi_dev_match_cb Suzuki K Poulose
                   ` (31 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose

Add a generic helper to match a device by its name. Also use the generic
match by device name helper for bus_find_device_by_name. Since the new
match function is also exported, let us convert this to a static inline
function.

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/bus.c     | 24 ------------------------
 drivers/base/core.c    |  6 ++++++
 include/linux/device.h | 21 ++++++++++++++++++---
 3 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 0a58e96..229e83ee 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, 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 db19185..88fa037 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3352,3 +3352,9 @@ int device_match_devt(struct device *dev, void *pdevt)
 	return dev->devt == *(dev_t *)pdevt;
 }
 EXPORT_SYMBOL_GPL(device_match_devt);
+
+int device_match_name(struct device *dev, 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 6ad1a27..b4a9cd2 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -167,15 +167,30 @@ int device_match_of_node(struct device *dev, void *np);
 int device_match_acpi_dev(struct device *dev, void *adev);
 int device_match_fwnode(struct device *dev, void *fwnode);
 int device_match_devt(struct device *dev, void *pdevt);
+int device_match_name(struct device *dev, 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,
 			       void *data,
 			       int (*match)(struct device *dev, 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
+ *
+ * This is similar to the bus_find_device() function, but it handles
+ * searching by a name automatically.
+ */
+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, (void *)name, device_match_name);
+}
 
 /**
  * bus_find_device_by_of_node : device iterator for locating a particular device
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 26/57] drivers: acpi: Clean up acpi_dev_match_cb
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (24 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 25/57] drivers: Add generic match by name helper Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 27/57] drivers: Unify the match prototype for bus_find_device with class_find_device Suzuki K Poulose
                   ` (30 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Rafael J. Wysocki, Len Brown, linux-acpi

acpi_dev_match_cb match function modifies the "data" argument
to pass on a result which could be easily deduced from the result
of the bus_find_device() call at the caller site. Clean this
up in preparation to convert the "match" argument for bus_find_device.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/acpi/utils.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 7def63a..1391b63 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -725,8 +725,6 @@ bool acpi_dev_found(const char *hid)
 EXPORT_SYMBOL(acpi_dev_found);
 
 struct acpi_dev_match_info {
-	const char *dev_name;
-	struct acpi_device *adev;
 	struct acpi_device_id hid[2];
 	const char *uid;
 	s64 hrv;
@@ -746,9 +744,6 @@ static int acpi_dev_match_cb(struct device *dev, void *data)
 	    strcmp(adev->pnp.unique_id, match->uid)))
 		return 0;
 
-	match->dev_name = acpi_dev_name(adev);
-	match->adev = adev;
-
 	if (match->hrv == -1)
 		return 1;
 
@@ -818,7 +813,7 @@ acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
 	match.hrv = hrv;
 
 	dev = bus_find_device(&acpi_bus_type, NULL, &match, acpi_dev_match_cb);
-	return dev ? match.adev : NULL;
+	return dev ? to_acpi_device(dev) : NULL;
 }
 EXPORT_SYMBOL(acpi_dev_get_first_match_dev);
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 27/57] drivers: Unify the match prototype for bus_find_device with class_find_device
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (25 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 26/57] drivers: acpi: Clean up acpi_dev_match_cb Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-04  6:52   ` Harald Freudenberger
  2019-06-04 11:26   ` Rafael J. Wysocki
  2019-06-03 15:49 ` [RFC PATCH 28/57] drivers: class: Add variants of class_find_device() Suzuki K Poulose
                   ` (29 subsequent siblings)
  56 siblings, 2 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Alexander Shishkin, Wolfram Sang,
	Jonathan Cameron, Hartmut Knaack, Grygorii Strashko,
	David S. Miller, Bjorn Helgaas, Sebastian Ott,
	Peter Oberparleiter, Harald Freudenberger, James E.J. Bottomley,
	Martin K. Petersen, Andreas Noever, Michael Jamet, Felipe Balbi,
	David Kershner

We have iterators for devices by bus and class, with a supplied
"match" function to do the comparison. However, both of the helper
function have slightly different prototype for the "match" argument.

 int (*) (struct device *dev, void *data)  // bus_find_device
  vs
 int (*) (struct device *dev, const void *data) // class_find_device

Unify the prototype by promoting the match function to use that of
the class_find_device(). This will allow us to share the generic
match helpers with class_find_device() users.

Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Sebastian Ott <sebott@linux.ibm.com>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Andreas Noever <andreas.noever@gmail.com>
Cc: Michael Jamet <michael.jamet@intel.com>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: David Kershner <david.kershner@unisys.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 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                       |  2 +-
 drivers/base/core.c                      | 10 +++++-----
 drivers/base/platform.c                  |  2 +-
 drivers/char/ipmi/ipmi_si_platform.c     |  2 +-
 drivers/firmware/efi/dev-path-parser.c   |  4 ++--
 drivers/hwtracing/coresight/coresight.c  |  6 +++---
 drivers/i2c/i2c-core-acpi.c              |  2 +-
 drivers/i2c/i2c-core-of.c                |  2 +-
 drivers/iio/inkern.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/pci/probe.c                      |  2 +-
 drivers/pci/search.c                     |  4 ++--
 drivers/s390/cio/css.c                   |  4 ++--
 drivers/s390/cio/device.c                |  4 ++--
 drivers/s390/crypto/ap_bus.c             |  4 ++--
 drivers/scsi/scsi_proc.c                 |  2 +-
 drivers/thunderbolt/switch.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                   | 13 ++++++-------
 28 files changed, 54 insertions(+), 55 deletions(-)

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 a34decc..fcf4386 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -454,7 +454,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 229e83ee..abe32b6 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -324,7 +324,7 @@ EXPORT_SYMBOL_GPL(bus_for_each_dev);
  */
 struct device *bus_find_device(struct bus_type *bus,
 			       struct device *start, void *data,
-			       int (*match)(struct device *dev, void *data))
+			       int (*match)(struct device *dev, const void *data))
 {
 	struct klist_iter i;
 	struct device *dev;
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 88fa037..731baac 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3329,31 +3329,31 @@ void device_set_of_node_from_dev(struct device *dev, const struct device *dev2)
 }
 EXPORT_SYMBOL_GPL(device_set_of_node_from_dev);
 
-int device_match_of_node(struct device *dev, void *np)
+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_acpi_dev(struct device *dev, void *adev)
+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_fwnode(struct device *dev, void *fwnode)
+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, void *pdevt)
+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_name(struct device *dev, void *name)
+int device_match_name(struct device *dev, const void *name)
 {
 	return sysfs_streq(dev_name(dev), name);
 }
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index daca44f..55ce86f 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1207,7 +1207,7 @@ struct device *platform_find_device_by_driver(struct device *start,
 					      const struct device_driver *drv)
 {
 	return bus_find_device(&platform_bus_type, start, (void *)drv,
-			       (int (*)(struct device *, void *))platform_match);
+			       (int (*)(struct device *, const void *))platform_match);
 }
 EXPORT_SYMBOL_GPL(platform_find_device_by_driver);
 
diff --git a/drivers/char/ipmi/ipmi_si_platform.c b/drivers/char/ipmi/ipmi_si_platform.c
index ff82353..99233f3 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/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
index 37ccd67..8231a0e 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/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index e28165b..cd6ff7a 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);
 
diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c
index b0b3fe1..e7f84d8 100644
--- a/drivers/i2c/i2c-core-of.c
+++ b/drivers/i2c/i2c-core-of.c
@@ -112,7 +112,7 @@ void of_i2c_register_devices(struct i2c_adapter *adap)
 	of_node_put(bus);
 }
 
-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/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/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..7b8488d 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;
+	const struct subchannel_id *schid = 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..6ca9a3a 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;
+	const struct ccw_dev_id *dev_id = data;
 
 	return ccw_dev_id_is_equal(&cdev->private->dev_id, dev_id);
 }
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index b9fc502..e440682 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -1365,7 +1365,7 @@ static int __match_card_device_with_id(struct device *dev, 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/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/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 b4a9cd2..e8d1267 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -163,18 +163,17 @@ 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, void *np);
-int device_match_acpi_dev(struct device *dev, void *adev);
-int device_match_fwnode(struct device *dev, void *fwnode);
-int device_match_devt(struct device *dev, void *pdevt);
-int device_match_name(struct device *dev, void *name);
+int device_match_of_node(struct device *dev, const void *np);
+int device_match_acpi_dev(struct device *dev, const void *adev);
+int device_match_fwnode(struct device *dev, const void *fwnode);
+int device_match_devt(struct device *dev, const void *pdevt);
+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,
 			       void *data,
-			       int (*match)(struct device *dev, void *data));
-
+			       int (*match)(struct device *dev, const void *data));
 /**
  * bus_find_device_by_name - device iterator for locating a particular device
  * of a specific name.
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 28/57] drivers: class: Add variants of class_find_device()
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (26 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 27/57] drivers: Unify the match prototype for bus_find_device with class_find_device Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 29/57] drivers: stm: Use class_find_device_by_name() helper Suzuki K Poulose
                   ` (28 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose

Similar to the bus_find_device_by_*() helpers add wrappers
for class_find_device() to find devices by generic attributes.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 include/linux/device.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/include/linux/device.h b/include/linux/device.h
index e8d1267..1945c3d 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -528,6 +528,64 @@ extern int class_for_each_device(struct class *class, struct device *start,
 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: the class we're iterating
+ * @start: Device to begin with
+ * @name: name of the device to match
+ *
+ * This is similar to the class_find_device() above, but it handles searching
+ * by a name automatically.
+ */
+static inline struct device *class_find_device_by_name(struct class *class,
+						       struct device *start,
+						       const void *name)
+{
+	return class_find_device(class, start, name, device_match_name);
+}
+
+/**
+ * class_find_device_by_devt - device iterator for locating a particular device
+ * by devt.
+ * @class: the class we're iterating
+ * @start: Device to begin with
+ * @devt: devt of the device to match
+ */
+static inline struct device *class_find_device_by_devt(struct class *class,
+						       struct device *start,
+						       dev_t devt)
+{
+	return class_find_device(class, start, &devt, device_match_devt);
+}
+
+/**
+ * class_find_device_by_of_node - device iterator for locating a particular device
+ * by of_node.
+ * @class: the class we're iterating
+ * @start: Device to begin with
+ * @np: of_node of the device to match
+ */
+static inline struct device *class_find_device_by_of_node(struct class *class,
+							  struct device *start,
+							  struct device_node *np)
+{
+	return class_find_device(class, start, np, device_match_of_node);
+}
+
+/**
+ * class_find_device_by_fwnode - device iterator for locating a particular device
+ * by fwnode.
+ * @class: the class we're iterating
+ * @start: Device to begin with
+ * @fwnode: fwnode of the device to match
+ */
+static inline struct device *class_find_device_by_fwnode(struct class *class,
+							  struct device *start,
+							  struct fwnode_handle *fwnode)
+{
+	return class_find_device(class, start, fwnode, device_match_fwnode);
+}
 
 struct class_attribute {
 	struct attribute attr;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 29/57] drivers: stm: Use class_find_device_by_name() helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (27 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 28/57] drivers: class: Add variants of class_find_device() Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 30/57] drivers: leds: " Suzuki K Poulose
                   ` (27 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Alexander Shishkin, Maxime Coquelin

Use the new class_find_device_by_name() helper.

Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/hwtracing/stm/core.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
index e55b902..e110958 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, NULL, buf);
 	if (!dev)
 		return NULL;
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 30/57] drivers: leds: Use class_find_device_by_name() helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (28 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 29/57] drivers: stm: Use class_find_device_by_name() helper Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-04  8:35   ` Pavel Machek
  2019-06-03 15:49 ` [RFC PATCH 31/57] drivers: rtc: " Suzuki K Poulose
                   ` (26 subsequent siblings)
  56 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Jacek Anaszewski, Pavel Machek,
	Dan Murphy, linux-leds

Use the new class_find_device_by_name() helper.

Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Dan Murphy <dmurphy@ti.com>
Cc: linux-leds@vger.kernel.org
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/leds/led-class.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 85848c5..ee052aa 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, NULL, name))) {
 		put_device(dev);
 		ret = snprintf(name, len, "%s_%u", init_name, ++i);
 	}
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 31/57] drivers: rtc: Use class_find_device_by_name() helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (29 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 30/57] drivers: leds: " Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:49 ` [RFC PATCH 32/57] drivers: s390-crypto: Use class_device_find_by_name() helper Suzuki K Poulose
                   ` (25 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Alessandro Zummo,
	Alexandre Belloni, linux-rtc

Use the new class_find_device_by_name() helper.

Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-rtc@vger.kernel.org
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/rtc/interface.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 4124f4d..307dbc6 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, NULL, name);
 	if (dev)
 		rtc = to_rtc_device(dev);
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 32/57] drivers: s390-crypto: Use class_device_find_by_name() helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (30 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 31/57] drivers: rtc: " Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-04  6:45   ` Harald Freudenberger
  2019-06-03 15:49 ` [RFC PATCH 33/57] drivers: usb: Use class_find_device_by_name() helper Suzuki K Poulose
                   ` (24 subsequent siblings)
  56 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Harald Freudenberger,
	Martin Schwidefsky, Heiko Carstens

Use the new class_find_device_by_name() helper.

Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/s390/crypto/zcrypt_api.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c
index 1058b4b..16cad8e 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,8 @@ 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,
+							NULL, (void *) name);
 
 	return dev ? to_zcdn_dev(dev) : NULL;
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 33/57] drivers: usb: Use class_find_device_by_name() helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (31 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 32/57] drivers: s390-crypto: Use class_device_find_by_name() helper Suzuki K Poulose
@ 2019-06-03 15:49 ` Suzuki K Poulose
  2019-06-03 15:50 ` [RFC PATCH 34/57] drivers: ieee802154: " Suzuki K Poulose
                   ` (23 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Heikki Krogerus, linux-usb

Use the new class_find_device_by_name() helper.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: linux-usb@vger.kernel.org
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/usb/roles/class.c | 8 +-------
 drivers/usb/typec/class.c | 8 +-------
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
index f45d8df..3dc78cb 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, NULL, 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..c11cc5f 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, NULL, con->endpoint[ep]);
 
 	return dev ? dev : ERR_PTR(-EPROBE_DEFER);
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 34/57] drivers: ieee802154: Use class_find_device_by_name() helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (32 preceding siblings ...)
  2019-06-03 15:49 ` [RFC PATCH 33/57] drivers: usb: Use class_find_device_by_name() helper Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 15:50 ` [RFC PATCH 35/57] drivers: core: Reuse generic match by device type helper Suzuki K Poulose
                   ` (22 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Alexander Aring, Stefan Schmidt,
	linux-wpan

Use the new class_find_device_by_name() helper.

Cc: Alexander Aring <alex.aring@gmail.com>
Cc: Stefan Schmidt <stefan@datenfreihafen.org>
Cc: linux-wpan@vger.kernel.org
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 net/ieee802154/core.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/net/ieee802154/core.c b/net/ieee802154/core.c
index 60b7ac5..26fe751 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, NULL, str);
 	if (!dev)
 		return NULL;
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 35/57] drivers: core: Reuse generic match by device type helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (33 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 34/57] drivers: ieee802154: " Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 15:50 ` [RFC PATCH 36/57] drivers: mei: Use class_find_device_by_devt match helper Suzuki K Poulose
                   ` (21 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose

Use the generic helper to match the device type of a given device.

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 | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 731baac..69cba57 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, NULL, devt);
 	if (dev) {
 		put_device(dev);
 		device_unregister(dev);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 36/57] drivers: mei: Use class_find_device_by_devt match helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (34 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 35/57] drivers: core: Reuse generic match by device type helper Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 18:00   ` Winkler, Tomas
  2019-06-03 15:50 ` [RFC PATCH 37/57] drivers: s390: zcrypt: Use class_find_device_by_devt helper Suzuki K Poulose
                   ` (20 subsequent siblings)
  56 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Tomas Winkler, Arnd Bergmann

Switch to the generic helper class_find_device_by_devt.

Cc: Tomas Winkler <tomas.winkler@intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/misc/mei/main.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index ad02097..243b481 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, NULL, dev->cdev.dev);
 	if (clsdev) {
 		sysfs_notify(&clsdev->kobj, NULL, "dev_state");
 		put_device(clsdev);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 37/57] drivers: s390: zcrypt: Use class_find_device_by_devt helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (35 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 36/57] drivers: mei: Use class_find_device_by_devt match helper Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-04  6:47   ` Harald Freudenberger
  2019-06-03 15:50 ` [RFC PATCH 38/57] drivers: fpga: Use generic helpers to match by of_node Suzuki K Poulose
                   ` (19 subsequent siblings)
  56 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Harald Freudenberger, Heiko Carstens

Use the generic helper to find a device matching the devt.

Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/s390/crypto/zcrypt_api.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c
index 16cad8e..99c9b77 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
@@ -159,10 +153,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, NULL, devt);
 
 	return dev ? to_zcdn_dev(dev) : NULL;
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 38/57] drivers: fpga: Use generic helpers to match by of_node
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (36 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 37/57] drivers: s390: zcrypt: Use class_find_device_by_devt helper Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 15:50 ` [RFC PATCH 39/57] drivers: mux: Use class_find_device_by_of_node helper Suzuki K Poulose
                   ` (18 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Alan Tull, Moritz Fischer, linux-fpga

Use the generic helpers available to find device matching of_node.

Cc: Alan Tull <atull@kernel.org>
Cc: Moritz Fischer <mdf@kernel.org>
Cc: linux-fpga@vger.kernel.org
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/fpga/fpga-bridge.c    | 8 +-------
 drivers/fpga/fpga-mgr.c       | 8 +-------
 drivers/fpga/of-fpga-region.c | 7 +------
 3 files changed, 3 insertions(+), 20 deletions(-)

diff --git a/drivers/fpga/fpga-bridge.c b/drivers/fpga/fpga-bridge.c
index 80bd8f1..f1222a9 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, NULL, np);
 	if (!dev)
 		return ERR_PTR(-ENODEV);
 
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index c386681..78d2ddb1 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, NULL, node);
 	if (!dev)
 		return ERR_PTR(-ENODEV);
 
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);
 }
 
 /**
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 39/57] drivers: mux: Use class_find_device_by_of_node helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (37 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 38/57] drivers: fpga: Use generic helpers to match by of_node Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 16:22   ` Peter Rosin
  2019-06-03 15:50 ` [RFC PATCH 40/57] drivers: spi: " Suzuki K Poulose
                   ` (17 subsequent siblings)
  56 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Peter Rosin

Use the generic helper to find a device matching the of_node.

Cc: Peter Rosin <peda@axentia.se>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/mux/core.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/mux/core.c b/drivers/mux/core.c
index d1271c1..3591e40 100644
--- a/drivers/mux/core.c
+++ b/drivers/mux/core.c
@@ -405,18 +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, NULL, np);
 	return dev ? to_mux_chip(dev) : NULL;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 40/57] drivers: spi: Use class_find_device_by_of_node helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (38 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 39/57] drivers: mux: Use class_find_device_by_of_node helper Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 15:50 ` [RFC PATCH 41/57] drivers: net: phy: " Suzuki K Poulose
                   ` (16 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose

Use the generic helper to find a device matching the of_node.

Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/spi/spi.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 5224ded..e1295e9 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -3549,21 +3549,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, NULL, 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, NULL, node);
 	if (!dev)
 		return NULL;
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 41/57] drivers: net: phy: Use class_find_device_by_of_node helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (39 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 40/57] drivers: spi: " Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 16:02   ` Andrew Lunn
  2019-06-03 15:50 ` [RFC PATCH 42/57] drivers: regulator: " Suzuki K Poulose
                   ` (15 subsequent siblings)
  56 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Andrew Lunn, Florian Fainelli,
	Heiner Kallweit, David S. Miller

Use the generic helper to find a device matching the of_node.

Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/net/phy/mdio_bus.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index bd04fe7..c868a40 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, NULL,  mdio_bus_np);
 	return d ? to_mii_bus(d) : NULL;
 }
 EXPORT_SYMBOL(of_mdio_find_bus);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 42/57] drivers: regulator: Use class_find_device_by_of_node helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (40 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 41/57] drivers: net: phy: " Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 16:04   ` Mark Brown
  2019-06-03 15:50 ` [RFC PATCH 43/57] drivers: tty : " Suzuki K Poulose
                   ` (14 subsequent siblings)
  56 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Liam Girdwood, Mark Brown

Use the generic helper to find a device matching the of_node.

Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/regulator/of_regulator.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 0ead116..1485f6e 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(&regulator_class, NULL, np, of_node_match);
+	dev = class_find_device_by_of_node(&regulator_class, NULL, np);
 
 	return dev ? dev_to_rdev(dev) : NULL;
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 43/57] drivers: tty : Use class_find_device_by_of_node helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (41 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 42/57] drivers: regulator: " Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 15:50 ` [RFC PATCH 44/57] drivers: usb : Use class_find_device_by_fwnode() helper Suzuki K Poulose
                   ` (13 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Jiri Slaby

Use the generic helper to find a device matching the of_node.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/tty/tty_io.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 033ac7e..b078fdb 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, NULL, devt);
 }
 
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 44/57] drivers: usb : Use class_find_device_by_fwnode() helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (42 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 43/57] drivers: tty : " Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 15:50 ` [RFC PATCH 45/57] drivers: driver_find_device: Unify the match function Suzuki K Poulose
                   ` (12 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Heikki Krogerus, linux-usb

Reuse the generic helper to find a device by fwnode handle.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: linux-usb@vger.kernel.org
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/usb/roles/class.c | 8 +-------
 drivers/usb/typec/class.c | 8 +-------
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
index 3dc78cb..be9b70c 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, NULL, con->fwnode);
 	} else {
 		dev = class_find_device_by_name(role_class, NULL, con->endpoint[ep]);
 	}
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index c11cc5f..12f9759 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, NULL, con->fwnode);
 
 	dev = class_find_device_by_name(typec_class, NULL, con->endpoint[ep]);
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 45/57] drivers: driver_find_device: Unify the match function
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (43 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 44/57] drivers: usb : Use class_find_device_by_fwnode() helper Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 15:50 ` [RFC PATCH 46/57] driver: Add variants of driver_find_device() Suzuki K Poulose
                   ` (11 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Russell King, Thierry Reding,
	Will Deacon, Joerg Roedel, Peter Oberparleiter, Sebastian Ott,
	David Airlie, Daniel Vetter, Nehal Shah, Shyam Sundar S K,
	Lee Jones

Unify the match function parameter for driver_find_device
with that of the {bus,class}_find_device helpers, to allow
us to reuse the generic helpers.

Cc: Russell King <linux@armlinux.org.uk>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Sebastian Ott <sebott@linux.ibm.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Nehal Shah <nehal-bakulchandra.shah@amd.com>
Cc: Shyam Sundar S K <shyam-sundar.s-k@amd.com>
Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/amba/tegra-ahb.c             | 4 ++--
 drivers/base/driver.c                | 2 +-
 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/mfd/syscon.c                 | 2 +-
 drivers/s390/cio/ccwgroup.c          | 2 +-
 drivers/s390/cio/chsc_sch.c          | 2 +-
 drivers/s390/cio/device.c            | 2 +-
 include/linux/device.h               | 2 +-
 13 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/amba/tegra-ahb.c b/drivers/amba/tegra-ahb.c
index 3751d81..42175a6 100644
--- a/drivers/amba/tegra-ahb.c
+++ b/drivers/amba/tegra-ahb.c
@@ -143,10 +143,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..a10e9da 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -74,7 +74,7 @@ EXPORT_SYMBOL_GPL(driver_for_each_device);
  */
 struct device *driver_find_device(struct device_driver *drv,
 				  struct device *start, void *data,
-				  int (*match)(struct device *dev, 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 5e54cc0..4ce429b 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1431,7 +1431,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/mfd/syscon.c b/drivers/mfd/syscon.c
index 8ce1e41..4f39ba5 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -190,7 +190,7 @@ 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)
+static int syscon_match_pdevname(struct device *dev, const void *data)
 {
 	return !strcmp(dev_name(dev), (const char *)data);
 }
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index a006945..c554f16 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -606,7 +606,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 6ca9a3a..a5c2765 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 1945c3d..52d59d5 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -399,7 +399,7 @@ extern int __must_check driver_for_each_device(struct device_driver *drv,
 							 void *));
 struct device *driver_find_device(struct device_driver *drv,
 				  struct device *start, void *data,
-				  int (*match)(struct device *dev, 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);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 46/57] driver: Add variants of driver_find_device()
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (44 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 45/57] drivers: driver_find_device: Unify the match function Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 19:10   ` Greg KH
                     ` (2 more replies)
  2019-06-03 15:50 ` [RFC PATCH 47/57] drivers: mfd: Use driver_find_device_by_name helper Suzuki K Poulose
                   ` (10 subsequent siblings)
  56 siblings, 3 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose

Add a wrappers to lookup a device by name for a given driver, by various
generic properties of a device. This can avoid the proliferation of custom
match functions throughout the drivers.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/include/linux/device.h b/include/linux/device.h
index 52d59d5..68d6e04 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -401,6 +401,50 @@ struct device *driver_find_device(struct device_driver *drv,
 				  struct device *start, 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
+ * @start: Device to begin with
+ * @name: name of the device to match
+ */
+static inline struct device *driver_find_device_by_name(struct device_driver *drv,
+							struct device *start,
+							const char *name)
+{
+	return driver_find_device(drv, start, (void *)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
+ * @start: Device to begin with
+ * @np: of_node pointer to match.
+ */
+static inline struct device *
+driver_find_device_by_of_node(struct device_driver *drv,
+			      struct device *start,
+			      const struct device_node *np)
+{
+	return driver_find_device(drv, start, (void *)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
+ * @start: Device to begin with
+ * @fwnode: fwnode pointer to match.
+ */
+static inline struct device *
+driver_find_device_by_fwnode(struct device_driver *drv,
+			     struct device *start,
+			     const struct fwnode_handle *fwnode)
+{
+	return driver_find_device(drv, start, (void *)fwnode, device_match_fwnode);
+}
+
 void driver_deferred_probe_add(struct device *dev);
 int driver_deferred_probe_check_state(struct device *dev);
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 47/57] drivers: mfd: Use driver_find_device_by_name helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (45 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 46/57] driver: Add variants of driver_find_device() Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-04  9:45   ` Arnd Bergmann
  2019-06-03 15:50 ` [RFC PATCH 48/57] drivers: s390: cio: Use driver_find_by_name() helper Suzuki K Poulose
                   ` (9 subsequent siblings)
  56 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Lee Jones, Arnd Bergmann

Use the new driver_find_device_by_name() helper.

Cc: Lee Jones <lee.jones@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/mfd/syscon.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 4f39ba5..e51e39a 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -190,18 +190,12 @@ 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, const 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);
+	dev = driver_find_device_by_name(&syscon_driver.driver, NULL, s);
 	if (!dev)
 		return ERR_PTR(-EPROBE_DEFER);
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 48/57] drivers: s390: cio: Use driver_find_by_name() helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (46 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 47/57] drivers: mfd: Use driver_find_device_by_name helper Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 15:50 ` [RFC PATCH 49/57] drivers: mfd: altera: Use driver_find_device_by_of_node() helper Suzuki K Poulose
                   ` (8 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Peter Oberparleiter,
	Martin Schwidefsky, Heiko Carstens

Use the new driver_find_by_name() helper.

Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/s390/cio/ccwgroup.c | 10 +---------
 drivers/s390/cio/device.c   | 17 +----------------
 2 files changed, 2 insertions(+), 25 deletions(-)

diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index c554f16..b1e24fb 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -606,13 +606,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
@@ -629,8 +622,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, NULL, bus_id);
 
 	return dev ? to_ccwgroupdev(dev) : NULL;
 }
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index a5c2765..262e81c 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, NULL, bus_id);
 
 	return dev ? to_ccwdev(dev) : NULL;
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 49/57] drivers: mfd: altera: Use driver_find_device_by_of_node() helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (47 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 48/57] drivers: s390: cio: Use driver_find_by_name() helper Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-04 16:13   ` Thor Thayer
  2019-06-03 15:50 ` [RFC PATCH 50/57] drivers: iommu: arm-smmu: Use driver_find_device_by_fwnode() helper Suzuki K Poulose
                   ` (7 subsequent siblings)
  56 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Thor Thayer, Lee Jones

Use the new helper to find device by of_node.

Cc: Thor Thayer <thor.thayer@linux.intel.com>
Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/mfd/altera-sysmgr.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/mfd/altera-sysmgr.c b/drivers/mfd/altera-sysmgr.c
index 2ee14d8..1fbe06c 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, NULL,
+					    (void *)sysmgr_np);
 	of_node_put(sysmgr_np);
 	if (!dev)
 		return ERR_PTR(-EPROBE_DEFER);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 50/57] drivers: iommu: arm-smmu: Use driver_find_device_by_fwnode() helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (48 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 49/57] drivers: mfd: altera: Use driver_find_device_by_of_node() helper Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 15:50 ` [RFC PATCH 51/57] drivers: Add generic helper to match all devices Suzuki K Poulose
                   ` (6 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Will Deacon, Robin Murphy, Joerg Roedel

Reuse the driver_find_device_by_fwnode() helper to lookup devices.

Cc: Will Deacon <will.deacon@arm.com>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/iommu/arm-smmu-v3.c | 9 ++-------
 drivers/iommu/arm-smmu.c    | 9 ++-------
 2 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index d787856..1f9851f 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,
+							  NULL, 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 4ce429b..c962e82 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1431,16 +1431,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,
+							  NULL, fwnode);
 	put_device(dev);
 	return dev ? dev_get_drvdata(dev) : NULL;
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 51/57] drivers: Add generic helper to match all devices
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (49 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 50/57] drivers: iommu: arm-smmu: Use driver_find_device_by_fwnode() helper Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 15:50 ` [RFC PATCH 52/57] drivers: tegra: Use driver_find_device_by_of_node() helper Suzuki K Poulose
                   ` (5 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose

Add a generic helper which matches any given device by always
returning true.

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 69cba57..dd08bf9 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3351,3 +3351,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 68d6e04..7ea15e6 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -168,6 +168,7 @@ int device_match_acpi_dev(struct device *dev, const void *adev);
 int device_match_fwnode(struct device *dev, const void *fwnode);
 int device_match_devt(struct device *dev, const void *pdevt);
 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));
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 52/57] drivers: tegra: Use driver_find_device_by_of_node() helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (50 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 51/57] drivers: Add generic helper to match all devices Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 15:50 ` [RFC PATCH 53/57] drivers: Introduce bus_find_next_device() helper Suzuki K Poulose
                   ` (4 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Thierry Reding, Jonathan Hunter

Switch to using the new helper driver_find_device_by_of_node().

Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/amba/tegra-ahb.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/amba/tegra-ahb.c b/drivers/amba/tegra-ahb.c
index 42175a6..5ce0f66 100644
--- a/drivers/amba/tegra-ahb.c
+++ b/drivers/amba/tegra-ahb.c
@@ -143,22 +143,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, NULL, dn);
 	if (!dev)
 		return -EPROBE_DEFER;
 	ahb = dev_get_drvdata(dev);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 53/57] drivers: Introduce bus_find_next_device() helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (51 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 52/57] drivers: tegra: Use driver_find_device_by_of_node() helper Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 15:50 ` [RFC PATCH 54/57] drivers: pci: Use " Suzuki K Poulose
                   ` (3 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Rafael J. Wysocki

Add a helper to find the next device on the given bus from a
given device iterator position.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 include/linux/device.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/include/linux/device.h b/include/linux/device.h
index 7ea15e6..528efc0 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -234,6 +234,16 @@ static inline struct device *bus_find_device_by_devt(struct bus_type *bus,
 	return bus_find_device(bus, start, &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 *start)
+{
+	return bus_find_device(bus, start, 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,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 54/57] drivers: pci: Use bus_find_next_device() helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (52 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 53/57] drivers: Introduce bus_find_next_device() helper Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 15:50 ` [RFC PATCH 55/57] drivers: scsi: " Suzuki K Poulose
                   ` (2 subsequent siblings)
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Bjorn Helgaas

Reuse the generic helper to find the next device on bus.

Cc: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/pci/probe.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

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;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 55/57] drivers: scsi: Use bus_find_next_device() helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (53 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 54/57] drivers: pci: Use " Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 15:50 ` [RFC PATCH 56/57] drivers: Introduce driver_find_next_device() helper Suzuki K Poulose
  2019-06-03 15:50 ` [RFC PATCH 57/57] drivers: i2c-amd: Use " Suzuki K Poulose
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, James E.J. Bottomley, Martin K. Petersen

Reuse the generic helper to find the next device.

Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/scsi/scsi_proc.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

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;
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 56/57] drivers: Introduce driver_find_next_device() helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (54 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 55/57] drivers: scsi: " Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  2019-06-03 15:50 ` [RFC PATCH 57/57] drivers: i2c-amd: Use " Suzuki K Poulose
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, rafael, suzuki.poulose, Rafael J. Wysocki

Similar to bus_find_next_device(), add a helper to find
the next device for the given driver.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 include/linux/device.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/device.h b/include/linux/device.h
index 528efc0..39a7755 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -456,6 +456,12 @@ driver_find_device_by_fwnode(struct device_driver *drv,
 	return driver_find_device(drv, start, (void *)fwnode, device_match_fwnode);
 }
 
+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);
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* [RFC PATCH 57/57] drivers: i2c-amd: Use driver_find_next_device() helper
       [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
                   ` (55 preceding siblings ...)
  2019-06-03 15:50 ` [RFC PATCH 56/57] drivers: Introduce driver_find_next_device() helper Suzuki K Poulose
@ 2019-06-03 15:50 ` Suzuki K Poulose
  56 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 15:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, suzuki.poulose, Elie Morisse, Nehal Shah,
	Shyam Sundar S K

Reuse the generic helper to find the first device matching
the driver.

Cc: Elie Morisse <syniurge@gmail.com>
Cc: Nehal Shah <nehal-bakulchandra.shah@amd.com>
Cc: Shyam Sundar S K <shyam-sundar.s-k@amd.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/i2c/busses/i2c-amd-mp2-pci.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

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;
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 11/57] of: mdio: Use bus_find_device_by_of_node helper
  2019-06-03 15:49 ` [RFC PATCH 11/57] of: mdio: " Suzuki K Poulose
@ 2019-06-03 16:00   ` Andrew Lunn
  0 siblings, 0 replies; 105+ messages in thread
From: Andrew Lunn @ 2019-06-03 16:00 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: linux-kernel, gregkh, rafael, Florian Fainelli, Rob Herring,
	Frank Rowand

On Mon, Jun 03, 2019 at 04:49:37PM +0100, Suzuki K Poulose wrote:
> Switch to using the bus_find_device_by_of_node helper
> 
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 09/57] drivers: sound: rockchip: rk3399: Use bus_find_device_by_of_node helper
  2019-06-03 15:49 ` [RFC PATCH 09/57] drivers: sound: rockchip: rk3399: " Suzuki K Poulose
@ 2019-06-03 16:02   ` Mark Brown
  0 siblings, 0 replies; 105+ messages in thread
From: Mark Brown @ 2019-06-03 16:02 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: linux-kernel, gregkh, rafael, Heiko Stuebner, Takashi Iwai,
	Liam Girdwood, linux-rockchip

[-- Attachment #1: Type: text/plain, Size: 292 bytes --]

On Mon, Jun 03, 2019 at 04:49:35PM +0100, Suzuki K Poulose wrote:
> Switch to using the bus_find_device_by_of_node helper

Please use subject lines matching the style for the subsystem.  This
makes it easier for people to identify relevant patches.

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 41/57] drivers: net: phy: Use class_find_device_by_of_node helper
  2019-06-03 15:50 ` [RFC PATCH 41/57] drivers: net: phy: " Suzuki K Poulose
@ 2019-06-03 16:02   ` Andrew Lunn
  0 siblings, 0 replies; 105+ messages in thread
From: Andrew Lunn @ 2019-06-03 16:02 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: linux-kernel, gregkh, rafael, Florian Fainelli, Heiner Kallweit,
	David S. Miller

On Mon, Jun 03, 2019 at 04:50:07PM +0100, Suzuki K Poulose wrote:
> Use the generic helper to find a device matching the of_node.
> 
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 08/57] drivers: spi: Use bus_find_device_by_of_node helper
  2019-06-03 15:49 ` [RFC PATCH 08/57] drivers: spi: " Suzuki K Poulose
@ 2019-06-03 16:04   ` Mark Brown
  0 siblings, 0 replies; 105+ messages in thread
From: Mark Brown @ 2019-06-03 16:04 UTC (permalink / raw)
  To: Suzuki K Poulose; +Cc: linux-kernel, gregkh, rafael, linux-spi

[-- Attachment #1: Type: text/plain, Size: 165 bytes --]

On Mon, Jun 03, 2019 at 04:49:34PM +0100, Suzuki K Poulose wrote:
> Switch to using the bus_find_device_by_of_node helper

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 23/57] drivers: spi: Use bus_find_device_by_acpi_dev match helper
  2019-06-03 15:49 ` [RFC PATCH 23/57] drivers: spi: Use bus_find_device_by_acpi_dev match helper Suzuki K Poulose
@ 2019-06-03 16:04   ` Mark Brown
  0 siblings, 0 replies; 105+ messages in thread
From: Mark Brown @ 2019-06-03 16:04 UTC (permalink / raw)
  To: Suzuki K Poulose; +Cc: linux-kernel, gregkh, rafael, linux-spi

[-- Attachment #1: Type: text/plain, Size: 296 bytes --]

On Mon, Jun 03, 2019 at 04:49:49PM +0100, Suzuki K Poulose wrote:
> Switch to the generic helper bus_find_device_by_acpi_dev.

Please use subject lines matching the style for the subsystem.  This
makes it easier for people to identify relevant patches.

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 42/57] drivers: regulator: Use class_find_device_by_of_node helper
  2019-06-03 15:50 ` [RFC PATCH 42/57] drivers: regulator: " Suzuki K Poulose
@ 2019-06-03 16:04   ` Mark Brown
  0 siblings, 0 replies; 105+ messages in thread
From: Mark Brown @ 2019-06-03 16:04 UTC (permalink / raw)
  To: Suzuki K Poulose; +Cc: linux-kernel, gregkh, rafael, Liam Girdwood

[-- Attachment #1: Type: text/plain, Size: 300 bytes --]

On Mon, Jun 03, 2019 at 04:50:08PM +0100, Suzuki K Poulose wrote:
> Use the generic helper to find a device matching the of_node.

Acked-by: Mark Brown <broonie@kernel.org>

Please use subject lines matching the style for the subsystem.  This
makes it easier for people to identify relevant patches.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 484 bytes --]

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 16/57] net: hns_roce: Use bus_find_device_by_fwnode helper
  2019-06-03 15:49 ` [RFC PATCH 16/57] net: hns_roce: Use " Suzuki K Poulose
@ 2019-06-03 16:05   ` Jason Gunthorpe
  0 siblings, 0 replies; 105+ messages in thread
From: Jason Gunthorpe @ 2019-06-03 16:05 UTC (permalink / raw)
  To: Suzuki K Poulose; +Cc: linux-kernel, gregkh, rafael, Doug Ledford

On Mon, Jun 03, 2019 at 04:49:42PM +0100, Suzuki K Poulose wrote:
> Switch to using the bus_find_device_by_fwnode helper
> 
> Cc: Doug Ledford <dledford@redhat.com>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)

Acked-by: Jason Gunthorpe <jgg@mellanox.com>

Jason

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 39/57] drivers: mux: Use class_find_device_by_of_node helper
  2019-06-03 15:50 ` [RFC PATCH 39/57] drivers: mux: Use class_find_device_by_of_node helper Suzuki K Poulose
@ 2019-06-03 16:22   ` Peter Rosin
  2019-06-03 16:45     ` Suzuki K Poulose
  0 siblings, 1 reply; 105+ messages in thread
From: Peter Rosin @ 2019-06-03 16:22 UTC (permalink / raw)
  To: Suzuki K Poulose, linux-kernel; +Cc: gregkh, rafael

Hi!

This all sounds like nice changes. First a couple of nitpicks:

From the cover letter, included here to spare most of the others...

> subsystems. This series is an attempt to consolidate the and cleanup

s/the and/and/

On 2019-06-03 17:50, Suzuki K Poulose wrote:
> Use the generic helper to find a device matching the of_node.
> 
> Cc: Peter Rosin <peda@axentia.se>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  drivers/mux/core.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/mux/core.c b/drivers/mux/core.c
> index d1271c1..3591e40 100644
> --- a/drivers/mux/core.c
> +++ b/drivers/mux/core.c
> @@ -405,18 +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);
> -

Nitpick #2. Please leave the blank line where it belongs.

However, how can I review this if I do not get to see the patch that
adds the class_find_device_by_of_node function? Please provide a
little bit more context!

Cheers,
Peter

> +	dev = class_find_device_by_of_node(&mux_class, NULL, np);
>  	return dev ? to_mux_chip(dev) : NULL;
>  }
>  
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 39/57] drivers: mux: Use class_find_device_by_of_node helper
  2019-06-03 16:22   ` Peter Rosin
@ 2019-06-03 16:45     ` Suzuki K Poulose
  2019-06-03 18:39       ` Peter Rosin
  0 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 16:45 UTC (permalink / raw)
  To: peda, linux-kernel; +Cc: gregkh, rafael

Hi Peter,

Thanks for your comments, please see my response inline.

On 03/06/2019 17:22, Peter Rosin wrote:
> Hi!
> 
> This all sounds like nice changes. First a couple of nitpicks:
> 
>  From the cover letter, included here to spare most of the others...
> 
>> subsystems. This series is an attempt to consolidate the and cleanup
> 
> s/the and/and/

Thanks for spotting.

> 
> On 2019-06-03 17:50, Suzuki K Poulose wrote:
>> Use the generic helper to find a device matching the of_node.
>>
>> Cc: Peter Rosin <peda@axentia.se>
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>> ---
>>   drivers/mux/core.c | 8 +-------
>>   1 file changed, 1 insertion(+), 7 deletions(-)
>>
>> diff --git a/drivers/mux/core.c b/drivers/mux/core.c
>> index d1271c1..3591e40 100644
>> --- a/drivers/mux/core.c
>> +++ b/drivers/mux/core.c
>> @@ -405,18 +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);
>> -
> 
> Nitpick #2. Please leave the blank line where it belongs.

Agreed !

> 
> However, how can I review this if I do not get to see the patch that
> adds the class_find_device_by_of_node function? Please provide a
> little bit more context!

Sorry about that. The routine is a wrapper to class_find_device()
which uses a generic routine to match the of_node, instead of the
driver specific of_dev_node_match(). The series adds such wrappers for
{bus/drivers/class}_find_device(). Unfortunately I didn't add
individual driver maintainers to the patches, which add those wrappers.
For the moment, please find the link below for the patch :

https://lkml.kernel.org/r/1559577023-558-29-git-send-email-suzuki.poulose@arm.com


I will try to address it in the next revision.

Kind regards
Suzuki

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 02/57] drivers: ipmi: Drop device reference
  2019-06-03 15:49 ` [RFC PATCH 02/57] drivers: ipmi: Drop device reference Suzuki K Poulose
@ 2019-06-03 17:01   ` Corey Minyard
  2019-06-03 17:03     ` Suzuki K Poulose
  2019-06-03 19:09   ` Greg KH
  1 sibling, 1 reply; 105+ messages in thread
From: Corey Minyard @ 2019-06-03 17:01 UTC (permalink / raw)
  To: Suzuki K Poulose; +Cc: linux-kernel, gregkh, rafael, Arnd Bergmann

On Mon, Jun 03, 2019 at 04:49:28PM +0100, Suzuki K Poulose wrote:
> Drop the reference to a device found via bus_find_device()

This change is correct, but it probably doesn't belong in this
series.  Would you like me to take it as a stand-alone change?

-corey

> 
> Cc: Corey Minyard <minyard@acm.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  drivers/char/ipmi/ipmi_si_platform.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/char/ipmi/ipmi_si_platform.c b/drivers/char/ipmi/ipmi_si_platform.c
> index f2a91c4..ff82353 100644
> --- a/drivers/char/ipmi/ipmi_si_platform.c
> +++ b/drivers/char/ipmi/ipmi_si_platform.c
> @@ -442,6 +442,7 @@ void ipmi_remove_platform_device_by_name(char *name)
>  				      pdev_match_name))) {
>  		struct platform_device *pdev = to_platform_device(dev);
>  
> +		put_device(dev);
>  		platform_device_unregister(pdev);
>  	}
>  }
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 02/57] drivers: ipmi: Drop device reference
  2019-06-03 17:01   ` Corey Minyard
@ 2019-06-03 17:03     ` Suzuki K Poulose
  0 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-03 17:03 UTC (permalink / raw)
  To: minyard; +Cc: linux-kernel, gregkh, rafael, arnd

Hi

On 03/06/2019 18:01, Corey Minyard wrote:
> On Mon, Jun 03, 2019 at 04:49:28PM +0100, Suzuki K Poulose wrote:
>> Drop the reference to a device found via bus_find_device()
> 
> This change is correct, but it probably doesn't belong in this
> series.  Would you like me to take it as a stand-alone change?
> 

Sure, please go ahead and I can drop it.

Thanks
Suzuki

^ permalink raw reply	[flat|nested] 105+ messages in thread

* RE: [RFC PATCH 36/57] drivers: mei: Use class_find_device_by_devt match helper
  2019-06-03 15:50 ` [RFC PATCH 36/57] drivers: mei: Use class_find_device_by_devt match helper Suzuki K Poulose
@ 2019-06-03 18:00   ` Winkler, Tomas
  2019-06-04  8:27     ` Suzuki K Poulose
  0 siblings, 1 reply; 105+ messages in thread
From: Winkler, Tomas @ 2019-06-03 18:00 UTC (permalink / raw)
  To: Suzuki K Poulose, linux-kernel; +Cc: gregkh, rafael, Arnd Bergmann



> -----Original Message-----
> From: Suzuki K Poulose [mailto:suzuki.poulose@arm.com]
> Sent: Monday, June 03, 2019 18:50
> To: linux-kernel@vger.kernel.org
> Cc: gregkh@linuxfoundation.org; rafael@kernel.org; suzuki.poulose@arm.com;
> Winkler, Tomas <tomas.winkler@intel.com>; Arnd Bergmann
> <arnd@arndb.de>
> Subject: [RFC PATCH 36/57] drivers: mei: Use class_find_device_by_devt match
> helper
> 
> Switch to the generic helper class_find_device_by_devt.

Looks okay, but  you could add me at least to cover later mail, there is very little context. 


Thanks
Tomas


> 
> Cc: Tomas Winkler <tomas.winkler@intel.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  drivers/misc/mei/main.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index
> ad02097..243b481 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, NULL, dev->cdev.dev);
>  	if (clsdev) {
>  		sysfs_notify(&clsdev->kobj, NULL, "dev_state");
>  		put_device(clsdev);
> --
> 2.7.4


^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 39/57] drivers: mux: Use class_find_device_by_of_node helper
  2019-06-03 16:45     ` Suzuki K Poulose
@ 2019-06-03 18:39       ` Peter Rosin
  0 siblings, 0 replies; 105+ messages in thread
From: Peter Rosin @ 2019-06-03 18:39 UTC (permalink / raw)
  To: Suzuki K Poulose, linux-kernel; +Cc: gregkh, rafael

On 2019-06-03 18:45, Suzuki K Poulose wrote:
> Hi Peter,

> Sorry about that. The routine is a wrapper to class_find_device()
> which uses a generic routine to match the of_node, instead of the
> driver specific of_dev_node_match(). The series adds such wrappers for
> {bus/drivers/class}_find_device(). Unfortunately I didn't add
> individual driver maintainers to the patches, which add those wrappers.
> For the moment, please find the link below for the patch :
> 
> https://lkml.kernel.org/r/1559577023-558-29-git-send-email-suzuki.poulose@arm.com
> 
> 
> I will try to address it in the next revision.

For the record, that patch references some other new function
"device_match_of_node" for which I do not have a definition. But with
the above link, I was able to find it without too much effort.

All looks ok to me, so, if you fix that blank line thing,

Reviewed-by: Peter Rosin <peda@axentia.se>

Cheers,
Peter

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 03/57] drivers: coresight: Drop device references found via bus_find_device
  2019-06-03 15:49 ` [RFC PATCH 03/57] drivers: coresight: Drop device references found via bus_find_device Suzuki K Poulose
@ 2019-06-03 19:08   ` Greg KH
  2019-06-04  8:19     ` Suzuki K Poulose
  0 siblings, 1 reply; 105+ messages in thread
From: Greg KH @ 2019-06-03 19:08 UTC (permalink / raw)
  To: Suzuki K Poulose; +Cc: linux-kernel, rafael, Mathieu Poirier

On Mon, Jun 03, 2019 at 04:49:29PM +0100, Suzuki K Poulose wrote:
> We must drop references to the device found via bus_find_device().
> 
> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  drivers/hwtracing/coresight/coresight.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
> index 4b13028..37ccd67 100644
> --- a/drivers/hwtracing/coresight/coresight.c
> +++ b/drivers/hwtracing/coresight/coresight.c
> @@ -540,7 +540,7 @@ struct coresight_device *coresight_get_enabled_sink(bool deactivate)
>  
>  	dev = bus_find_device(&coresight_bustype, NULL, &deactivate,
>  			      coresight_enabled_sink);
> -
> +	put_device(dev);
>  	return dev ? to_coresight_device(dev) : NULL;

You drop the reference and then use the pointer?

Not good :(

>  }
>  
> @@ -581,7 +581,7 @@ struct coresight_device *coresight_get_sink_by_id(u32 id)
>  
>  	dev = bus_find_device(&coresight_bustype, NULL, &id,
>  			      coresight_sink_by_id);
> -
> +	put_device(dev);
>  	return dev ? to_coresight_device(dev) : NULL;

Same here, not good :(

Please fix this up and it can go in as a bugfix like any other normal
patch, outside of this huge series.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 02/57] drivers: ipmi: Drop device reference
  2019-06-03 15:49 ` [RFC PATCH 02/57] drivers: ipmi: Drop device reference Suzuki K Poulose
  2019-06-03 17:01   ` Corey Minyard
@ 2019-06-03 19:09   ` Greg KH
  2019-06-03 19:59     ` Corey Minyard
  1 sibling, 1 reply; 105+ messages in thread
From: Greg KH @ 2019-06-03 19:09 UTC (permalink / raw)
  To: Suzuki K Poulose; +Cc: linux-kernel, rafael, Corey Minyard, Arnd Bergmann

On Mon, Jun 03, 2019 at 04:49:28PM +0100, Suzuki K Poulose wrote:
> Drop the reference to a device found via bus_find_device()
> 
> Cc: Corey Minyard <minyard@acm.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  drivers/char/ipmi/ipmi_si_platform.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/char/ipmi/ipmi_si_platform.c b/drivers/char/ipmi/ipmi_si_platform.c
> index f2a91c4..ff82353 100644
> --- a/drivers/char/ipmi/ipmi_si_platform.c
> +++ b/drivers/char/ipmi/ipmi_si_platform.c
> @@ -442,6 +442,7 @@ void ipmi_remove_platform_device_by_name(char *name)
>  				      pdev_match_name))) {
>  		struct platform_device *pdev = to_platform_device(dev);
>  
> +		put_device(dev);
>  		platform_device_unregister(pdev);

So you drop the reference, and then actually use the pointer?

The drop needs to be _after_ the call to platform_device_unregister().

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 46/57] driver: Add variants of driver_find_device()
  2019-06-03 15:50 ` [RFC PATCH 46/57] driver: Add variants of driver_find_device() Suzuki K Poulose
@ 2019-06-03 19:10   ` Greg KH
  2019-06-04  8:45     ` Suzuki K Poulose
  2019-06-03 19:11   ` Greg KH
  2019-06-03 19:12   ` Greg KH
  2 siblings, 1 reply; 105+ messages in thread
From: Greg KH @ 2019-06-03 19:10 UTC (permalink / raw)
  To: Suzuki K Poulose; +Cc: linux-kernel, rafael

On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote:
> Add a wrappers to lookup a device by name for a given driver, by various
> generic properties of a device. This can avoid the proliferation of custom
> match functions throughout the drivers.
> 
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)

You should put the "here are the new functions that everyone can use"
much earlier in the patch series, otherwise it's hard to dig out.

And if you send just those as an individual series, and they look good,
I can queue them up now so that everyone else can take the individual
patches through their respective trees.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 46/57] driver: Add variants of driver_find_device()
  2019-06-03 15:50 ` [RFC PATCH 46/57] driver: Add variants of driver_find_device() Suzuki K Poulose
  2019-06-03 19:10   ` Greg KH
@ 2019-06-03 19:11   ` Greg KH
  2019-06-04  8:36     ` Suzuki K Poulose
  2019-06-03 19:12   ` Greg KH
  2 siblings, 1 reply; 105+ messages in thread
From: Greg KH @ 2019-06-03 19:11 UTC (permalink / raw)
  To: Suzuki K Poulose; +Cc: linux-kernel, rafael

On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote:
> Add a wrappers to lookup a device by name for a given driver, by various
> generic properties of a device. This can avoid the proliferation of custom
> match functions throughout the drivers.
> 
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
> 
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 52d59d5..68d6e04 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -401,6 +401,50 @@ struct device *driver_find_device(struct device_driver *drv,
>  				  struct device *start, 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
> + * @start: Device to begin with
> + * @name: name of the device to match
> + */
> +static inline struct device *driver_find_device_by_name(struct device_driver *drv,
> +							struct device *start,
> +							const char *name)
> +{
> +	return driver_find_device(drv, start, (void *)name, device_match_name);

Why is the cast needed?

> +}
> +
> +/**
> + * driver_find_device_by_of_node- device iterator for locating a particular device
> + * by of_node pointer.
> + * @driver: the driver we're iterating
> + * @start: Device to begin with
> + * @np: of_node pointer to match.
> + */
> +static inline struct device *
> +driver_find_device_by_of_node(struct device_driver *drv,
> +			      struct device *start,
> +			      const struct device_node *np)
> +{
> +	return driver_find_device(drv, start, (void *)np, device_match_of_node);

Same here.

> +}
> +
> +/**
> + * driver_find_device_by_fwnode- device iterator for locating a particular device
> + * by fwnode pointer.
> + * @driver: the driver we're iterating
> + * @start: Device to begin with
> + * @fwnode: fwnode pointer to match.
> + */
> +static inline struct device *
> +driver_find_device_by_fwnode(struct device_driver *drv,
> +			     struct device *start,
> +			     const struct fwnode_handle *fwnode)
> +{
> +	return driver_find_device(drv, start, (void *)fwnode, device_match_fwnode);

And here

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 46/57] driver: Add variants of driver_find_device()
  2019-06-03 15:50 ` [RFC PATCH 46/57] driver: Add variants of driver_find_device() Suzuki K Poulose
  2019-06-03 19:10   ` Greg KH
  2019-06-03 19:11   ` Greg KH
@ 2019-06-03 19:12   ` Greg KH
  2019-06-04  8:33     ` Suzuki K Poulose
  2 siblings, 1 reply; 105+ messages in thread
From: Greg KH @ 2019-06-03 19:12 UTC (permalink / raw)
  To: Suzuki K Poulose; +Cc: linux-kernel, rafael

On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote:
> Add a wrappers to lookup a device by name for a given driver, by various
> generic properties of a device. This can avoid the proliferation of custom
> match functions throughout the drivers.
> 
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
> 
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 52d59d5..68d6e04 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -401,6 +401,50 @@ struct device *driver_find_device(struct device_driver *drv,
>  				  struct device *start, 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
> + * @start: Device to begin with
> + * @name: name of the device to match
> + */
> +static inline struct device *driver_find_device_by_name(struct device_driver *drv,
> +							struct device *start,
> +							const char *name)
> +{
> +	return driver_find_device(drv, start, (void *)name, device_match_name);
> +}

Are any of the users you are finding for these new functions ever using
the 'start' parameter?  If not, let's just drop it, as it's normally a
rare thing to care about, right?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 02/57] drivers: ipmi: Drop device reference
  2019-06-03 19:09   ` Greg KH
@ 2019-06-03 19:59     ` Corey Minyard
  2019-06-04  7:43       ` Greg KH
  0 siblings, 1 reply; 105+ messages in thread
From: Corey Minyard @ 2019-06-03 19:59 UTC (permalink / raw)
  To: Greg KH; +Cc: Suzuki K Poulose, linux-kernel, rafael, Arnd Bergmann

On Mon, Jun 03, 2019 at 09:09:21PM +0200, Greg KH wrote:
> On Mon, Jun 03, 2019 at 04:49:28PM +0100, Suzuki K Poulose wrote:
> > Drop the reference to a device found via bus_find_device()
> > 
> > Cc: Corey Minyard <minyard@acm.org>
> > Cc: Arnd Bergmann <arnd@arndb.de>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> > ---
> >  drivers/char/ipmi/ipmi_si_platform.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/char/ipmi/ipmi_si_platform.c b/drivers/char/ipmi/ipmi_si_platform.c
> > index f2a91c4..ff82353 100644
> > --- a/drivers/char/ipmi/ipmi_si_platform.c
> > +++ b/drivers/char/ipmi/ipmi_si_platform.c
> > @@ -442,6 +442,7 @@ void ipmi_remove_platform_device_by_name(char *name)
> >  				      pdev_match_name))) {
> >  		struct platform_device *pdev = to_platform_device(dev);
> >  
> > +		put_device(dev);
> >  		platform_device_unregister(pdev);
> 
> So you drop the reference, and then actually use the pointer?

I did think about this, and in this case you can, I think.
platform_device_unregister() does a put_device() at the end of it's
processing, right?

But it is better style to do it the other way, so I can change it.

-corey

> 
> The drop needs to be _after_ the call to platform_device_unregister().
> 
> thanks,
> 
> greg k-h

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 32/57] drivers: s390-crypto: Use class_device_find_by_name() helper
  2019-06-03 15:49 ` [RFC PATCH 32/57] drivers: s390-crypto: Use class_device_find_by_name() helper Suzuki K Poulose
@ 2019-06-04  6:45   ` Harald Freudenberger
  0 siblings, 0 replies; 105+ messages in thread
From: Harald Freudenberger @ 2019-06-04  6:45 UTC (permalink / raw)
  To: Suzuki K Poulose, linux-kernel
  Cc: gregkh, rafael, Martin Schwidefsky, Heiko Carstens

On 03.06.19 17:49, Suzuki K Poulose wrote:
> Use the new class_find_device_by_name() helper.
>
> Cc: Harald Freudenberger <freude@linux.ibm.com>
> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  drivers/s390/crypto/zcrypt_api.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c
> index 1058b4b..16cad8e 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,8 @@ 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,
> +							NULL, (void *) name);
>  
>  	return dev ? to_zcdn_dev(dev) : NULL;
>  }
fine with me, thanks
acked-by: Harald Freudenberger <freude@linux.ibm.com>


^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 37/57] drivers: s390: zcrypt: Use class_find_device_by_devt helper
  2019-06-03 15:50 ` [RFC PATCH 37/57] drivers: s390: zcrypt: Use class_find_device_by_devt helper Suzuki K Poulose
@ 2019-06-04  6:47   ` Harald Freudenberger
  0 siblings, 0 replies; 105+ messages in thread
From: Harald Freudenberger @ 2019-06-04  6:47 UTC (permalink / raw)
  To: Suzuki K Poulose, linux-kernel; +Cc: gregkh, rafael, Heiko Carstens

On 03.06.19 17:50, Suzuki K Poulose wrote:
> Use the generic helper to find a device matching the devt.
>
> Cc: Harald Freudenberger <freude@linux.ibm.com>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  drivers/s390/crypto/zcrypt_api.c | 11 +----------
>  1 file changed, 1 insertion(+), 10 deletions(-)
>
> diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c
> index 16cad8e..99c9b77 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
> @@ -159,10 +153,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, NULL, devt);
>  
>  	return dev ? to_zcdn_dev(dev) : NULL;
>  }
fine with me, thanks
acked-by: Harald Freudenberger <freude@linux.ibm.com>


^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 27/57] drivers: Unify the match prototype for bus_find_device with class_find_device
  2019-06-03 15:49 ` [RFC PATCH 27/57] drivers: Unify the match prototype for bus_find_device with class_find_device Suzuki K Poulose
@ 2019-06-04  6:52   ` Harald Freudenberger
  2019-06-04 11:26   ` Rafael J. Wysocki
  1 sibling, 0 replies; 105+ messages in thread
From: Harald Freudenberger @ 2019-06-04  6:52 UTC (permalink / raw)
  To: Suzuki K Poulose, linux-kernel
  Cc: gregkh, rafael, Alexander Shishkin, Wolfram Sang,
	Jonathan Cameron, Hartmut Knaack, Grygorii Strashko,
	David S. Miller, Bjorn Helgaas, Sebastian Ott,
	Peter Oberparleiter, James E.J. Bottomley, Martin K. Petersen,
	Andreas Noever, Michael Jamet, Felipe Balbi, David Kershner

On 03.06.19 17:49, Suzuki K Poulose wrote:
> We have iterators for devices by bus and class, with a supplied
> "match" function to do the comparison. However, both of the helper
> function have slightly different prototype for the "match" argument.
>
>  int (*) (struct device *dev, void *data)  // bus_find_device
>   vs
>  int (*) (struct device *dev, const void *data) // class_find_device
>
> Unify the prototype by promoting the match function to use that of
> the class_find_device(). This will allow us to share the generic
> match helpers with class_find_device() users.
>
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: Jonathan Cameron <jic23@kernel.org>
> Cc: Hartmut Knaack <knaack.h@gmx.de>
> Cc: Grygorii Strashko <grygorii.strashko@ti.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Sebastian Ott <sebott@linux.ibm.com>
> Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
> Cc: Harald Freudenberger <freude@linux.ibm.com>
> Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: Andreas Noever <andreas.noever@gmail.com>
> Cc: Michael Jamet <michael.jamet@intel.com>
> Cc: Felipe Balbi <balbi@kernel.org>
> Cc: David Kershner <david.kershner@unisys.com>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  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                       |  2 +-
>  drivers/base/core.c                      | 10 +++++-----
>  drivers/base/platform.c                  |  2 +-
>  drivers/char/ipmi/ipmi_si_platform.c     |  2 +-
>  drivers/firmware/efi/dev-path-parser.c   |  4 ++--
>  drivers/hwtracing/coresight/coresight.c  |  6 +++---
>  drivers/i2c/i2c-core-acpi.c              |  2 +-
>  drivers/i2c/i2c-core-of.c                |  2 +-
>  drivers/iio/inkern.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/pci/probe.c                      |  2 +-
>  drivers/pci/search.c                     |  4 ++--
>  drivers/s390/cio/css.c                   |  4 ++--
>  drivers/s390/cio/device.c                |  4 ++--
>  drivers/s390/crypto/ap_bus.c             |  4 ++--
>  drivers/scsi/scsi_proc.c                 |  2 +-
>  drivers/thunderbolt/switch.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                   | 13 ++++++-------
>  28 files changed, 54 insertions(+), 55 deletions(-)
>
...

> diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
> index b9fc502..e440682 100644
> --- a/drivers/s390/crypto/ap_bus.c
> +++ b/drivers/s390/crypto/ap_bus.c
> @@ -1365,7 +1365,7 @@ static int __match_card_device_with_id(struct device *dev, 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;
fine with me, Thanks
acked-by: Harald Freudenberger <freude@linux.ibm.com>



^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 02/57] drivers: ipmi: Drop device reference
  2019-06-03 19:59     ` Corey Minyard
@ 2019-06-04  7:43       ` Greg KH
  0 siblings, 0 replies; 105+ messages in thread
From: Greg KH @ 2019-06-04  7:43 UTC (permalink / raw)
  To: Corey Minyard; +Cc: Suzuki K Poulose, linux-kernel, rafael, Arnd Bergmann

On Mon, Jun 03, 2019 at 02:59:27PM -0500, Corey Minyard wrote:
> On Mon, Jun 03, 2019 at 09:09:21PM +0200, Greg KH wrote:
> > On Mon, Jun 03, 2019 at 04:49:28PM +0100, Suzuki K Poulose wrote:
> > > Drop the reference to a device found via bus_find_device()
> > > 
> > > Cc: Corey Minyard <minyard@acm.org>
> > > Cc: Arnd Bergmann <arnd@arndb.de>
> > > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> > > ---
> > >  drivers/char/ipmi/ipmi_si_platform.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/drivers/char/ipmi/ipmi_si_platform.c b/drivers/char/ipmi/ipmi_si_platform.c
> > > index f2a91c4..ff82353 100644
> > > --- a/drivers/char/ipmi/ipmi_si_platform.c
> > > +++ b/drivers/char/ipmi/ipmi_si_platform.c
> > > @@ -442,6 +442,7 @@ void ipmi_remove_platform_device_by_name(char *name)
> > >  				      pdev_match_name))) {
> > >  		struct platform_device *pdev = to_platform_device(dev);
> > >  
> > > +		put_device(dev);
> > >  		platform_device_unregister(pdev);
> > 
> > So you drop the reference, and then actually use the pointer?
> 
> I did think about this, and in this case you can, I think.
> platform_device_unregister() does a put_device() at the end of it's
> processing, right?

Yes, but that is the reference of the counter that was originally
initialized, not the reference that was just grabbed here.  It's really
all the same :)

> But it is better style to do it the other way, so I can change it.

Please do, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 03/57] drivers: coresight: Drop device references found via bus_find_device
  2019-06-03 19:08   ` Greg KH
@ 2019-06-04  8:19     ` Suzuki K Poulose
  0 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-04  8:19 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, rafael, mathieu.poirier



On 03/06/2019 20:08, Greg KH wrote:
> On Mon, Jun 03, 2019 at 04:49:29PM +0100, Suzuki K Poulose wrote:
>> We must drop references to the device found via bus_find_device().
>>
>> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>> ---
>>   drivers/hwtracing/coresight/coresight.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
>> index 4b13028..37ccd67 100644
>> --- a/drivers/hwtracing/coresight/coresight.c
>> +++ b/drivers/hwtracing/coresight/coresight.c
>> @@ -540,7 +540,7 @@ struct coresight_device *coresight_get_enabled_sink(bool deactivate)
>>   
>>   	dev = bus_find_device(&coresight_bustype, NULL, &deactivate,
>>   			      coresight_enabled_sink);
>> -
>> +	put_device(dev);
>>   	return dev ? to_coresight_device(dev) : NULL;
> 
> You drop the reference and then use the pointer?
> 
> Not good :(
> 
>>   }
>>   
>> @@ -581,7 +581,7 @@ struct coresight_device *coresight_get_sink_by_id(u32 id)
>>   
>>   	dev = bus_find_device(&coresight_bustype, NULL, &id,
>>   			      coresight_sink_by_id);
>> -
>> +	put_device(dev);
>>   	return dev ? to_coresight_device(dev) : NULL;
> 
> Same here, not good :(
> 
> Please fix this up and it can go in as a bugfix like any other normal
> patch, outside of this huge series.
> 
> thanks,
> 

Sure, will do. I think there are much more of such instances lying around. :-(
I will take it out of this series.

Thanks
Suzuki

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 36/57] drivers: mei: Use class_find_device_by_devt match helper
  2019-06-03 18:00   ` Winkler, Tomas
@ 2019-06-04  8:27     ` Suzuki K Poulose
  0 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-04  8:27 UTC (permalink / raw)
  To: tomas.winkler, linux-kernel; +Cc: gregkh, rafael, arnd

Hi Tomas,

On 03/06/2019 19:00, Winkler, Tomas wrote:
> 
> 
>> -----Original Message-----
>> From: Suzuki K Poulose [mailto:suzuki.poulose@arm.com]
>> Sent: Monday, June 03, 2019 18:50
>> To: linux-kernel@vger.kernel.org
>> Cc: gregkh@linuxfoundation.org; rafael@kernel.org; suzuki.poulose@arm.com;
>> Winkler, Tomas <tomas.winkler@intel.com>; Arnd Bergmann
>> <arnd@arndb.de>
>> Subject: [RFC PATCH 36/57] drivers: mei: Use class_find_device_by_devt match
>> helper
>>
>> Switch to the generic helper class_find_device_by_devt.
> 
> Looks okay, but  you could add me at least to cover later mail, there is very little context.

You were on the Cc list. I am not sure if the cover-letter was kind of blocked
due to the large Cc set. Please find it below. I can see that you are copied
on the cover letter in my inbox. The subject of is :

"[RFC PATCH 00/57] drivers: Consolidate device lookup helpers"

--- cover ---

We have helper routines to lookup devices matching a criteria defined
by a "match" helper for bus/class/driver. Often the search is based on a
generic property of a device, such as of_node, fwnode, device type or
device name. In the absense of a common set of match functions, we have
drivers writing their own match functions, spilled all over the driver
subsystems. This series is an attempt to consolidate the and cleanup
the device match functions by providing generic match helpers by device
properties listed above. In this attempt, we unify the prototype for
the match functions for {bus/driver}_find_device() with that of the
class_find_device() and thus further reducing the duplicate functions.
The series also adds wrapper functions to lookup the devices by generic
attributes, so that people don't miss the generic match functions and
continue to write their own.

Also, there are a couple of instances where the drivers use "platform_bus_type"
directly reusing the "match" function of the bus. This is cleaned by providing
a new helper "platform_find_device_by_driver()" to abstract the details away
from the callers.

Applies on 5.2-rc3

Cc: Alan Tull <atull@kernel.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
...
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>
...

----

Cheers
Suzuki

> 
> 
> Thanks
> Tomas
> 
> 
>>
>> Cc: Tomas Winkler <tomas.winkler@intel.com>
>> Cc: Arnd Bergmann <arnd@arndb.de>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>> ---
>>   drivers/misc/mei/main.c | 9 +--------
>>   1 file changed, 1 insertion(+), 8 deletions(-)
>>
>> diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index
>> ad02097..243b481 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, NULL, dev->cdev.dev);
>>   	if (clsdev) {
>>   		sysfs_notify(&clsdev->kobj, NULL, "dev_state");
>>   		put_device(clsdev);
>> --
>> 2.7.4
> 

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 46/57] driver: Add variants of driver_find_device()
  2019-06-03 19:12   ` Greg KH
@ 2019-06-04  8:33     ` Suzuki K Poulose
  0 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-04  8:33 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, rafael



On 03/06/2019 20:12, Greg KH wrote:
> On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote:
>> Add a wrappers to lookup a device by name for a given driver, by various
>> generic properties of a device. This can avoid the proliferation of custom
>> match functions throughout the drivers.
>>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>> ---
>>   include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 44 insertions(+)
>>
>> diff --git a/include/linux/device.h b/include/linux/device.h
>> index 52d59d5..68d6e04 100644
>> --- a/include/linux/device.h
>> +++ b/include/linux/device.h
>> @@ -401,6 +401,50 @@ struct device *driver_find_device(struct device_driver *drv,
>>   				  struct device *start, 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
>> + * @start: Device to begin with
>> + * @name: name of the device to match
>> + */
>> +static inline struct device *driver_find_device_by_name(struct device_driver *drv,
>> +							struct device *start,
>> +							const char *name)
>> +{
>> +	return driver_find_device(drv, start, (void *)name, device_match_name);
>> +}
> 
> Are any of the users you are finding for these new functions ever using
> the 'start' parameter?  If not, let's just drop it, as it's normally a
> rare thing to care about, right?

No, they don't except for the bus_find_next_device() at the end of the series.
I could clean this up.

Cheers
Suzuki

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 30/57] drivers: leds: Use class_find_device_by_name() helper
  2019-06-03 15:49 ` [RFC PATCH 30/57] drivers: leds: " Suzuki K Poulose
@ 2019-06-04  8:35   ` Pavel Machek
  0 siblings, 0 replies; 105+ messages in thread
From: Pavel Machek @ 2019-06-04  8:35 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: linux-kernel, gregkh, rafael, Jacek Anaszewski, Dan Murphy, linux-leds

[-- Attachment #1: Type: text/plain, Size: 378 bytes --]

On Mon 2019-06-03 16:49:56, Suzuki K Poulose wrote:
> Use the new class_find_device_by_name() helper.
> 
> Cc: Jacek Anaszewski <jacek.anaszewski@gmail.com>
> Cc: Pavel Machek <pavel@ucw.cz>

Acked-by: Pavel Machek <pavel@ucw.cz>

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 46/57] driver: Add variants of driver_find_device()
  2019-06-03 19:11   ` Greg KH
@ 2019-06-04  8:36     ` Suzuki K Poulose
  2019-06-04  8:46       ` Greg KH
  0 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-04  8:36 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, rafael



On 03/06/2019 20:11, Greg KH wrote:
> On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote:
>> Add a wrappers to lookup a device by name for a given driver, by various
>> generic properties of a device. This can avoid the proliferation of custom
>> match functions throughout the drivers.
>>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>> ---
>>   include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 44 insertions(+)
>>
>> diff --git a/include/linux/device.h b/include/linux/device.h
>> index 52d59d5..68d6e04 100644
>> --- a/include/linux/device.h
>> +++ b/include/linux/device.h
>> @@ -401,6 +401,50 @@ struct device *driver_find_device(struct device_driver *drv,
>>   				  struct device *start, 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
>> + * @start: Device to begin with
>> + * @name: name of the device to match
>> + */
>> +static inline struct device *driver_find_device_by_name(struct device_driver *drv,
>> +							struct device *start,
>> +							const char *name)
>> +{
>> +	return driver_find_device(drv, start, (void *)name, device_match_name);
> 
> Why is the cast needed?
> 
>> +}
>> +
>> +/**
>> + * driver_find_device_by_of_node- device iterator for locating a particular device
>> + * by of_node pointer.
>> + * @driver: the driver we're iterating
>> + * @start: Device to begin with
>> + * @np: of_node pointer to match.
>> + */
>> +static inline struct device *
>> +driver_find_device_by_of_node(struct device_driver *drv,
>> +			      struct device *start,
>> +			      const struct device_node *np)
>> +{
>> +	return driver_find_device(drv, start, (void *)np, device_match_of_node);
> 
> Same here.
> 
>> +}
>> +
>> +/**
>> + * driver_find_device_by_fwnode- device iterator for locating a particular device
>> + * by fwnode pointer.
>> + * @driver: the driver we're iterating
>> + * @start: Device to begin with
>> + * @fwnode: fwnode pointer to match.
>> + */
>> +static inline struct device *
>> +driver_find_device_by_fwnode(struct device_driver *drv,
>> +			     struct device *start,
>> +			     const struct fwnode_handle *fwnode)
>> +{
>> +	return driver_find_device(drv, start, (void *)fwnode, device_match_fwnode);
> 
> And here

Because the driver_find_device() expects a "void *" and not a "const void *".
May be we could promote that to "const void *" in the core API too, since we
have converted the "match" to const void * already. Thoughts ?

Suzuki


^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 46/57] driver: Add variants of driver_find_device()
  2019-06-03 19:10   ` Greg KH
@ 2019-06-04  8:45     ` Suzuki K Poulose
  2019-06-04 10:55       ` Suzuki K Poulose
  0 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-04  8:45 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, rafael



On 03/06/2019 20:10, Greg KH wrote:
> On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote:
>> Add a wrappers to lookup a device by name for a given driver, by various
>> generic properties of a device. This can avoid the proliferation of custom
>> match functions throughout the drivers.
>>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>> ---
>>   include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 44 insertions(+)
> 
> You should put the "here are the new functions that everyone can use"
> much earlier in the patch series, otherwise it's hard to dig out.

Sure, I will add it in the respective commits.

> 
> And if you send just those as an individual series, and they look good,
> I can queue them up now so that everyone else can take the individual
> patches through their respective trees.

I see. I think I may be able to do that.

Cheers
Suzuki

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 46/57] driver: Add variants of driver_find_device()
  2019-06-04  8:36     ` Suzuki K Poulose
@ 2019-06-04  8:46       ` Greg KH
  0 siblings, 0 replies; 105+ messages in thread
From: Greg KH @ 2019-06-04  8:46 UTC (permalink / raw)
  To: Suzuki K Poulose; +Cc: linux-kernel, rafael

On Tue, Jun 04, 2019 at 09:36:08AM +0100, Suzuki K Poulose wrote:
> 
> 
> On 03/06/2019 20:11, Greg KH wrote:
> > On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote:
> > > Add a wrappers to lookup a device by name for a given driver, by various
> > > generic properties of a device. This can avoid the proliferation of custom
> > > match functions throughout the drivers.
> > > 
> > > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > > Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> > > ---
> > >   include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
> > >   1 file changed, 44 insertions(+)
> > > 
> > > diff --git a/include/linux/device.h b/include/linux/device.h
> > > index 52d59d5..68d6e04 100644
> > > --- a/include/linux/device.h
> > > +++ b/include/linux/device.h
> > > @@ -401,6 +401,50 @@ struct device *driver_find_device(struct device_driver *drv,
> > >   				  struct device *start, 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
> > > + * @start: Device to begin with
> > > + * @name: name of the device to match
> > > + */
> > > +static inline struct device *driver_find_device_by_name(struct device_driver *drv,
> > > +							struct device *start,
> > > +							const char *name)
> > > +{
> > > +	return driver_find_device(drv, start, (void *)name, device_match_name);
> > 
> > Why is the cast needed?
> > 
> > > +}
> > > +
> > > +/**
> > > + * driver_find_device_by_of_node- device iterator for locating a particular device
> > > + * by of_node pointer.
> > > + * @driver: the driver we're iterating
> > > + * @start: Device to begin with
> > > + * @np: of_node pointer to match.
> > > + */
> > > +static inline struct device *
> > > +driver_find_device_by_of_node(struct device_driver *drv,
> > > +			      struct device *start,
> > > +			      const struct device_node *np)
> > > +{
> > > +	return driver_find_device(drv, start, (void *)np, device_match_of_node);
> > 
> > Same here.
> > 
> > > +}
> > > +
> > > +/**
> > > + * driver_find_device_by_fwnode- device iterator for locating a particular device
> > > + * by fwnode pointer.
> > > + * @driver: the driver we're iterating
> > > + * @start: Device to begin with
> > > + * @fwnode: fwnode pointer to match.
> > > + */
> > > +static inline struct device *
> > > +driver_find_device_by_fwnode(struct device_driver *drv,
> > > +			     struct device *start,
> > > +			     const struct fwnode_handle *fwnode)
> > > +{
> > > +	return driver_find_device(drv, start, (void *)fwnode, device_match_fwnode);
> > 
> > And here
> 
> Because the driver_find_device() expects a "void *" and not a "const void *".

Can we fix that?

> May be we could promote that to "const void *" in the core API too, since we
> have converted the "match" to const void * already. Thoughts ?

Yes, let's fix the core if possible.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 22/57] drivers: i2c: Use generic helper to match device by acpi_dev
  2019-06-03 15:49 ` [RFC PATCH 22/57] drivers: i2c: Use generic helper to match device by acpi_dev Suzuki K Poulose
@ 2019-06-04  9:27   ` Mika Westerberg
  2019-06-06 20:03   ` Wolfram Sang
  1 sibling, 0 replies; 105+ messages in thread
From: Mika Westerberg @ 2019-06-04  9:27 UTC (permalink / raw)
  To: Suzuki K Poulose; +Cc: linux-kernel, gregkh, rafael, Wolfram Sang, linux-i2c

On Mon, Jun 03, 2019 at 04:49:48PM +0100, Suzuki K Poulose wrote:
> Switch to the generic helper to match device by acpi_dev.

It would be nice if you had Cc'd actual implementation of
device_match_acpi_dev() as well but if it looks like
i2c_acpi_find_match_device() then this is fine by me,

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 47/57] drivers: mfd: Use driver_find_device_by_name helper
  2019-06-03 15:50 ` [RFC PATCH 47/57] drivers: mfd: Use driver_find_device_by_name helper Suzuki K Poulose
@ 2019-06-04  9:45   ` Arnd Bergmann
  2019-06-04 11:42     ` Suzuki K Poulose
  0 siblings, 1 reply; 105+ messages in thread
From: Arnd Bergmann @ 2019-06-04  9:45 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: Linux Kernel Mailing List, gregkh, Rafael Wysocki, Lee Jones

On Mon, Jun 3, 2019 at 5:52 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>
> Use the new driver_find_device_by_name() helper.
>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>

I see that there are currently no callers of this function, and I never
liked the interface anyway, so how about just removing
syscon_regmap_lookup_by_pdevname instead?

       Arnd

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 46/57] driver: Add variants of driver_find_device()
  2019-06-04  8:45     ` Suzuki K Poulose
@ 2019-06-04 10:55       ` Suzuki K Poulose
  2019-06-04 11:32         ` Greg KH
  2019-06-04 11:33         ` Rafael J. Wysocki
  0 siblings, 2 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-04 10:55 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, rafael



On 04/06/2019 09:45, Suzuki K Poulose wrote:
> 
> 
> On 03/06/2019 20:10, Greg KH wrote:
>> On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote:
>>> Add a wrappers to lookup a device by name for a given driver, by various
>>> generic properties of a device. This can avoid the proliferation of custom
>>> match functions throughout the drivers.
>>>
>>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>>> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
>>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>>> ---
>>>    include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
>>>    1 file changed, 44 insertions(+)
>>
>> You should put the "here are the new functions that everyone can use"
>> much earlier in the patch series, otherwise it's hard to dig out.
> 
> Sure, I will add it in the respective commits.
> 
>>
>> And if you send just those as an individual series, and they look good,
>> I can queue them up now so that everyone else can take the individual
>> patches through their respective trees.
> 
> I see. I think I may be able to do that.

The API change patch (i.e, "drivers: Unify the match prototype for 
bus_find_device with class_find_device" ) is tricky and prevents us from doing
this. So, that patch has to come via your tree as it must be a one shot change.
And that would make the individual subsystem patches conflict with your tree.
Also, it would break the builds until the individual subsystem trees are merged
with your tree with the new API.

So I am not quite sure what the best approach here would be.

Cheers
Suzuki

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 27/57] drivers: Unify the match prototype for bus_find_device with class_find_device
  2019-06-03 15:49 ` [RFC PATCH 27/57] drivers: Unify the match prototype for bus_find_device with class_find_device Suzuki K Poulose
  2019-06-04  6:52   ` Harald Freudenberger
@ 2019-06-04 11:26   ` Rafael J. Wysocki
  2019-06-04 11:39     ` Suzuki K Poulose
  1 sibling, 1 reply; 105+ messages in thread
From: Rafael J. Wysocki @ 2019-06-04 11:26 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: Linux Kernel Mailing List, Greg Kroah-Hartman, Rafael J. Wysocki,
	Alexander Shishkin, Wolfram Sang, Jonathan Cameron,
	Hartmut Knaack, Grygorii Strashko, David S. Miller,
	Bjorn Helgaas, Sebastian Ott, Peter Oberparleiter,
	Harald Freudenberger, James E.J. Bottomley, Martin K. Petersen,
	Andreas Noever, Michael Jamet, Felipe Balbi, David Kershner

On Mon, Jun 3, 2019 at 5:51 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>
> We have iterators for devices by bus and class, with a supplied
> "match" function to do the comparison. However, both of the helper
> function have slightly different prototype for the "match" argument.
>
>  int (*) (struct device *dev, void *data)  // bus_find_device
>   vs
>  int (*) (struct device *dev, const void *data) // class_find_device
>
> Unify the prototype by promoting the match function to use that of
> the class_find_device(). This will allow us to share the generic
> match helpers with class_find_device() users.

The patch looks good to me, but the changelog might be a bit better.

It seems to be all about the bus_find_device() and class_find_device()
prototype consolidation, so that the same pair of data and match()
arguments can be passed to both of them, which then will allow some
optimizations to be made, so what about the following:

"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.

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.".

Also, it looks like there is no need to make all of the following
changes in the series along with this one in one go and making them
separately would be *much* better from the patch review perspective.

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 46/57] driver: Add variants of driver_find_device()
  2019-06-04 10:55       ` Suzuki K Poulose
@ 2019-06-04 11:32         ` Greg KH
  2019-06-04 11:44           ` Suzuki K Poulose
  2019-06-04 11:33         ` Rafael J. Wysocki
  1 sibling, 1 reply; 105+ messages in thread
From: Greg KH @ 2019-06-04 11:32 UTC (permalink / raw)
  To: Suzuki K Poulose; +Cc: linux-kernel, rafael

On Tue, Jun 04, 2019 at 11:55:36AM +0100, Suzuki K Poulose wrote:
> 
> 
> On 04/06/2019 09:45, Suzuki K Poulose wrote:
> > 
> > 
> > On 03/06/2019 20:10, Greg KH wrote:
> > > On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote:
> > > > Add a wrappers to lookup a device by name for a given driver, by various
> > > > generic properties of a device. This can avoid the proliferation of custom
> > > > match functions throughout the drivers.
> > > > 
> > > > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > > > Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> > > > ---
> > > >    include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
> > > >    1 file changed, 44 insertions(+)
> > > 
> > > You should put the "here are the new functions that everyone can use"
> > > much earlier in the patch series, otherwise it's hard to dig out.
> > 
> > Sure, I will add it in the respective commits.
> > 
> > > 
> > > And if you send just those as an individual series, and they look good,
> > > I can queue them up now so that everyone else can take the individual
> > > patches through their respective trees.
> > 
> > I see. I think I may be able to do that.
> 
> The API change patch (i.e, "drivers: Unify the match prototype for
> bus_find_device with class_find_device" ) is tricky and prevents us from
> doing
> this. So, that patch has to come via your tree as it must be a one shot change.
> And that would make the individual subsystem patches conflict with your tree.
> Also, it would break the builds until the individual subsystem trees are merged
> with your tree with the new API.
> 
> So I am not quite sure what the best approach here would be.

That's for you to work out :)

one-shot changes are usually not a good idea, there are lots of ways to
prevent this from being required.

good luck!

greg k-h

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 46/57] driver: Add variants of driver_find_device()
  2019-06-04 10:55       ` Suzuki K Poulose
  2019-06-04 11:32         ` Greg KH
@ 2019-06-04 11:33         ` Rafael J. Wysocki
  1 sibling, 0 replies; 105+ messages in thread
From: Rafael J. Wysocki @ 2019-06-04 11:33 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: Greg Kroah-Hartman, Linux Kernel Mailing List, Rafael J. Wysocki

On Tue, Jun 4, 2019 at 12:55 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>
>
>
> On 04/06/2019 09:45, Suzuki K Poulose wrote:
> >
> >
> > On 03/06/2019 20:10, Greg KH wrote:
> >> On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote:
> >>> Add a wrappers to lookup a device by name for a given driver, by various
> >>> generic properties of a device. This can avoid the proliferation of custom
> >>> match functions throughout the drivers.
> >>>
> >>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> >>> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> >>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> >>> ---
> >>>    include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
> >>>    1 file changed, 44 insertions(+)
> >>
> >> You should put the "here are the new functions that everyone can use"
> >> much earlier in the patch series, otherwise it's hard to dig out.
> >
> > Sure, I will add it in the respective commits.
> >
> >>
> >> And if you send just those as an individual series, and they look good,
> >> I can queue them up now so that everyone else can take the individual
> >> patches through their respective trees.
> >
> > I see. I think I may be able to do that.
>
> The API change patch (i.e, "drivers: Unify the match prototype for
> bus_find_device with class_find_device" ) is tricky and prevents us from doing
> this. So, that patch has to come via your tree as it must be a one shot change.
> And that would make the individual subsystem patches conflict with your tree.
> Also, it would break the builds until the individual subsystem trees are merged
> with your tree with the new API.
>
> So I am not quite sure what the best approach here would be.

It looks like you need to consolidate the prototypes of
bus_find_device() and class_find_device() in the first place, so all
of the changes this depends one need to go into one series and through
the Greg's tree.

Then, you need the new helpers to be defined on top of that and I
would introduce them in another patch series once the first step above
has been completed.

Finally, some code in multiple places needs to be changed to use the
new helpers and that can be done in many smaller steps with individual
changes going in through the respective subsystem trees of theirs.

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 27/57] drivers: Unify the match prototype for bus_find_device with class_find_device
  2019-06-04 11:26   ` Rafael J. Wysocki
@ 2019-06-04 11:39     ` Suzuki K Poulose
  0 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-04 11:39 UTC (permalink / raw)
  To: rafael
  Cc: linux-kernel, gregkh, alexander.shishkin, wsa, jic23, knaack.h,
	grygorii.strashko, davem, bhelgaas, sebott, oberpar, freude,
	jejb, martin.petersen, andreas.noever, michael.jamet, balbi,
	david.kershner



On 04/06/2019 12:26, Rafael J. Wysocki wrote:
> On Mon, Jun 3, 2019 at 5:51 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>>
>> We have iterators for devices by bus and class, with a supplied
>> "match" function to do the comparison. However, both of the helper
>> function have slightly different prototype for the "match" argument.
>>
>>   int (*) (struct device *dev, void *data)  // bus_find_device
>>    vs
>>   int (*) (struct device *dev, const void *data) // class_find_device
>>
>> Unify the prototype by promoting the match function to use that of
>> the class_find_device(). This will allow us to share the generic
>> match helpers with class_find_device() users.
> 
> The patch looks good to me, but the changelog might be a bit better.
> 
> It seems to be all about the bus_find_device() and class_find_device()
> prototype consolidation, so that the same pair of data and match()
> arguments can be passed to both of them, which then will allow some
> optimizations to be made, so what about the following:
> 
> "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.
> 
> 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.".

Agreed, I will reword the description.

> 
> Also, it looks like there is no need to make all of the following
> changes in the series along with this one in one go and making them
> separately would be *much* better from the patch review perspective.

Sure. I started with the helpers in the hope that, I would need fewer
changes to individual subsystems, once I convert them to use the
new helpers.

i.e, driver A -> use new helper and the change the new helper.

rather than

change all callers of *_find_device() and then all to switch to new helper.

Anyways, looks like the latter is better in terms of splitting the series.
I will rework the series.

Thanks a lot for your input

Cheers
Suzuki


^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 47/57] drivers: mfd: Use driver_find_device_by_name helper
  2019-06-04  9:45   ` Arnd Bergmann
@ 2019-06-04 11:42     ` Suzuki K Poulose
  2019-06-04 11:47       ` Arnd Bergmann
  0 siblings, 1 reply; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-04 11:42 UTC (permalink / raw)
  To: arnd; +Cc: linux-kernel, gregkh, rafael, lee.jones

Hi Arnd,

On 04/06/2019 10:45, Arnd Bergmann wrote:
> On Mon, Jun 3, 2019 at 5:52 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>>
>> Use the new driver_find_device_by_name() helper.
>>
>> Cc: Lee Jones <lee.jones@linaro.org>
>> Cc: Arnd Bergmann <arnd@arndb.de>
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> 
> I see that there are currently no callers of this function, and I never
> liked the interface anyway, so how about just removing
> syscon_regmap_lookup_by_pdevname instead?

If that works for you, sure. I can send in a patch separately
and hopefully I can remove this patch depending when the said
change lands.

Cheers
Suzuki

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 46/57] driver: Add variants of driver_find_device()
  2019-06-04 11:32         ` Greg KH
@ 2019-06-04 11:44           ` Suzuki K Poulose
  0 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-04 11:44 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, rafael



On 04/06/2019 12:32, Greg KH wrote:
> On Tue, Jun 04, 2019 at 11:55:36AM +0100, Suzuki K Poulose wrote:
>>
>>
>> On 04/06/2019 09:45, Suzuki K Poulose wrote:
>>>
>>>
>>> On 03/06/2019 20:10, Greg KH wrote:
>>>> On Mon, Jun 03, 2019 at 04:50:12PM +0100, Suzuki K Poulose wrote:
>>>>> Add a wrappers to lookup a device by name for a given driver, by various
>>>>> generic properties of a device. This can avoid the proliferation of custom
>>>>> match functions throughout the drivers.
>>>>>
>>>>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>>>>> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
>>>>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>>>>> ---
>>>>>     include/linux/device.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
>>>>>     1 file changed, 44 insertions(+)
>>>>
>>>> You should put the "here are the new functions that everyone can use"
>>>> much earlier in the patch series, otherwise it's hard to dig out.
>>>
>>> Sure, I will add it in the respective commits.
>>>
>>>>
>>>> And if you send just those as an individual series, and they look good,
>>>> I can queue them up now so that everyone else can take the individual
>>>> patches through their respective trees.
>>>
>>> I see. I think I may be able to do that.
>>
>> The API change patch (i.e, "drivers: Unify the match prototype for
>> bus_find_device with class_find_device" ) is tricky and prevents us from
>> doing
>> this. So, that patch has to come via your tree as it must be a one shot change.
>> And that would make the individual subsystem patches conflict with your tree.
>> Also, it would break the builds until the individual subsystem trees are merged
>> with your tree with the new API.
>>
>> So I am not quite sure what the best approach here would be.

I was under the assumption that the changes are minimal for the subsystems to
allow the series queued as one shot through your tree, with Acks from the
individual maintainers. However, if thats not how it works, I can split the
series.

> 
> That's for you to work out :)
> 
> one-shot changes are usually not a good idea, there are lots of ways to
> prevent this from being required.

Sure, I will rework the series.

> 
> good luck!

Thank  :-)

Suzuki

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 47/57] drivers: mfd: Use driver_find_device_by_name helper
  2019-06-04 11:42     ` Suzuki K Poulose
@ 2019-06-04 11:47       ` Arnd Bergmann
  0 siblings, 0 replies; 105+ messages in thread
From: Arnd Bergmann @ 2019-06-04 11:47 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: Linux Kernel Mailing List, gregkh, Rafael Wysocki, Lee Jones

On Tue, Jun 4, 2019 at 1:42 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
> On 04/06/2019 10:45, Arnd Bergmann wrote:
> > On Mon, Jun 3, 2019 at 5:52 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
> >>
> >> Use the new driver_find_device_by_name() helper.
> >>
> >> Cc: Lee Jones <lee.jones@linaro.org>
> >> Cc: Arnd Bergmann <arnd@arndb.de>
> >> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> >
> > I see that there are currently no callers of this function, and I never
> > liked the interface anyway, so how about just removing
> > syscon_regmap_lookup_by_pdevname instead?
>
> If that works for you, sure. I can send in a patch separately
> and hopefully I can remove this patch depending when the said
> change lands.

Sounds good, thanks.

      Arnd

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 20/57] platform: Add a helper to find device by driver
  2019-06-03 15:49 ` [RFC PATCH 20/57] platform: Add a helper to find device by driver Suzuki K Poulose
@ 2019-06-04 13:29   ` Heiko Stuebner
  2019-06-04 13:31     ` Suzuki K Poulose
  0 siblings, 1 reply; 105+ messages in thread
From: Heiko Stuebner @ 2019-06-04 13:29 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: linux-kernel, gregkh, rafael, Inki Dae, Seung-Woo Kim,
	Sandy Huang, Eric Anholt

Hi,

Am Montag, 3. Juni 2019, 17:49:46 CEST schrieb Suzuki K Poulose:
> There are a couple of places where we reuse platform specific
> match to find a device. Instead of spilling the global varilable
> everywhere, let us provide a helper to do the same.
> 
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Inki Dae <inki.dae@samsung.com>
> Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
> Cc: Sandy Huang <hjc@rock-chips.com>
> Cc: "Heiko Stübner" <heiko@sntech.de>
> Cc: Eric Anholt <eric@anholt.net>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>

> diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
> index cc46485..a82b3ec 100644
> --- a/include/linux/platform_device.h
> +++ b/include/linux/platform_device.h
> @@ -52,6 +52,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 dev*,
> +			       const struct device_driver *drv);

the "dev*" causes compilation errors and also doesn't match the
function definition. With "dev*" -> "*start" it compiles again and
my rockchip drm driver still manages to find its components, so
after the above issue is fixed:

Tested-by: Heiko Stuebner <heiko@sntech.de>



^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 20/57] platform: Add a helper to find device by driver
  2019-06-04 13:29   ` Heiko Stuebner
@ 2019-06-04 13:31     ` Suzuki K Poulose
  0 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-04 13:31 UTC (permalink / raw)
  To: heiko; +Cc: linux-kernel, gregkh, rafael, inki.dae, sw0312.kim, hjc, eric

Hi Heiko,

On 04/06/2019 14:29, Heiko Stuebner wrote:
> Hi,
> 
> Am Montag, 3. Juni 2019, 17:49:46 CEST schrieb Suzuki K Poulose:
>> There are a couple of places where we reuse platform specific
>> match to find a device. Instead of spilling the global varilable
>> everywhere, let us provide a helper to do the same.
>>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
>> Cc: Inki Dae <inki.dae@samsung.com>
>> Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
>> Cc: Sandy Huang <hjc@rock-chips.com>
>> Cc: "Heiko Stübner" <heiko@sntech.de>
>> Cc: Eric Anholt <eric@anholt.net>
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> 
>> diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
>> index cc46485..a82b3ec 100644
>> --- a/include/linux/platform_device.h
>> +++ b/include/linux/platform_device.h
>> @@ -52,6 +52,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 dev*,
>> +			       const struct device_driver *drv);
> 
> the "dev*" causes compilation errors and also doesn't match the
> function definition. With "dev*" -> "*start" it compiles again and
> my rockchip drm driver still manages to find its components, so
> after the above issue is fixed:
> 

Thanks for spotting, I have fixed this already locally.

> Tested-by: Heiko Stuebner <heiko@sntech.de>

Thanks a lot for the testing !

Suzuki

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 49/57] drivers: mfd: altera: Use driver_find_device_by_of_node() helper
  2019-06-03 15:50 ` [RFC PATCH 49/57] drivers: mfd: altera: Use driver_find_device_by_of_node() helper Suzuki K Poulose
@ 2019-06-04 16:13   ` Thor Thayer
  0 siblings, 0 replies; 105+ messages in thread
From: Thor Thayer @ 2019-06-04 16:13 UTC (permalink / raw)
  To: Suzuki K Poulose, linux-kernel; +Cc: gregkh, rafael, Lee Jones

On 6/3/19 10:50 AM, Suzuki K Poulose wrote:
> Use the new helper to find device by of_node.
> 
> Cc: Thor Thayer <thor.thayer@linux.intel.com>
> Cc: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>

Acked-by: Thor Thayer <thor.thayer@linux.intel.com>

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 22/57] drivers: i2c: Use generic helper to match device by acpi_dev
  2019-06-03 15:49 ` [RFC PATCH 22/57] drivers: i2c: Use generic helper to match device by acpi_dev Suzuki K Poulose
  2019-06-04  9:27   ` Mika Westerberg
@ 2019-06-06 20:03   ` Wolfram Sang
  2019-06-10 12:49     ` Suzuki K Poulose
  1 sibling, 1 reply; 105+ messages in thread
From: Wolfram Sang @ 2019-06-06 20:03 UTC (permalink / raw)
  To: Suzuki K Poulose; +Cc: linux-kernel, gregkh, rafael, Mika Westerberg, linux-i2c

[-- Attachment #1: Type: text/plain, Size: 433 bytes --]


> -	dev = bus_find_device(&i2c_bus_type, NULL, adev,
> -			      i2c_acpi_find_match_device);
> +	dev = bus_find_device(&i2c_bus_type, NULL, adev, device_match_acpi_dev);

In general, this looks like a nice cleanup which I am in favour of.
However, I didn't understand why ACPI uses bus_find_device() but OF has
a seperate helper bus_find_device_by_of_node(). Why this inconsistency
of having a seperate helper here and not there?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 22/57] drivers: i2c: Use generic helper to match device by acpi_dev
  2019-06-06 20:03   ` Wolfram Sang
@ 2019-06-10 12:49     ` Suzuki K Poulose
  0 siblings, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-10 12:49 UTC (permalink / raw)
  To: wsa; +Cc: linux-kernel, gregkh, rafael, mika.westerberg, linux-i2c

Hi,

On 06/06/2019 21:03, Wolfram Sang wrote:
> 
>> -	dev = bus_find_device(&i2c_bus_type, NULL, adev,
>> -			      i2c_acpi_find_match_device);
>> +	dev = bus_find_device(&i2c_bus_type, NULL, adev, device_match_acpi_dev);
> 
> In general, this looks like a nice cleanup which I am in favour of.
> However, I didn't understand why ACPI uses bus_find_device() but OF has
> a seperate helper bus_find_device_by_of_node(). Why this inconsistency
> of having a seperate helper here and not there?

This was skipped purposefully due to the header file dependency issues with
adding "acpi_bus.h" to linux/device.h, which kind of creates a circular
dependency for adding "struct acpi_device" to the prototype.

However, I think I have found a way to solve that and include that in
the next version.

Thanks
Suzuki

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 12/57] of: platform: Use bus_find_device_by_of_node helper
  2019-06-03 15:49 ` [RFC PATCH 12/57] of: platform: " Suzuki K Poulose
@ 2019-06-10 20:44   ` Rob Herring
  0 siblings, 0 replies; 105+ messages in thread
From: Rob Herring @ 2019-06-10 20:44 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: linux-kernel, Greg Kroah-Hartman, Rafael J. Wysocki,
	Frank Rowand, devicetree

On Mon, Jun 3, 2019 at 9:51 AM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>
> Switch to using the bus_find_device_by_of_node helper
>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  drivers/of/platform.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 01/57] drivers: s390/cio: Use driver_for_each_device
  2019-06-03 15:49 ` [RFC PATCH 01/57] drivers: s390/cio: Use driver_for_each_device Suzuki K Poulose
@ 2019-06-14 13:32   ` Suzuki K Poulose
  2019-06-17  9:21   ` Sebastian Ott
  1 sibling, 0 replies; 105+ messages in thread
From: Suzuki K Poulose @ 2019-06-14 13:32 UTC (permalink / raw)
  To: linux-kernel, sebott, oberpar, heiko.carstens; +Cc: gregkh, rafael

Heiko, Sebastian, Peter,

Please could you review the following patch ?


On 03/06/2019 16:49, Suzuki K Poulose wrote:
> The cio driver use driver_find_device() to find all devices
> to release them before the driver is unregistered. Instead,
> it could easily use a lighter driver_for_each_device() helper
> to iterate over all the devices.
> 
> Cc: Sebastian Ott <sebott@linux.ibm.com>
> Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>   drivers/s390/cio/ccwgroup.c | 18 ++++++++----------
>   1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
> index 4ebf6d4..a006945 100644
> --- a/drivers/s390/cio/ccwgroup.c
> +++ b/drivers/s390/cio/ccwgroup.c
> @@ -581,9 +581,12 @@ 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_release_device(struct device *dev, void *unused)
>   {
> -	return 1;
> +	struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
> +
> +	ccwgroup_ungroup(gdev);
> +	return 0;
>   }
>   
>   /**
> @@ -594,16 +597,11 @@ static int __ccwgroup_match_all(struct device *dev, void *data)
>    */
>   void ccwgroup_driver_unregister(struct ccwgroup_driver *cdriver)
>   {
> -	struct device *dev;
> +	int ret;
>   
>   	/* We don't want ccwgroup devices to live longer than their driver. */
> -	while ((dev = driver_find_device(&cdriver->driver, NULL, NULL,
> -					 __ccwgroup_match_all))) {
> -		struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
> -
> -		ccwgroup_ungroup(gdev);
> -		put_device(dev);
> -	}
> +	ret = driver_for_each_device(&cdriver->driver, NULL, NULL,
> +				     ccwgroup_release_device);
>   	driver_unregister(&cdriver->driver);
>   }
>   EXPORT_SYMBOL(ccwgroup_driver_unregister);
> 


Thanks
Suzuki

^ permalink raw reply	[flat|nested] 105+ messages in thread

* Re: [RFC PATCH 01/57] drivers: s390/cio: Use driver_for_each_device
  2019-06-03 15:49 ` [RFC PATCH 01/57] drivers: s390/cio: Use driver_for_each_device Suzuki K Poulose
  2019-06-14 13:32   ` Suzuki K Poulose
@ 2019-06-17  9:21   ` Sebastian Ott
  1 sibling, 0 replies; 105+ messages in thread
From: Sebastian Ott @ 2019-06-17  9:21 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: linux-kernel, gregkh, rafael, Peter Oberparleiter, Heiko Carstens

On Mon, 3 Jun 2019, Suzuki K Poulose wrote:
> The cio driver use driver_find_device() to find all devices
> to release them before the driver is unregistered. Instead,
> it could easily use a lighter driver_for_each_device() helper
> to iterate over all the devices.
> 
> Cc: Sebastian Ott <sebott@linux.ibm.com>
> Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>

Reviewed-by: Sebastian Ott <sebott@linux.ibm.com>


^ permalink raw reply	[flat|nested] 105+ messages in thread

end of thread, other threads:[~2019-06-17  9:22 UTC | newest]

Thread overview: 105+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1559577023-558-1-git-send-email-suzuki.poulose@arm.com>
2019-06-03 15:49 ` [RFC PATCH 01/57] drivers: s390/cio: Use driver_for_each_device Suzuki K Poulose
2019-06-14 13:32   ` Suzuki K Poulose
2019-06-17  9:21   ` Sebastian Ott
2019-06-03 15:49 ` [RFC PATCH 02/57] drivers: ipmi: Drop device reference Suzuki K Poulose
2019-06-03 17:01   ` Corey Minyard
2019-06-03 17:03     ` Suzuki K Poulose
2019-06-03 19:09   ` Greg KH
2019-06-03 19:59     ` Corey Minyard
2019-06-04  7:43       ` Greg KH
2019-06-03 15:49 ` [RFC PATCH 03/57] drivers: coresight: Drop device references found via bus_find_device Suzuki K Poulose
2019-06-03 19:08   ` Greg KH
2019-06-04  8:19     ` Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 04/57] drivers: Add generic match helper to match the device of_node Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 05/57] drm: mipi_dsi: Use bus_find_device_by_of_node() helper Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 06/57] drivers: i2c: i2c-core: Use bus_find_device_by_of_node helper Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 07/57] drivers: nvmem: " Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 08/57] drivers: spi: " Suzuki K Poulose
2019-06-03 16:04   ` Mark Brown
2019-06-03 15:49 ` [RFC PATCH 09/57] drivers: sound: rockchip: rk3399: " Suzuki K Poulose
2019-06-03 16:02   ` Mark Brown
2019-06-03 15:49 ` [RFC PATCH 10/57] drivers: coresight: " Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 11/57] of: mdio: " Suzuki K Poulose
2019-06-03 16:00   ` Andrew Lunn
2019-06-03 15:49 ` [RFC PATCH 12/57] of: platform: " Suzuki K Poulose
2019-06-10 20:44   ` Rob Herring
2019-06-03 15:49 ` [RFC PATCH 13/57] drivers: Add generic helper for matching device by fwnode Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 14/57] drivers: devcon: Use bus_find_device_by_fwnode helper Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 15/57] net: hisilicon: hnfs:Use " Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 16/57] net: hns_roce: Use " Suzuki K Poulose
2019-06-03 16:05   ` Jason Gunthorpe
2019-06-03 15:49 ` [RFC PATCH 17/57] drivers: Add generic match by device type helper Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 18/57] drivers: intel_th: Use bus_find_device_by_devt helper Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 19/57] drivers: usb: core: " Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 20/57] platform: Add a helper to find device by driver Suzuki K Poulose
2019-06-04 13:29   ` Heiko Stuebner
2019-06-04 13:31     ` Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 21/57] drivers: Add generic match helper by ACPI_COMPANION device Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 22/57] drivers: i2c: Use generic helper to match device by acpi_dev Suzuki K Poulose
2019-06-04  9:27   ` Mika Westerberg
2019-06-06 20:03   ` Wolfram Sang
2019-06-10 12:49     ` Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 23/57] drivers: spi: Use bus_find_device_by_acpi_dev match helper Suzuki K Poulose
2019-06-03 16:04   ` Mark Brown
2019-06-03 15:49 ` [RFC PATCH 24/57] drivers: staging: most-core: Use bus_find_device_by_name Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 25/57] drivers: Add generic match by name helper Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 26/57] drivers: acpi: Clean up acpi_dev_match_cb Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 27/57] drivers: Unify the match prototype for bus_find_device with class_find_device Suzuki K Poulose
2019-06-04  6:52   ` Harald Freudenberger
2019-06-04 11:26   ` Rafael J. Wysocki
2019-06-04 11:39     ` Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 28/57] drivers: class: Add variants of class_find_device() Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 29/57] drivers: stm: Use class_find_device_by_name() helper Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 30/57] drivers: leds: " Suzuki K Poulose
2019-06-04  8:35   ` Pavel Machek
2019-06-03 15:49 ` [RFC PATCH 31/57] drivers: rtc: " Suzuki K Poulose
2019-06-03 15:49 ` [RFC PATCH 32/57] drivers: s390-crypto: Use class_device_find_by_name() helper Suzuki K Poulose
2019-06-04  6:45   ` Harald Freudenberger
2019-06-03 15:49 ` [RFC PATCH 33/57] drivers: usb: Use class_find_device_by_name() helper Suzuki K Poulose
2019-06-03 15:50 ` [RFC PATCH 34/57] drivers: ieee802154: " Suzuki K Poulose
2019-06-03 15:50 ` [RFC PATCH 35/57] drivers: core: Reuse generic match by device type helper Suzuki K Poulose
2019-06-03 15:50 ` [RFC PATCH 36/57] drivers: mei: Use class_find_device_by_devt match helper Suzuki K Poulose
2019-06-03 18:00   ` Winkler, Tomas
2019-06-04  8:27     ` Suzuki K Poulose
2019-06-03 15:50 ` [RFC PATCH 37/57] drivers: s390: zcrypt: Use class_find_device_by_devt helper Suzuki K Poulose
2019-06-04  6:47   ` Harald Freudenberger
2019-06-03 15:50 ` [RFC PATCH 38/57] drivers: fpga: Use generic helpers to match by of_node Suzuki K Poulose
2019-06-03 15:50 ` [RFC PATCH 39/57] drivers: mux: Use class_find_device_by_of_node helper Suzuki K Poulose
2019-06-03 16:22   ` Peter Rosin
2019-06-03 16:45     ` Suzuki K Poulose
2019-06-03 18:39       ` Peter Rosin
2019-06-03 15:50 ` [RFC PATCH 40/57] drivers: spi: " Suzuki K Poulose
2019-06-03 15:50 ` [RFC PATCH 41/57] drivers: net: phy: " Suzuki K Poulose
2019-06-03 16:02   ` Andrew Lunn
2019-06-03 15:50 ` [RFC PATCH 42/57] drivers: regulator: " Suzuki K Poulose
2019-06-03 16:04   ` Mark Brown
2019-06-03 15:50 ` [RFC PATCH 43/57] drivers: tty : " Suzuki K Poulose
2019-06-03 15:50 ` [RFC PATCH 44/57] drivers: usb : Use class_find_device_by_fwnode() helper Suzuki K Poulose
2019-06-03 15:50 ` [RFC PATCH 45/57] drivers: driver_find_device: Unify the match function Suzuki K Poulose
2019-06-03 15:50 ` [RFC PATCH 46/57] driver: Add variants of driver_find_device() Suzuki K Poulose
2019-06-03 19:10   ` Greg KH
2019-06-04  8:45     ` Suzuki K Poulose
2019-06-04 10:55       ` Suzuki K Poulose
2019-06-04 11:32         ` Greg KH
2019-06-04 11:44           ` Suzuki K Poulose
2019-06-04 11:33         ` Rafael J. Wysocki
2019-06-03 19:11   ` Greg KH
2019-06-04  8:36     ` Suzuki K Poulose
2019-06-04  8:46       ` Greg KH
2019-06-03 19:12   ` Greg KH
2019-06-04  8:33     ` Suzuki K Poulose
2019-06-03 15:50 ` [RFC PATCH 47/57] drivers: mfd: Use driver_find_device_by_name helper Suzuki K Poulose
2019-06-04  9:45   ` Arnd Bergmann
2019-06-04 11:42     ` Suzuki K Poulose
2019-06-04 11:47       ` Arnd Bergmann
2019-06-03 15:50 ` [RFC PATCH 48/57] drivers: s390: cio: Use driver_find_by_name() helper Suzuki K Poulose
2019-06-03 15:50 ` [RFC PATCH 49/57] drivers: mfd: altera: Use driver_find_device_by_of_node() helper Suzuki K Poulose
2019-06-04 16:13   ` Thor Thayer
2019-06-03 15:50 ` [RFC PATCH 50/57] drivers: iommu: arm-smmu: Use driver_find_device_by_fwnode() helper Suzuki K Poulose
2019-06-03 15:50 ` [RFC PATCH 51/57] drivers: Add generic helper to match all devices Suzuki K Poulose
2019-06-03 15:50 ` [RFC PATCH 52/57] drivers: tegra: Use driver_find_device_by_of_node() helper Suzuki K Poulose
2019-06-03 15:50 ` [RFC PATCH 53/57] drivers: Introduce bus_find_next_device() helper Suzuki K Poulose
2019-06-03 15:50 ` [RFC PATCH 54/57] drivers: pci: Use " Suzuki K Poulose
2019-06-03 15:50 ` [RFC PATCH 55/57] drivers: scsi: " Suzuki K Poulose
2019-06-03 15:50 ` [RFC PATCH 56/57] drivers: Introduce driver_find_next_device() helper Suzuki K Poulose
2019-06-03 15:50 ` [RFC PATCH 57/57] drivers: i2c-amd: Use " Suzuki K Poulose

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).