[U-Boot] [i.MX8MM+CCF 01/41] clk: correct get clk_x pointer
Lukasz Majewski
lukma at denx.de
Mon May 6 21:36:49 UTC 2019
Hi Peng,
> Directly use driver data is wrong, need to the helper to get
> the correct clk_divider and etc
I just followed the kernel approach.
This works as the address of first element of struct clk_XXX is always
struct clk clk address;
But yes, this may be the preferred (more readable) approach.
>
> Signed-off-by: Peng Fan <peng.fan at nxp.com>
> ---
> drivers/clk/clk-divider.c | 2 +-
> drivers/clk/imx/clk-gate2.c | 4 ++--
> drivers/clk/imx/clk-pfd.c | 2 +-
> drivers/clk/imx/clk-pllv3.c | 2 +-
> 4 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
> index 3841d8bfbb..1d2c1b1ec4 100644
> --- a/drivers/clk/clk-divider.c
> +++ b/drivers/clk/clk-divider.c
> @@ -70,7 +70,7 @@ unsigned long divider_recalc_rate(struct clk *hw,
> unsigned long parent_rate, static ulong
> clk_divider_recalc_rate(struct clk *clk) {
> struct clk_divider *divider =
> - (struct clk_divider *)dev_get_driver_data(clk->dev);
> + to_clk_divider((struct clk
> *)dev_get_driver_data(clk->dev)); unsigned long parent_rate =
> clk_get_parent_rate(clk); unsigned int val;
>
> diff --git a/drivers/clk/imx/clk-gate2.c b/drivers/clk/imx/clk-gate2.c
> index 1e53e4f9db..83589b9206 100644
> --- a/drivers/clk/imx/clk-gate2.c
> +++ b/drivers/clk/imx/clk-gate2.c
> @@ -38,7 +38,7 @@ struct clk_gate2 {
> static int clk_gate2_enable(struct clk *clk)
> {
> struct clk_gate2 *gate =
> - (struct clk_gate2 *)dev_get_driver_data(clk->dev);
> + to_clk_gate2((struct clk
> *)dev_get_driver_data(clk->dev)); u32 reg;
>
> reg = readl(gate->reg);
> @@ -52,7 +52,7 @@ static int clk_gate2_enable(struct clk *clk)
> static int clk_gate2_disable(struct clk *clk)
> {
> struct clk_gate2 *gate =
> - (struct clk_gate2 *)dev_get_driver_data(clk->dev);
> + to_clk_gate2((struct clk
> *)dev_get_driver_data(clk->dev)); u32 reg;
>
> reg = readl(gate->reg);
> diff --git a/drivers/clk/imx/clk-pfd.c b/drivers/clk/imx/clk-pfd.c
> index 2293d481d4..51521ccee6 100644
> --- a/drivers/clk/imx/clk-pfd.c
> +++ b/drivers/clk/imx/clk-pfd.c
> @@ -41,7 +41,7 @@ struct clk_pfd {
> static unsigned long clk_pfd_recalc_rate(struct clk *clk)
> {
> struct clk_pfd *pfd =
> - (struct clk_pfd *)dev_get_driver_data(clk->dev);
> + to_clk_pfd((struct clk
> *)dev_get_driver_data(clk->dev)); unsigned long parent_rate =
> clk_get_parent_rate(clk); u64 tmp = parent_rate;
> u8 frac = (readl(pfd->reg) >> (pfd->idx * 8)) & 0x3f;
> diff --git a/drivers/clk/imx/clk-pllv3.c b/drivers/clk/imx/clk-pllv3.c
> index 3fe9b7c03d..28c0439878 100644
> --- a/drivers/clk/imx/clk-pllv3.c
> +++ b/drivers/clk/imx/clk-pllv3.c
> @@ -27,7 +27,7 @@ struct clk_pllv3 {
> static ulong clk_pllv3_get_rate(struct clk *clk)
> {
> struct clk_pllv3 *pll =
> - (struct clk_pllv3 *)dev_get_driver_data(clk->dev);
> + to_clk_pllv3((struct clk
> *)dev_get_driver_data(clk->dev)); unsigned long parent_rate =
> clk_get_parent_rate(clk);
> u32 div = (readl(pll->base) >> pll->div_shift) &
> pll->div_mask;
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190506/97a5ff1c/attachment.sig>
More information about the U-Boot
mailing list