* [PATCH] [RFC] of/platform: Make of_dev_node_match() helper public
@ 2017-05-05 14:52 Geert Uytterhoeven
2017-05-05 18:50 ` Rob Herring
0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2017-05-05 14:52 UTC (permalink / raw)
To: Rob Herring, Frank Rowand
Cc: Mathieu Poirier, Wolfram Sang, devicetree, linux-kernel,
Geert Uytterhoeven
Several drivers provide their own match functions, identical to
of_dev_node_match() in the OF platform core.
Reduce duplication by making of_dev_node_match() public.
To avoid conflicts, the duplicates in coresight and i2c must be removed
at the same time.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Is "of_dev_node_match()" a suitable name for a public API?
If another (non-conflicting) name is chosen, the conversion of coresight
and i2c can be moved into a separate patch.
TODO: Convert all other code using (non-const) match functions with
different names, but doing exactly the same.
---
drivers/hwtracing/coresight/of_coresight.c | 5 -----
drivers/i2c/i2c-core.c | 5 -----
drivers/of/platform.c | 2 +-
include/linux/of_platform.h | 1 +
4 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c
index 629e031b745651f1..62e8208759dbebc9 100644
--- a/drivers/hwtracing/coresight/of_coresight.c
+++ b/drivers/hwtracing/coresight/of_coresight.c
@@ -25,11 +25,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)
{
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 7a065c4260f30be4..d545ef4eba2c3571 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1830,11 +1830,6 @@ static 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;
-}
-
/* must call put_device() when done with returned i2c_client device */
struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
{
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 71fecc2debfc940a..5e70725ff6f984b4 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -37,7 +37,7 @@ const struct of_device_id of_default_bus_match_table[] = {
{} /* Empty terminated list */
};
-static int of_dev_node_match(struct device *dev, void *data)
+int of_dev_node_match(struct device *dev, void *data)
{
return dev->of_node == data;
}
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index dc8224ae28d5d9e6..7346ba02553b4761 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -57,6 +57,7 @@ extern const struct of_device_id of_default_bus_match_table[];
extern struct platform_device *of_device_alloc(struct device_node *np,
const char *bus_id,
struct device *parent);
+extern int of_dev_node_match(struct device *dev, void *data);
extern struct platform_device *of_find_device_by_node(struct device_node *np);
/* Platform devices and busses creation */
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] [RFC] of/platform: Make of_dev_node_match() helper public
2017-05-05 14:52 [PATCH] [RFC] of/platform: Make of_dev_node_match() helper public Geert Uytterhoeven
@ 2017-05-05 18:50 ` Rob Herring
2017-05-05 19:13 ` Geert Uytterhoeven
0 siblings, 1 reply; 3+ messages in thread
From: Rob Herring @ 2017-05-05 18:50 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Frank Rowand, Mathieu Poirier, Wolfram Sang, devicetree, linux-kernel
On Fri, May 5, 2017 at 9:52 AM, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> Several drivers provide their own match functions, identical to
> of_dev_node_match() in the OF platform core.
>
> Reduce duplication by making of_dev_node_match() public.
> To avoid conflicts, the duplicates in coresight and i2c must be removed
> at the same time.
I think you are down one level too far. At least the 2 users here are
just for calls to bus_find_device. We already have a function for that
with of_find_device_by_node at least for platform devices. Perhaps
rework that to be "struct device *of_find_bus_device_by_node(struct
bus_type *b, struct device_node *np)" and then wrappers for each bus
type. And perhaps make a class variant as well. However, we should
also consider if OF is the right level. Maybe it should be fwnode
functions?
Rob
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] [RFC] of/platform: Make of_dev_node_match() helper public
2017-05-05 18:50 ` Rob Herring
@ 2017-05-05 19:13 ` Geert Uytterhoeven
0 siblings, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2017-05-05 19:13 UTC (permalink / raw)
To: Rob Herring
Cc: Geert Uytterhoeven, Frank Rowand, Mathieu Poirier, Wolfram Sang,
devicetree, linux-kernel
Hi Rob,
On Fri, May 5, 2017 at 8:50 PM, Rob Herring <robh+dt@kernel.org> wrote:
> On Fri, May 5, 2017 at 9:52 AM, Geert Uytterhoeven
> <geert+renesas@glider.be> wrote:
>> Several drivers provide their own match functions, identical to
>> of_dev_node_match() in the OF platform core.
>>
>> Reduce duplication by making of_dev_node_match() public.
>> To avoid conflicts, the duplicates in coresight and i2c must be removed
>> at the same time.
>
> I think you are down one level too far. At least the 2 users here are
> just for calls to bus_find_device. We already have a function for that
There are more of them, some used with driver_find_device().
class_find_device() need a slightly different version, as the data pointer
is const. E.g. drivers/spi/spi.c uses both variants...
device_find_child() can use the same callback.
> with of_find_device_by_node at least for platform devices. Perhaps
> rework that to be "struct device *of_find_bus_device_by_node(struct
> bus_type *b, struct device_node *np)" and then wrappers for each bus
> type. And perhaps make a class variant as well. However, we should
> also consider if OF is the right level. Maybe it should be fwnode
> functions?
There are only 2 of these:
$ git grep 'dev->fwnode == data'
drivers/iommu/arm-smmu-v3.c: return dev->fwnode == data;
drivers/iommu/arm-smmu.c: return dev->fwnode == data;
$
while you can find a few dozen of the OF callbacks.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-05 19:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-05 14:52 [PATCH] [RFC] of/platform: Make of_dev_node_match() helper public Geert Uytterhoeven
2017-05-05 18:50 ` Rob Herring
2017-05-05 19:13 ` Geert Uytterhoeven
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).