* [PATCH 02/22] amba: tegra-ahb: Use of_device_match()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
@ 2016-06-06 8:31 ` Thierry Reding
2016-06-06 18:51 ` Frank Rowand
2016-06-06 8:31 ` [PATCH 03/22] coresight: " Thierry Reding
` (18 subsequent siblings)
19 siblings, 1 reply; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:31 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
From: Thierry Reding <treding@nvidia.com>
Use the common implementation rather than the open-coded variant.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/amba/tegra-ahb.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/amba/tegra-ahb.c b/drivers/amba/tegra-ahb.c
index b0b688c481e8..d87e76cf448c 100644
--- a/drivers/amba/tegra-ahb.c
+++ b/drivers/amba/tegra-ahb.c
@@ -26,6 +26,7 @@
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <soc/tegra/ahb.h>
@@ -143,14 +144,6 @@ 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)
-{
- struct tegra_ahb *ahb = dev_get_drvdata(dev);
- 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;
@@ -158,7 +151,7 @@ int tegra_ahb_enable_smmu(struct device_node *dn)
struct tegra_ahb *ahb;
dev = driver_find_device(&tegra_ahb_driver.driver, NULL, dn,
- tegra_ahb_match_by_smmu);
+ of_device_match);
if (!dev)
return -EPROBE_DEFER;
ahb = dev_get_drvdata(dev);
--
2.8.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH 02/22] amba: tegra-ahb: Use of_device_match()
2016-06-06 8:31 ` [PATCH 02/22] amba: tegra-ahb: Use of_device_match() Thierry Reding
@ 2016-06-06 18:51 ` Frank Rowand
0 siblings, 0 replies; 25+ messages in thread
From: Frank Rowand @ 2016-06-06 18:51 UTC (permalink / raw)
To: Thierry Reding, Rob Herring
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
On 06/06/16 01:31, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> Use the common implementation rather than the open-coded variant.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
> drivers/amba/tegra-ahb.c | 11 ++---------
> 1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/amba/tegra-ahb.c b/drivers/amba/tegra-ahb.c
> index b0b688c481e8..d87e76cf448c 100644
> --- a/drivers/amba/tegra-ahb.c
> +++ b/drivers/amba/tegra-ahb.c
> @@ -26,6 +26,7 @@
> #include <linux/platform_device.h>
> #include <linux/io.h>
> #include <linux/of.h>
> +#include <linux/of_device.h>
>
> #include <soc/tegra/ahb.h>
>
> @@ -143,14 +144,6 @@ 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)
> -{
> - struct tegra_ahb *ahb = dev_get_drvdata(dev);
> - 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;
> @@ -158,7 +151,7 @@ int tegra_ahb_enable_smmu(struct device_node *dn)
> struct tegra_ahb *ahb;
>
> dev = driver_find_device(&tegra_ahb_driver.driver, NULL, dn,
To use of_device_match, should that be something like:
struct tegra_ahb *ahb = dev_get_drvdata(dev);
dev = driver_find_device(&tegra_ahb_driver.driver, NULL, ahb->dev,
> - tegra_ahb_match_by_smmu);
> + of_device_match);
> if (!dev)
> return -EPROBE_DEFER;
> ahb = dev_get_drvdata(dev);
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH 03/22] coresight: Use of_device_match()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
2016-06-06 8:31 ` [PATCH 02/22] amba: tegra-ahb: Use of_device_match() Thierry Reding
@ 2016-06-06 8:31 ` Thierry Reding
2016-06-06 8:31 ` [PATCH 04/22] i2c: core: " Thierry Reding
` (17 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:31 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
From: Thierry Reding <treding@nvidia.com>
Use the common implementation rather than the driver-private variant.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/hwtracing/coresight/of_coresight.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c
index b68da1888fd5..ba438d527d5e 100644
--- a/drivers/hwtracing/coresight/of_coresight.c
+++ b/drivers/hwtracing/coresight/of_coresight.c
@@ -16,6 +16,7 @@
#include <linux/clk.h>
#include <linux/of.h>
#include <linux/of_address.h>
+#include <linux/of_device.h>
#include <linux/of_graph.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
@@ -25,11 +26,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)
{
@@ -40,7 +36,7 @@ of_coresight_get_endpoint_device(struct device_node *endpoint)
* platform bus.
*/
dev = bus_find_device(&platform_bus_type, NULL,
- endpoint, of_dev_node_match);
+ endpoint, of_device_match);
if (dev)
return dev;
@@ -49,7 +45,7 @@ of_coresight_get_endpoint_device(struct device_node *endpoint)
* looking for the device that matches the endpoint node.
*/
return bus_find_device(&amba_bustype, NULL,
- endpoint, of_dev_node_match);
+ endpoint, of_device_match);
}
static void of_coresight_get_ports(struct device_node *node,
--
2.8.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 04/22] i2c: core: Use of_device_match()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
2016-06-06 8:31 ` [PATCH 02/22] amba: tegra-ahb: Use of_device_match() Thierry Reding
2016-06-06 8:31 ` [PATCH 03/22] coresight: " Thierry Reding
@ 2016-06-06 8:31 ` Thierry Reding
2016-06-06 8:31 ` [PATCH 05/22] net: cpsw-phy-sel: " Thierry Reding
` (16 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:31 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
From: Thierry Reding <treding@nvidia.com>
Use the common implementation rather than the I2C-private variant.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/i2c/i2c-core.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index af11b658984d..f0c7d8a64013 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1426,18 +1426,13 @@ static void of_i2c_register_devices(struct i2c_adapter *adap)
}
}
-static int of_dev_node_match(struct device *dev, void *data)
-{
- return dev->of_node == data;
-}
-
/* must call put_device() when done with returned i2c_client device */
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(&i2c_bus_type, NULL, node, of_device_match);
if (!dev)
return NULL;
@@ -1455,7 +1450,7 @@ struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node)
struct device *dev;
struct i2c_adapter *adapter;
- dev = bus_find_device(&i2c_bus_type, NULL, node, of_dev_node_match);
+ dev = bus_find_device(&i2c_bus_type, NULL, node, of_device_match);
if (!dev)
return NULL;
--
2.8.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 05/22] net: cpsw-phy-sel: Use of_device_match()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
` (2 preceding siblings ...)
2016-06-06 8:31 ` [PATCH 04/22] i2c: core: " Thierry Reding
@ 2016-06-06 8:31 ` Thierry Reding
[not found] ` <20160606083204.19760-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
` (15 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:31 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
From: Thierry Reding <treding@nvidia.com>
This driver uses bus_find_device() to go through every platform device
and match using the driver and device tree node. It's more efficient to
use driver_find_device() to iterate over all devices associated with a
particular driver, in which case the matching is reduced to the device
tree node and can be done using the common implementation.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/net/ethernet/ti/cpsw-phy-sel.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/ti/cpsw-phy-sel.c b/drivers/net/ethernet/ti/cpsw-phy-sel.c
index c3e85acfdc70..bb0de7744681 100644
--- a/drivers/net/ethernet/ti/cpsw-phy-sel.c
+++ b/drivers/net/ethernet/ti/cpsw-phy-sel.c
@@ -143,12 +143,6 @@ 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)
-{
- struct device_node *node = (struct device_node *)data;
- return dev->of_node == node &&
- dev->driver == &cpsw_phy_sel_driver.driver;
-}
void cpsw_phy_sel(struct device *dev, phy_interface_t phy_mode, int slave)
{
@@ -161,7 +155,8 @@ void cpsw_phy_sel(struct device *dev, phy_interface_t phy_mode, int slave)
return;
}
- dev = bus_find_device(&platform_bus_type, NULL, node, match);
+ dev = driver_find_device(&cpsw_phy_sel_driver.driver, NULL, node,
+ of_device_match);
priv = dev_get_drvdata(dev);
priv->cpsw_phy_sel(priv, phy_mode, slave);
--
2.8.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
[parent not found: <20160606083204.19760-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* [PATCH 01/22] of: Implement of_match_device()
[not found] ` <20160606083204.19760-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-06-06 8:31 ` Thierry Reding
2016-06-06 8:31 ` [PATCH 06/22] nvmem: core: Use of_device_match() Thierry Reding
` (2 subsequent siblings)
3 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:31 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Many drivers open-code a variant of this function to look up the device
representing a given device tree node. Provide a common implementation
that can be reused by all drivers to avoid duplication.
Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
drivers/gpu/drm/drm_mipi_dsi.c | 5 -----
include/linux/of_device.h | 5 +++++
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index f5d80839a90c..37f95f3b2dd2 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -77,11 +77,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
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index cc7dd687a89d..ada83eac2ae2 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -102,4 +102,9 @@ static inline void of_dma_configure(struct device *dev, struct device_node *np)
{}
#endif /* CONFIG_OF */
+static inline int of_device_match(struct device *dev, void *data)
+{
+ return dev->of_node == data;
+}
+
#endif /* _LINUX_OF_DEVICE_H */
--
2.8.3
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 06/22] nvmem: core: Use of_device_match()
[not found] ` <20160606083204.19760-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-06-06 8:31 ` [PATCH 01/22] of: Implement of_match_device() Thierry Reding
@ 2016-06-06 8:31 ` Thierry Reding
2016-06-06 8:31 ` [PATCH 10/22] usb: phy: am335x-control: " Thierry Reding
2016-06-06 8:31 ` [PATCH 13/22] drm/armada: " Thierry Reding
3 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:31 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Use the common implementation rather than the subsystem-specific one.
Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
drivers/nvmem/core.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 965911d9b36a..c4062fb39522 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -23,6 +23,7 @@
#include <linux/nvmem-consumer.h>
#include <linux/nvmem-provider.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/slab.h>
struct nvmem_device {
@@ -263,11 +264,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;
@@ -275,7 +271,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(&nvmem_bus_type, NULL, nvmem_np, of_device_match);
if (!d)
return NULL;
--
2.8.3
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 10/22] usb: phy: am335x-control: Use of_device_match()
[not found] ` <20160606083204.19760-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-06-06 8:31 ` [PATCH 01/22] of: Implement of_match_device() Thierry Reding
2016-06-06 8:31 ` [PATCH 06/22] nvmem: core: Use of_device_match() Thierry Reding
@ 2016-06-06 8:31 ` Thierry Reding
2016-06-06 8:31 ` [PATCH 13/22] drm/armada: " Thierry Reding
3 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:31 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
This driver uses bus_find_device() to go through every platform device
and match using the driver and device tree node. It's more efficient to
use driver_find_device() to iterate over all devices associated with a
particular driver, in which case the matching is reduced to the device
tree node and can be done using the common implementation.
Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
drivers/usb/phy/phy-am335x-control.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/phy/phy-am335x-control.c b/drivers/usb/phy/phy-am335x-control.c
index 42a1afe36a90..1ac16f649154 100644
--- a/drivers/usb/phy/phy-am335x-control.c
+++ b/drivers/usb/phy/phy-am335x-control.c
@@ -2,6 +2,7 @@
#include <linux/platform_device.h>
#include <linux/err.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/io.h>
#include <linux/delay.h>
#include <linux/usb/otg.h>
@@ -117,12 +118,6 @@ 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)
-{
- struct device_node *node = (struct device_node *)data;
- return dev->of_node == node &&
- dev->driver == &am335x_control_driver.driver;
-}
struct phy_control *am335x_get_phy_control(struct device *dev)
{
@@ -133,7 +128,8 @@ struct phy_control *am335x_get_phy_control(struct device *dev)
if (!node)
return NULL;
- dev = bus_find_device(&platform_bus_type, NULL, node, match);
+ dev = driver_find_device(&am335x_control_driver.driver, NULL, node,
+ of_device_match);
if (!dev)
return NULL;
--
2.8.3
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 13/22] drm/armada: Use of_device_match()
[not found] ` <20160606083204.19760-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
` (2 preceding siblings ...)
2016-06-06 8:31 ` [PATCH 10/22] usb: phy: am335x-control: " Thierry Reding
@ 2016-06-06 8:31 ` Thierry Reding
3 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:31 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Use the common implementation rather than the driver-private variant.
Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
drivers/gpu/drm/armada/armada_drv.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index 6ca2aa36515e..c86807187183 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -8,6 +8,7 @@
#include <linux/clk.h>
#include <linux/component.h>
#include <linux/module.h>
+#include <linux/of_device.h>
#include <linux/of_graph.h>
#include <drm/drmP.h>
#include <drm/drm_crtc_helper.h>
@@ -227,11 +228,6 @@ static void armada_drm_unbind(struct device *dev)
drm_put_dev(dev_get_drvdata(dev));
}
-static int compare_of(struct device *dev, void *data)
-{
- return dev->of_node == data;
-}
-
static void release_of(struct device *dev, void *data)
{
of_node_put(data);
@@ -261,7 +257,7 @@ static void armada_add_endpoints(struct device *dev,
}
component_match_add_release(dev, match, release_of,
- compare_of, remote);
+ of_device_match, remote);
}
}
--
2.8.3
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 07/22] of/platform: Use of_device_match()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
` (4 preceding siblings ...)
[not found] ` <20160606083204.19760-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-06-06 8:31 ` Thierry Reding
2016-06-06 8:31 ` [PATCH 08/22] spi: " Thierry Reding
` (13 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:31 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
From: Thierry Reding <treding@nvidia.com>
Use the common implementation rather than the OF-private variant.
Signed-off-by: Thierry Reding <treding@nvidia.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 16e8daffac06..61d00cce9291 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -33,11 +33,6 @@ const struct of_device_id of_default_bus_match_table[] = {
};
EXPORT_SYMBOL(of_default_bus_match_table);
-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
@@ -48,7 +43,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(&platform_bus_type, NULL, np, of_device_match);
return dev ? to_platform_device(dev) : NULL;
}
EXPORT_SYMBOL(of_find_device_by_node);
--
2.8.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 08/22] spi: Use of_device_match()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
` (5 preceding siblings ...)
2016-06-06 8:31 ` [PATCH 07/22] of/platform: " Thierry Reding
@ 2016-06-06 8:31 ` Thierry Reding
2016-06-06 8:31 ` [PATCH 09/22] of: mdio: " Thierry Reding
` (12 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:31 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
From: Thierry Reding <treding@nvidia.com>
Use the common implementation rather than the SPI-private variant.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/spi/spi.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 77e6e45951f4..df0d800b19f0 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -3019,16 +3019,11 @@ EXPORT_SYMBOL_GPL(spi_write_then_read);
/*-------------------------------------------------------------------------*/
#if IS_ENABLED(CONFIG_OF_DYNAMIC)
-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 */
static 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);
+ of_device_match);
return dev ? to_spi_device(dev) : NULL;
}
--
2.8.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 09/22] of: mdio: Use of_device_match()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
` (6 preceding siblings ...)
2016-06-06 8:31 ` [PATCH 08/22] spi: " Thierry Reding
@ 2016-06-06 8:31 ` Thierry Reding
2016-06-06 8:31 ` [PATCH 11/22] usb: phy: isp1301: " Thierry Reding
` (11 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:31 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
From: Thierry Reding <treding@nvidia.com>
Use the common implementation rather than the MDIO-private variant.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/of/of_mdio.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index e051e1b57609..5d7d95900f44 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -16,6 +16,7 @@
#include <linux/phy.h>
#include <linux/phy_fixed.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <linux/of_irq.h>
#include <linux/of_mdio.h>
@@ -265,12 +266,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
@@ -286,7 +281,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(&mdio_bus_type, NULL, phy_np, of_device_match);
if (d) {
mdiodev = to_mdio_device(d);
if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY)
--
2.8.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 11/22] usb: phy: isp1301: Use of_device_match()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
` (7 preceding siblings ...)
2016-06-06 8:31 ` [PATCH 09/22] of: mdio: " Thierry Reding
@ 2016-06-06 8:31 ` Thierry Reding
2016-06-06 8:31 ` [PATCH 12/22] drm/hdlcd: " Thierry Reding
` (10 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:31 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
From: Thierry Reding <treding@nvidia.com>
This driver uses bus_find_device() to go through every platform device
and match using the driver and device tree node. It's more efficient to
use driver_find_device() to iterate over all devices associated with a
particular driver, in which case the matching is reduced to the device
tree node and can be done using the common implementation.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/usb/phy/phy-isp1301.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/phy/phy-isp1301.c b/drivers/usb/phy/phy-isp1301.c
index db68156568e6..a5f5dc0b8c18 100644
--- a/drivers/usb/phy/phy-isp1301.c
+++ b/drivers/usb/phy/phy-isp1301.c
@@ -13,6 +13,7 @@
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/i2c.h>
+#include <linux/of_device.h>
#include <linux/usb/phy.h>
#include <linux/usb/isp1301.h>
@@ -138,18 +139,12 @@ static struct i2c_driver isp1301_driver = {
module_i2c_driver(isp1301_driver);
-static int match(struct device *dev, void *data)
-{
- struct device_node *node = (struct device_node *)data;
- return (dev->of_node == node) &&
- (dev->driver == &isp1301_driver.driver);
-}
-
struct i2c_client *isp1301_get_client(struct device_node *node)
{
if (node) { /* reference of ISP1301 I2C node via DT */
- struct device *dev = bus_find_device(&i2c_bus_type, NULL,
- node, match);
+ struct device *dev = driver_find_device(&isp1301_driver.driver,
+ NULL, node,
+ of_device_match);
if (!dev)
return NULL;
return to_i2c_client(dev);
--
2.8.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 12/22] drm/hdlcd: Use of_device_match()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
` (8 preceding siblings ...)
2016-06-06 8:31 ` [PATCH 11/22] usb: phy: isp1301: " Thierry Reding
@ 2016-06-06 8:31 ` Thierry Reding
2016-06-06 8:31 ` [PATCH 14/22] drm/etnaviv: " Thierry Reding
` (9 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:31 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
From: Thierry Reding <treding@nvidia.com>
Use the common implementation rather than the driver-private variant.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/gpu/drm/arm/hdlcd_drv.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index 3422ca23cfaf..4fa93123802b 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -14,6 +14,7 @@
#include <linux/clk.h>
#include <linux/component.h>
#include <linux/list.h>
+#include <linux/of_device.h>
#include <linux/of_graph.h>
#include <linux/of_reserved_mem.h>
#include <linux/pm_runtime.h>
@@ -429,11 +430,6 @@ static const struct component_master_ops hdlcd_master_ops = {
.unbind = hdlcd_drm_unbind,
};
-static int compare_of(struct device *dev, void *data)
-{
- return dev->of_node == data;
-}
-
static void release_of(struct device *dev, void *data)
{
of_node_put(data);
@@ -466,7 +462,7 @@ static int hdlcd_probe(struct platform_device *pdev)
}
component_match_add_release(&pdev->dev, &match, release_of,
- compare_of, port);
+ of_device_match, port);
return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
match);
--
2.8.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 14/22] drm/etnaviv: Use of_device_match()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
` (9 preceding siblings ...)
2016-06-06 8:31 ` [PATCH 12/22] drm/hdlcd: " Thierry Reding
@ 2016-06-06 8:31 ` Thierry Reding
2016-06-06 8:31 ` [PATCH 15/22] drm/hisilicon: " Thierry Reding
` (8 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:31 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
From: Thierry Reding <treding@nvidia.com>
Use the common implementation rather than the driver-private variant.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/gpu/drm/etnaviv/etnaviv_drv.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index 3d4f56df8359..187523110d58 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -15,6 +15,7 @@
*/
#include <linux/component.h>
+#include <linux/of_device.h>
#include <linux/of_platform.h>
#include "etnaviv_drv.h"
@@ -606,13 +607,6 @@ static const struct component_master_ops etnaviv_master_ops = {
.unbind = etnaviv_unbind,
};
-static int compare_of(struct device *dev, void *data)
-{
- struct device_node *np = data;
-
- return dev->of_node == np;
-}
-
static int compare_str(struct device *dev, void *data)
{
return !strcmp(dev_name(dev), data);
@@ -635,8 +629,8 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
if (!core_node)
break;
- component_match_add(&pdev->dev, &match, compare_of,
- core_node);
+ component_match_add(&pdev->dev, &match,
+ of_device_match, core_node);
of_node_put(core_node);
}
} else if (dev->platform_data) {
--
2.8.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 15/22] drm/hisilicon: Use of_device_match()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
` (10 preceding siblings ...)
2016-06-06 8:31 ` [PATCH 14/22] drm/etnaviv: " Thierry Reding
@ 2016-06-06 8:31 ` Thierry Reding
2016-06-06 8:31 ` [PATCH 16/22] drm/mediatek: " Thierry Reding
` (7 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:31 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
From: Thierry Reding <treding@nvidia.com>
Use the common implementation rather than the driver-private variant.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
index 193657259ee9..c153b486c89d 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
@@ -15,6 +15,7 @@
*
*/
+#include <linux/of_device.h>
#include <linux/of_platform.h>
#include <linux/component.h>
#include <linux/of_graph.h>
@@ -196,11 +197,6 @@ static struct drm_driver kirin_drm_driver = {
.minor = 0,
};
-static int compare_of(struct device *dev, void *data)
-{
- return dev->of_node == data;
-}
-
static int kirin_drm_bind(struct device *dev)
{
struct drm_driver *driver = &kirin_drm_driver;
@@ -303,7 +299,7 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
if (IS_ERR(remote))
return PTR_ERR(remote);
- component_match_add(dev, &match, compare_of, remote);
+ component_match_add(dev, &match, of_device_match, remote);
return component_master_add_with_match(dev, &kirin_drm_ops, match);
--
2.8.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 16/22] drm/mediatek: Use of_device_match()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
` (11 preceding siblings ...)
2016-06-06 8:31 ` [PATCH 15/22] drm/hisilicon: " Thierry Reding
@ 2016-06-06 8:31 ` Thierry Reding
2016-06-06 8:31 ` [PATCH 17/22] drm/msm: " Thierry Reding
` (6 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:31 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
From: Thierry Reding <treding@nvidia.com>
Use the common implementation rather than the driver-private variant.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/gpu/drm/mediatek/mtk_drm_drv.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index 06a417b2f91e..9ab44224dcc0 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -21,6 +21,7 @@
#include <linux/component.h>
#include <linux/iommu.h>
#include <linux/of_address.h>
+#include <linux/of_device.h>
#include <linux/of_platform.h>
#include <linux/pm_runtime.h>
@@ -265,11 +266,6 @@ static struct drm_driver mtk_drm_driver = {
.minor = DRIVER_MINOR,
};
-static int compare_of(struct device *dev, void *data)
-{
- return dev->of_node == data;
-}
-
static int mtk_drm_bind(struct device *dev)
{
struct mtk_drm_private *private = dev_get_drvdata(dev);
@@ -406,7 +402,7 @@ static int mtk_drm_probe(struct platform_device *pdev)
comp_type == MTK_DPI) {
dev_info(dev, "Adding component match for %s\n",
node->full_name);
- component_match_add(dev, &match, compare_of, node);
+ component_match_add(dev, &match, of_device_match, node);
} else {
struct mtk_ddp_comp *comp;
--
2.8.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 17/22] drm/msm: Use of_device_match()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
` (12 preceding siblings ...)
2016-06-06 8:31 ` [PATCH 16/22] drm/mediatek: " Thierry Reding
@ 2016-06-06 8:31 ` Thierry Reding
2016-06-06 8:32 ` [PATCH 18/22] drm/rockchip: " Thierry Reding
` (5 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:31 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
From: Thierry Reding <treding@nvidia.com>
Use the common implementation rather than the driver-private variant.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/gpu/drm/msm/msm_drv.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 1f7de47d817e..554d0b4f1e9b 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -15,6 +15,8 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <linux/of_device.h>
+
#include "msm_drv.h"
#include "msm_debugfs.h"
#include "msm_fence.h"
@@ -796,15 +798,6 @@ static const struct dev_pm_ops msm_pm_ops = {
* Componentized driver support:
*/
-/*
- * NOTE: duplication of the same code as exynos or imx (or probably any other).
- * so probably some room for some helpers
- */
-static int compare_of(struct device *dev, void *data)
-{
- return dev->of_node == data;
-}
-
static void release_of(struct device *dev, void *data)
{
of_node_put(data);
@@ -824,7 +817,7 @@ static int add_components(struct device *dev, struct component_match **matchptr,
break;
component_match_add_release(dev, matchptr, release_of,
- compare_of, node);
+ of_device_match, node);
}
return 0;
--
2.8.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 18/22] drm/rockchip: Use of_device_match()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
` (13 preceding siblings ...)
2016-06-06 8:31 ` [PATCH 17/22] drm/msm: " Thierry Reding
@ 2016-06-06 8:32 ` Thierry Reding
2016-06-06 8:32 ` [PATCH 19/22] drm/sti: " Thierry Reding
` (4 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:32 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
From: Thierry Reding <treding@nvidia.com>
Use the common implementation rather than the driver-private variant.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index f5a68fc031ed..afd08288ee86 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -22,6 +22,7 @@
#include <linux/dma-mapping.h>
#include <linux/pm_runtime.h>
#include <linux/module.h>
+#include <linux/of_device.h>
#include <linux/of_graph.h>
#include <linux/component.h>
@@ -414,13 +415,6 @@ static const struct dev_pm_ops rockchip_drm_pm_ops = {
rockchip_drm_sys_resume)
};
-static int compare_of(struct device *dev, void *data)
-{
- struct device_node *np = data;
-
- return dev->of_node == np;
-}
-
static void release_of(struct device *dev, void *data)
{
of_node_put(data);
@@ -445,7 +439,7 @@ static void rockchip_add_endpoints(struct device *dev,
}
component_match_add_release(dev, match, release_of,
- compare_of, remote);
+ of_device_match, remote);
}
}
@@ -525,7 +519,7 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
of_node_get(port->parent);
component_match_add_release(dev, &match, release_of,
- compare_of, port->parent);
+ of_device_match, port->parent);
of_node_put(port);
}
--
2.8.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 19/22] drm/sti: Use of_device_match()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
` (14 preceding siblings ...)
2016-06-06 8:32 ` [PATCH 18/22] drm/rockchip: " Thierry Reding
@ 2016-06-06 8:32 ` Thierry Reding
2016-06-06 8:32 ` [PATCH 20/22] drm/sun4i: " Thierry Reding
` (3 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:32 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
From: Thierry Reding <treding@nvidia.com>
Use the common implementation rather than the driver-private variant.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/gpu/drm/sti/sti_drv.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index 4ee6fa4f1beb..d0ea8c3b8e3c 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -10,6 +10,7 @@
#include <linux/debugfs.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/of_device.h>
#include <linux/of_platform.h>
#include <drm/drm_atomic.h>
@@ -341,11 +342,6 @@ static struct drm_driver sti_driver = {
.minor = DRIVER_MINOR,
};
-static int compare_of(struct device *dev, void *data)
-{
- return dev->of_node == data;
-}
-
static void release_of(struct device *dev, void *data)
{
of_node_put(data);
@@ -381,7 +377,7 @@ static int sti_platform_probe(struct platform_device *pdev)
while (child_np) {
component_match_add_release(dev, &match, release_of,
- compare_of, child_np);
+ of_device_match, child_np);
child_np = of_get_next_available_child(node, child_np);
}
--
2.8.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 20/22] drm/sun4i: Use of_device_match()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
` (15 preceding siblings ...)
2016-06-06 8:32 ` [PATCH 19/22] drm/sti: " Thierry Reding
@ 2016-06-06 8:32 ` Thierry Reding
2016-06-06 8:32 ` [PATCH 21/22] drm/tilcdc: " Thierry Reding
` (2 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:32 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
From: Thierry Reding <treding@nvidia.com>
Use the common implementation instead of the driver-private variant.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/gpu/drm/sun4i/sun4i_drv.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
index 257d2b4f3645..6a61d9c8afa1 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -11,6 +11,7 @@
*/
#include <linux/component.h>
+#include <linux/of_device.h>
#include <linux/of_graph.h>
#include <drm/drmP.h>
@@ -219,15 +220,6 @@ static bool sun4i_drv_node_is_tcon(struct device_node *node)
return of_device_is_compatible(node, "allwinner,sun5i-a13-tcon");
}
-static int compare_of(struct device *dev, void *data)
-{
- DRM_DEBUG_DRIVER("Comparing of node %s with %s\n",
- of_node_full_name(dev->of_node),
- of_node_full_name(data));
-
- return dev->of_node == data;
-}
-
static int sun4i_drv_add_endpoints(struct device *dev,
struct component_match **match,
struct device_node *node)
@@ -248,7 +240,7 @@ static int sun4i_drv_add_endpoints(struct device *dev,
/* Add current component */
DRM_DEBUG_DRIVER("Adding component %s\n",
of_node_full_name(node));
- component_match_add(dev, match, compare_of, node);
+ component_match_add(dev, match, of_device_match, node);
count++;
}
--
2.8.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 21/22] drm/tilcdc: Use of_device_match()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
` (16 preceding siblings ...)
2016-06-06 8:32 ` [PATCH 20/22] drm/sun4i: " Thierry Reding
@ 2016-06-06 8:32 ` Thierry Reding
2016-06-06 8:32 ` [PATCH 22/22] iommu/mediatek: " Thierry Reding
2016-06-06 18:50 ` [PATCH 00/22] of: Introduce of_match_device() Frank Rowand
19 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:32 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
From: Thierry Reding <treding@nvidia.com>
Use the common implementation instead of the driver-private variant.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/gpu/drm/tilcdc/tilcdc_external.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index 7e11b5ecdd4a..78196a90d7ba 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
@@ -9,6 +9,7 @@
*/
#include <linux/component.h>
+#include <linux/of_device.h>
#include <linux/of_graph.h>
#include "tilcdc_drv.h"
@@ -130,11 +131,6 @@ void tilcdc_remove_external_encoders(struct drm_device *dev)
priv->connector_funcs[i]);
}
-static int dev_match_of(struct device *dev, void *data)
-{
- return dev->of_node == data;
-}
-
static void dev_release_of(struct device *dev, void *data)
{
of_node_put(data);
@@ -158,7 +154,7 @@ int tilcdc_get_external_components(struct device *dev,
dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
if (match)
component_match_add_release(dev, match, dev_release_of,
- dev_match_of, node);
+ of_device_match, node);
count++;
}
--
2.8.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 22/22] iommu/mediatek: Use of_device_match()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
` (17 preceding siblings ...)
2016-06-06 8:32 ` [PATCH 21/22] drm/tilcdc: " Thierry Reding
@ 2016-06-06 8:32 ` Thierry Reding
2016-06-06 18:50 ` [PATCH 00/22] of: Introduce of_match_device() Frank Rowand
19 siblings, 0 replies; 25+ messages in thread
From: Thierry Reding @ 2016-06-06 8:32 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
From: Thierry Reding <treding@nvidia.com>
Use the common implementation instead of the driver-private variant.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/iommu/mtk_iommu.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index c036df1c49ca..80e7b7a79343 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -24,6 +24,7 @@
#include <linux/iopoll.h>
#include <linux/list.h>
#include <linux/of_address.h>
+#include <linux/of_device.h>
#include <linux/of_iommu.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
@@ -552,11 +553,6 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data *data)
return 0;
}
-static int compare_of(struct device *dev, void *data)
-{
- return dev->of_node == data;
-}
-
static void release_of(struct device *dev, void *data)
{
of_node_put(data);
@@ -647,7 +643,7 @@ static int mtk_iommu_probe(struct platform_device *pdev)
data->smi_imu.larb_imu[i].dev = &plarbdev->dev;
component_match_add_release(dev, &match, release_of,
- compare_of, larbnode);
+ of_device_match, larbnode);
}
platform_set_drvdata(pdev, data);
--
2.8.3
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH 00/22] of: Introduce of_match_device()
2016-06-06 8:31 [PATCH 00/22] of: Introduce of_match_device() Thierry Reding
` (18 preceding siblings ...)
2016-06-06 8:32 ` [PATCH 22/22] iommu/mediatek: " Thierry Reding
@ 2016-06-06 18:50 ` Frank Rowand
19 siblings, 0 replies; 25+ messages in thread
From: Frank Rowand @ 2016-06-06 18:50 UTC (permalink / raw)
To: Thierry Reding, Rob Herring
Cc: Greg Kroah-Hartman, Russell King, devicetree, linux-kernel
On 06/06/16 01:31, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> This series of patches introduces a common implementation of a function
> that can be used in iterators (such as the bus_for_each_dev() or the
> driver_for_each_device() functions) and that compare's a device's device
> tree node with the passed in data. Numerous drivers and subsystems have
> their own variant of this function, so a lot of duplication can be
> removed by making use of the common implementation.
>
> One thing that slightly bugs me about this is that it can't be used with
> users of class_for_each_device() or class_find_device() because they get
> passed a callback that takes a const void * rather than a void * for the
> device tree node. I had at some point investigated to turn the remainder
> of the iterators into taking const void *, but there are some drivers in
> the kernel that want to modify the data passed to them, so it isn't easy
> to switch.
>
> An alternative would be to turn the const void * into void * for all the
> callbacks of this sort, so that we can use a single set throughout the
> tree, but I'm not sure how welcome that would be. I can give that a shot
> if people think it worth, though.
>
> Greg, any thoughts on this?
>
> I've also kept the list of recipients very short, to get early feedback
> and buy-in from Rob and Frank on the common implementation. I expect the
> naming to allow for some good bike-shedding.
Common implementation looks fine to me.
My shot at bike-shedding is to make the function name reflect the argument
names of bus_find_device() and driver_find_device(). That would suggest
of_node_match_data(). Or if one wanted to be more concise, of_node_match()
or of_match_node().
But of_match_node() is already in wide use (for something else entirely).
And drivers/regulator/core.c is the one existing version of of_node_match():
static int of_node_match(struct device *dev, const void *data)
{
return dev->of_node == data;
}
This is an example of the 'const void *data' vs 'void *data' that you
mentioned, because this of_node_match() is used for class_find_device().
of_node_match() could be used since only one current usage of the
name would have to be changed to some other name.
So that brings me back to of_node_match_data() being my preference
because of_node_match() is entirely too similar to of_match_node(),
which seems like it would lead to confusion when I am reading code.
Then maybe a variant on that name with a 'const void *data' argument.
Like the longer than I would like of_node_match_const_data().
< snip >
-Frank
^ permalink raw reply [flat|nested] 25+ messages in thread