diff mbox series

[v7,04/22] clk: Fix clk_get_by_* handling of index

Message ID 20200319205420.720815-5-seanga2@gmail.com
State Superseded
Headers show
Series riscv: Add Sipeed Maix support | expand

Commit Message

Sean Anderson March 19, 2020, 8:54 p.m. UTC
clk_get_by_index_nodev only ever fetched clock 1, due to passing a boolean
predicate instead of the index. Other clk_get_by_* functions got the clock
correctly, but passed a predicate instead of the index to clk_get_by_tail.
This could lead to confusing error messages.

Signed-off-by: Sean Anderson <seanga2 at gmail.com>
---

Changes in v7:
- New

 drivers/clk/clk-uclass.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Rick Chen March 30, 2020, 6:42 a.m. UTC | #1
Hi Jagan

> clk_get_by_index_nodev only ever fetched clock 1, due to passing a boolean
> predicate instead of the index. Other clk_get_by_* functions got the clock
> correctly, but passed a predicate instead of the index to clk_get_by_tail.
> This could lead to confusing error messages.
>
> Signed-off-by: Sean Anderson <seanga2 at gmail.com>
> ---
>
> Changes in v7:
> - New
>
>  drivers/clk/clk-uclass.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
> index aa8dd9d027..c082fe95ff 100644
> --- a/drivers/clk/clk-uclass.c
> +++ b/drivers/clk/clk-uclass.c

Do you have any suggestions about this patch ?

Thanks
Rick

> @@ -121,7 +121,7 @@ static int clk_get_by_indexed_prop(struct udevice *dev, const char *prop_name,
>
>
>         return clk_get_by_index_tail(ret, dev_ofnode(dev), &args, "clocks",
> -                                    index > 0, clk);
> +                                    index, clk);
>  }
>
>  int clk_get_by_index(struct udevice *dev, int index, struct clk *clk)
> @@ -133,7 +133,7 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk)
>                                          index, &args);
>
>         return clk_get_by_index_tail(ret, dev_ofnode(dev), &args, "clocks",
> -                                    index > 0, clk);
> +                                    index, clk);
>  }
>
>  int clk_get_by_index_nodev(ofnode node, int index, struct clk *clk)
> @@ -142,10 +142,10 @@ int clk_get_by_index_nodev(ofnode node, int index, struct clk *clk)
>         int ret;
>
>         ret = ofnode_parse_phandle_with_args(node, "clocks", "#clock-cells", 0,
> -                                            index > 0, &args);
> +                                            index, &args);
>
>         return clk_get_by_index_tail(ret, node, &args, "clocks",
> -                                    index > 0, clk);
> +                                    index, clk);
>  }
>
>  int clk_get_bulk(struct udevice *dev, struct clk_bulk *bulk)
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index aa8dd9d027..c082fe95ff 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -121,7 +121,7 @@  static int clk_get_by_indexed_prop(struct udevice *dev, const char *prop_name,
 
 
 	return clk_get_by_index_tail(ret, dev_ofnode(dev), &args, "clocks",
-				     index > 0, clk);
+				     index, clk);
 }
 
 int clk_get_by_index(struct udevice *dev, int index, struct clk *clk)
@@ -133,7 +133,7 @@  int clk_get_by_index(struct udevice *dev, int index, struct clk *clk)
 					 index, &args);
 
 	return clk_get_by_index_tail(ret, dev_ofnode(dev), &args, "clocks",
-				     index > 0, clk);
+				     index, clk);
 }
 
 int clk_get_by_index_nodev(ofnode node, int index, struct clk *clk)
@@ -142,10 +142,10 @@  int clk_get_by_index_nodev(ofnode node, int index, struct clk *clk)
 	int ret;
 
 	ret = ofnode_parse_phandle_with_args(node, "clocks", "#clock-cells", 0,
-					     index > 0, &args);
+					     index, &args);
 
 	return clk_get_by_index_tail(ret, node, &args, "clocks",
-				     index > 0, clk);
+				     index, clk);
 }
 
 int clk_get_bulk(struct udevice *dev, struct clk_bulk *bulk)