diff mbox series

[U-Boot,v3,05/11] clk: Provide struct clk for fixed rate clock (clk_fixed_rate.c)

Message ID 20190425102953.5348-6-lukma@denx.de
State Changes Requested
Delegated to: Tom Rini
Headers show
Series clk: Port Linux common clock framework [CCF] to U-boot (tag: 5.0-rc3) | expand

Commit Message

Lukasz Majewski April 25, 2019, 10:29 a.m. UTC
Up till now the fixed rate clock ('osc') has been added to UCLASS_CLK
without declaring struct clk. As a result it was only accessible by
iterating the udevice's uclass list.

This is a problem for clock code, which operates on pointers to struct
clk (like clk_get_rate()), not udevices.

After this change struct clk is accessible from udevice and udevice from
struct clk.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
---

Changes in v3: None

 drivers/clk/clk_fixed_rate.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Peng Fan April 26, 2019, 2:29 a.m. UTC | #1
> Subject: [PATCH v3 05/11] clk: Provide struct clk for fixed rate clock
> (clk_fixed_rate.c)
> 
> Up till now the fixed rate clock ('osc') has been added to UCLASS_CLK without
> declaring struct clk. As a result it was only accessible by iterating the
> udevice's uclass list.
> 
> This is a problem for clock code, which operates on pointers to struct clk (like
> clk_get_rate()), not udevices.
> 
> After this change struct clk is accessible from udevice and udevice from struct
> clk.
> 
> Signed-off-by: Lukasz Majewski <lukma@denx.de>
> ---
> 
> Changes in v3: None
> 
>  drivers/clk/clk_fixed_rate.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/clk/clk_fixed_rate.c b/drivers/clk/clk_fixed_rate.c index
> 50dbb13655..089f060a23 100644
> --- a/drivers/clk/clk_fixed_rate.c
> +++ b/drivers/clk/clk_fixed_rate.c
> @@ -8,6 +8,7 @@
>  #include <dm.h>
> 
>  struct clk_fixed_rate {
> +	struct clk clk;
>  	unsigned long fixed_rate;
>  };
> 
> @@ -24,10 +25,14 @@ const struct clk_ops clk_fixed_rate_ops = {
> 
>  static int clk_fixed_rate_ofdata_to_platdata(struct udevice *dev)  {
> +	struct clk *clk = &to_clk_fixed_rate(dev)->clk;
>  #if !CONFIG_IS_ENABLED(OF_PLATDATA)
>  	to_clk_fixed_rate(dev)->fixed_rate =
>  		dev_read_u32_default(dev, "clock-frequency", 0);  #endif
> +	/* Make fixed rate clock accessible from higher level struct clk */
> +	dev->driver_data = (ulong)clk;
> +	clk->dev = dev;

Reviewed-by: Peng Fan <peng.fan@nxp.com>

> 
>  	return 0;
>  }
> --
> 2.11.0
diff mbox series

Patch

diff --git a/drivers/clk/clk_fixed_rate.c b/drivers/clk/clk_fixed_rate.c
index 50dbb13655..089f060a23 100644
--- a/drivers/clk/clk_fixed_rate.c
+++ b/drivers/clk/clk_fixed_rate.c
@@ -8,6 +8,7 @@ 
 #include <dm.h>
 
 struct clk_fixed_rate {
+	struct clk clk;
 	unsigned long fixed_rate;
 };
 
@@ -24,10 +25,14 @@  const struct clk_ops clk_fixed_rate_ops = {
 
 static int clk_fixed_rate_ofdata_to_platdata(struct udevice *dev)
 {
+	struct clk *clk = &to_clk_fixed_rate(dev)->clk;
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	to_clk_fixed_rate(dev)->fixed_rate =
 		dev_read_u32_default(dev, "clock-frequency", 0);
 #endif
+	/* Make fixed rate clock accessible from higher level struct clk */
+	dev->driver_data = (ulong)clk;
+	clk->dev = dev;
 
 	return 0;
 }