* [PATCH 1/3] driver: support Linux device/driver OF struct member names
@ 2022-12-09 7:10 Ahmad Fatoum
2022-12-09 7:10 ` [PATCH 2/3] clk: add prepare/unprepare helpers Ahmad Fatoum
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2022-12-09 7:10 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
When porting drivers from Linux, one of the modifications that needs to
be done is to rename all .of_node to .device_node and of_match_table
to of_compatible. Just accept both names. It comes at no extra cost.
Once all barebox drivers use the Linux naming, we could drop the union
again.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
include/driver.h | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/include/driver.h b/include/driver.h
index 2386949c312a..1c50b79886c1 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -74,7 +74,10 @@ struct device_d {
struct list_head cdevs;
const struct platform_device_id *id_entry;
- struct device_node *device_node;
+ union {
+ struct device_node *device_node;
+ struct device_node *of_node;
+ };
const struct of_device_id *of_id_entry;
@@ -113,7 +116,10 @@ struct driver_d {
struct bus_type *bus;
const struct platform_device_id *id_table;
- const struct of_device_id *of_compatible;
+ union {
+ const struct of_device_id *of_compatible;
+ const struct of_device_id *of_match_table;
+ };
};
/*@}*/ /* do not delete, doxygen relevant */
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/3] clk: add prepare/unprepare helpers
2022-12-09 7:10 [PATCH 1/3] driver: support Linux device/driver OF struct member names Ahmad Fatoum
@ 2022-12-09 7:10 ` Ahmad Fatoum
2022-12-16 6:38 ` Sascha Hauer
2022-12-09 7:10 ` [PATCH 3/3] of: provide of_node_get and of_node_put stubs Ahmad Fatoum
2022-12-09 9:19 ` [PATCH 1/3] driver: support Linux device/driver OF struct member names Marco Felsch
2 siblings, 1 reply; 5+ messages in thread
From: Ahmad Fatoum @ 2022-12-09 7:10 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
barebox doesn't use interrupts, so it need not differentiate between a
possibly sleeping prepare/unprepare and an atomic enable/disable.
Provide a wrapper that just expands to the already existing functions to
simplify porting of Linux kernel drivers.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
include/linux/clk.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 42c64d650d1f..afa62cdccc02 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -71,6 +71,7 @@ struct clk *clk_get(struct device_d *dev, const char *id);
* Returns success (0) or negative errno.
*/
int clk_enable(struct clk *clk);
+#define clk_prepare_enable(clk) clk_enable(clk)
/**
* clk_disable - inform the system when the clock source is no longer required.
@@ -85,6 +86,7 @@ int clk_enable(struct clk *clk);
* disabled.
*/
void clk_disable(struct clk *clk);
+#define clk_disable_unprepare(clk) clk_disable(clk)
/**
* clk_get_rate - obtain the current clock rate (in Hz) for a clock source.
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/3] of: provide of_node_get and of_node_put stubs
2022-12-09 7:10 [PATCH 1/3] driver: support Linux device/driver OF struct member names Ahmad Fatoum
2022-12-09 7:10 ` [PATCH 2/3] clk: add prepare/unprepare helpers Ahmad Fatoum
@ 2022-12-09 7:10 ` Ahmad Fatoum
2022-12-09 9:19 ` [PATCH 1/3] driver: support Linux device/driver OF struct member names Marco Felsch
2 siblings, 0 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2022-12-09 7:10 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
While removal of of_node_get and of_node_put can simplify ported kernel
code, on the other hand, they can be more of a hassle with future syncs
of the driver. Just provide stubs for them, so they can be left in.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
include/of.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/of.h b/include/of.h
index 901101df051d..e1024e2c3ff8 100644
--- a/include/of.h
+++ b/include/of.h
@@ -101,6 +101,11 @@ static inline const void *of_property_get_value(const struct property *pp)
return pp->value ? pp->value : pp->value_const;
}
+static inline struct device_node *of_node_get(struct device_node *node)
+{
+ return node;
+}
+static inline void of_node_put(struct device_node *node) { }
void of_print_property(const void *data, int len);
void of_print_cmdline(struct device_node *root);
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] driver: support Linux device/driver OF struct member names
2022-12-09 7:10 [PATCH 1/3] driver: support Linux device/driver OF struct member names Ahmad Fatoum
2022-12-09 7:10 ` [PATCH 2/3] clk: add prepare/unprepare helpers Ahmad Fatoum
2022-12-09 7:10 ` [PATCH 3/3] of: provide of_node_get and of_node_put stubs Ahmad Fatoum
@ 2022-12-09 9:19 ` Marco Felsch
2 siblings, 0 replies; 5+ messages in thread
From: Marco Felsch @ 2022-12-09 9:19 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On 22-12-09, Ahmad Fatoum wrote:
> When porting drivers from Linux, one of the modifications that needs to
> be done is to rename all .of_node to .device_node and of_match_table
> to of_compatible. Just accept both names. It comes at no extra cost.
>
> Once all barebox drivers use the Linux naming, we could drop the union
> again.
Nice :)
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
> include/driver.h | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/include/driver.h b/include/driver.h
> index 2386949c312a..1c50b79886c1 100644
> --- a/include/driver.h
> +++ b/include/driver.h
> @@ -74,7 +74,10 @@ struct device_d {
> struct list_head cdevs;
>
> const struct platform_device_id *id_entry;
> - struct device_node *device_node;
> + union {
> + struct device_node *device_node;
> + struct device_node *of_node;
> + };
>
> const struct of_device_id *of_id_entry;
>
> @@ -113,7 +116,10 @@ struct driver_d {
> struct bus_type *bus;
>
> const struct platform_device_id *id_table;
> - const struct of_device_id *of_compatible;
> + union {
> + const struct of_device_id *of_compatible;
> + const struct of_device_id *of_match_table;
> + };
> };
>
> /*@}*/ /* do not delete, doxygen relevant */
> --
> 2.30.2
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/3] clk: add prepare/unprepare helpers
2022-12-09 7:10 ` [PATCH 2/3] clk: add prepare/unprepare helpers Ahmad Fatoum
@ 2022-12-16 6:38 ` Sascha Hauer
0 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2022-12-16 6:38 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Fri, Dec 09, 2022 at 08:10:01AM +0100, Ahmad Fatoum wrote:
> barebox doesn't use interrupts, so it need not differentiate between a
> possibly sleeping prepare/unprepare and an atomic enable/disable.
>
> Provide a wrapper that just expands to the already existing functions to
> simplify porting of Linux kernel drivers.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> include/linux/clk.h | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/include/linux/clk.h b/include/linux/clk.h
> index 42c64d650d1f..afa62cdccc02 100644
> --- a/include/linux/clk.h
> +++ b/include/linux/clk.h
> @@ -71,6 +71,7 @@ struct clk *clk_get(struct device_d *dev, const char *id);
> * Returns success (0) or negative errno.
> */
> int clk_enable(struct clk *clk);
> +#define clk_prepare_enable(clk) clk_enable(clk)
>
> /**
> * clk_disable - inform the system when the clock source is no longer required.
> @@ -85,6 +86,7 @@ int clk_enable(struct clk *clk);
> * disabled.
> */
> void clk_disable(struct clk *clk);
> +#define clk_disable_unprepare(clk) clk_disable(clk)
You should define this outside of #ifdef CONFIG_HAVE_CLK.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-12-16 6:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-09 7:10 [PATCH 1/3] driver: support Linux device/driver OF struct member names Ahmad Fatoum
2022-12-09 7:10 ` [PATCH 2/3] clk: add prepare/unprepare helpers Ahmad Fatoum
2022-12-16 6:38 ` Sascha Hauer
2022-12-09 7:10 ` [PATCH 3/3] of: provide of_node_get and of_node_put stubs Ahmad Fatoum
2022-12-09 9:19 ` [PATCH 1/3] driver: support Linux device/driver OF struct member names Marco Felsch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox