linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: sunxi: fix mux clk takes register bit mask instead of width
@ 2014-09-06  4:06 Chen-Yu Tsai
  2014-09-06 15:44 ` Chen-Yu Tsai
  0 siblings, 1 reply; 2+ messages in thread
From: Chen-Yu Tsai @ 2014-09-06  4:06 UTC (permalink / raw)
  To: linux-arm-kernel

clk_register_mux takes both register bit shift and mask as parameters
to which bits it should use to control the clock mux.

sunxi_mux_clk_setup incorrectly passed the width of effective bits,
instead of the bit mask. This would result in incorrect values being
read or set.

Fixes: e874a6697710 ("clk: arm: sunxi: Add a new clock driver for sunxi SOCs")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Cc: stable at vger.kernel.org
---

We never ran into this because the mux clks do not have auto-reparenting
enabled, and the only time we did reparent was in the sun6i dma driver.
Luckily the new value is the same as the mask there.

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

diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index b654b7b..df61199 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -674,7 +674,7 @@ static struct clk * __init sunxi_factors_clk_setup(struct device_node *node,
  * sunxi_mux_clk_setup() - Setup function for muxes
  */
 
-#define SUNXI_MUX_GATE_WIDTH	2
+#define SUNXI_MUX_GATE_MASK	0x3
 
 struct mux_data {
 	u8 shift;
@@ -711,7 +711,7 @@ static void __init sunxi_mux_clk_setup(struct device_node *node,
 
 	clk = clk_register_mux(NULL, clk_name, parents, i,
 			       CLK_SET_RATE_NO_REPARENT, reg,
-			       data->shift, SUNXI_MUX_GATE_WIDTH,
+			       data->shift, SUNXI_MUX_GATE_MASK,
 			       0, &clk_lock);
 
 	if (clk) {
-- 
2.1.0

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

* [PATCH] clk: sunxi: fix mux clk takes register bit mask instead of width
  2014-09-06  4:06 [PATCH] clk: sunxi: fix mux clk takes register bit mask instead of width Chen-Yu Tsai
@ 2014-09-06 15:44 ` Chen-Yu Tsai
  0 siblings, 0 replies; 2+ messages in thread
From: Chen-Yu Tsai @ 2014-09-06 15:44 UTC (permalink / raw)
  To: linux-arm-kernel

Self NACK this one.

I misread the definition, and extrapolated from the init data.
The original code is correct. Sorry about the noise.

On Sat, Sep 6, 2014 at 12:06 PM, Chen-Yu Tsai <wens@csie.org> wrote:
> clk_register_mux takes both register bit shift and mask as parameters
> to which bits it should use to control the clock mux.
>
> sunxi_mux_clk_setup incorrectly passed the width of effective bits,
> instead of the bit mask. This would result in incorrect values being
> read or set.
>
> Fixes: e874a6697710 ("clk: arm: sunxi: Add a new clock driver for sunxi SOCs")
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> Cc: stable at vger.kernel.org
> ---
>
> We never ran into this because the mux clks do not have auto-reparenting
> enabled, and the only time we did reparent was in the sun6i dma driver.
> Luckily the new value is the same as the mask there.
>
> ---
>  drivers/clk/sunxi/clk-sunxi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
> index b654b7b..df61199 100644
> --- a/drivers/clk/sunxi/clk-sunxi.c
> +++ b/drivers/clk/sunxi/clk-sunxi.c
> @@ -674,7 +674,7 @@ static struct clk * __init sunxi_factors_clk_setup(struct device_node *node,
>   * sunxi_mux_clk_setup() - Setup function for muxes
>   */
>
> -#define SUNXI_MUX_GATE_WIDTH   2
> +#define SUNXI_MUX_GATE_MASK    0x3
>
>  struct mux_data {
>         u8 shift;
> @@ -711,7 +711,7 @@ static void __init sunxi_mux_clk_setup(struct device_node *node,
>
>         clk = clk_register_mux(NULL, clk_name, parents, i,
>                                CLK_SET_RATE_NO_REPARENT, reg,
> -                              data->shift, SUNXI_MUX_GATE_WIDTH,
> +                              data->shift, SUNXI_MUX_GATE_MASK,
>                                0, &clk_lock);
>
>         if (clk) {
> --
> 2.1.0
>

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

end of thread, other threads:[~2014-09-06 15:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-06  4:06 [PATCH] clk: sunxi: fix mux clk takes register bit mask instead of width Chen-Yu Tsai
2014-09-06 15:44 ` Chen-Yu Tsai

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