devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 01/63] of: Add a new macro to declare_of for one parameter function returning a value
       [not found] <1466112442-31105-1-git-send-email-daniel.lezcano@linaro.org>
@ 2016-06-16 21:26 ` Daniel Lezcano
       [not found]   ` <1466112442-31105-2-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Lezcano @ 2016-06-16 21:26 UTC (permalink / raw)
  To: daniel.lezcano, tglx
  Cc: linux-kernel, Rob Herring, Frank Rowand, Grant Likely,
	open list:OPEN FIRMWARE AND...

The macro OF_DECLARE_1 expect a void (*func)(struct device_node *) while the
OF_DECLARE_2 expect a int (*func)(struct device_node *, struct device_node *).

The second one allows to pass an init function returning a value, which make
possible to call the functions in the table and check the return value in order
to catch at a higher level the errors and handle them from there instead of
doing a panic in each driver (well at least this is the case for the clkevt).

Unfortunately the OF_DECLARE_1 does not allow that and that lead to some code
duplication and crappyness in the drivers.

The OF_DECLARE_1 is used by all the clk drivers and the clocksource/clockevent
drivers. It is not possible to do the change in one shot as we have to change
all the init functions.

The OF_DECLARE_2 specifies an init function prototype with two parameters with
the node and its parent. The latter won't be used, ever, in the timer drivers.

Introduce a OF_DECLARE_1_RET macro to be used, and hopefully we can smoothly
and iteratively change the users of OF_DECLARE_1 to use the new macro instead.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 include/linux/of.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/of.h b/include/linux/of.h
index c7292e8..552943d 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -1009,10 +1009,13 @@ static inline int of_get_available_child_count(const struct device_node *np)
 #endif
 
 typedef int (*of_init_fn_2)(struct device_node *, struct device_node *);
+typedef int (*of_init_fn_1_ret)(struct device_node *);
 typedef void (*of_init_fn_1)(struct device_node *);
 
 #define OF_DECLARE_1(table, name, compat, fn) \
 		_OF_DECLARE(table, name, compat, fn, of_init_fn_1)
+#define OF_DECLARE_1_RET(table, name, compat, fn) \
+		_OF_DECLARE(table, name, compat, fn, of_init_fn_1_ret)
 #define OF_DECLARE_2(table, name, compat, fn) \
 		_OF_DECLARE(table, name, compat, fn, of_init_fn_2)
 
-- 
1.9.1

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

* Re: [PATCH V2 01/63] of: Add a new macro to declare_of for one parameter function returning a value
       [not found]   ` <1466112442-31105-2-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2016-06-20 21:03     ` Rob Herring
  0 siblings, 0 replies; 2+ messages in thread
From: Rob Herring @ 2016-06-20 21:03 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Thomas Gleixner,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Frank Rowand, Grant Likely, open list:OPEN FIRMWARE AND...

On Thu, Jun 16, 2016 at 4:26 PM, Daniel Lezcano
<daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> wrote:
> The macro OF_DECLARE_1 expect a void (*func)(struct device_node *) while the
> OF_DECLARE_2 expect a int (*func)(struct device_node *, struct device_node *).
>
> The second one allows to pass an init function returning a value, which make
> possible to call the functions in the table and check the return value in order
> to catch at a higher level the errors and handle them from there instead of
> doing a panic in each driver (well at least this is the case for the clkevt).
>
> Unfortunately the OF_DECLARE_1 does not allow that and that lead to some code
> duplication and crappyness in the drivers.
>
> The OF_DECLARE_1 is used by all the clk drivers and the clocksource/clockevent
> drivers. It is not possible to do the change in one shot as we have to change
> all the init functions.
>
> The OF_DECLARE_2 specifies an init function prototype with two parameters with
> the node and its parent. The latter won't be used, ever, in the timer drivers.
>
> Introduce a OF_DECLARE_1_RET macro to be used, and hopefully we can smoothly
> and iteratively change the users of OF_DECLARE_1 to use the new macro instead.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
>  include/linux/of.h | 3 +++
>  1 file changed, 3 insertions(+)

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
--
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	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-20 21:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1466112442-31105-1-git-send-email-daniel.lezcano@linaro.org>
2016-06-16 21:26 ` [PATCH V2 01/63] of: Add a new macro to declare_of for one parameter function returning a value Daniel Lezcano
     [not found]   ` <1466112442-31105-2-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-06-20 21:03     ` Rob Herring

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