diff mbox

[v4,01/11] clk: sunxi: Add display and TCON0 clocks driver

Message ID 20160509223924.GX3492@codeaurora.org (mailing list archive)
State New, archived
Headers show

Commit Message

Stephen Boyd May 9, 2016, 10:39 p.m. UTC
On 05/09, Stephen Boyd wrote:
> 
> Ok I applied this one to clk-next.
> 

And I squashed this in to silence the following checker warning.

drivers/clk/sunxi/clk-sun4i-display.c:110:33: warning: Variable
length array is used.

---8<---

Comments

Maxime Ripard May 10, 2016, 6:36 a.m. UTC | #1
Hi Stephen,

On Mon, May 09, 2016 at 03:39:24PM -0700, Stephen Boyd wrote:
> On 05/09, Stephen Boyd wrote:
> > 
> > Ok I applied this one to clk-next.
> > 
> 
> And I squashed this in to silence the following checker warning.
> 
> drivers/clk/sunxi/clk-sun4i-display.c:110:33: warning: Variable
> length array is used.

Thanks, just out of curiosity, which checker are you talking about?
sparse?

Maxime
Priit Laes May 10, 2016, 7:10 p.m. UTC | #2
On Mon, 2016-05-09 at 15:39 -0700, Stephen Boyd wrote:
> On 05/09, Stephen Boyd wrote:
> > 
> > 
> > Ok I applied this one to clk-next.
> > 
> And I squashed this in to silence the following checker warning.
> 
> drivers/clk/sunxi/clk-sun4i-display.c:110:33: warning: Variable
> length array is used.
> 
> ---8<---
> diff --git a/drivers/clk/sunxi/clk-sun4i-display.c
> b/drivers/clk/sunxi/clk-sun4i-display.c
> index f02e250e64ed..f8ff6c4a5633 100644
> --- a/drivers/clk/sunxi/clk-sun4i-display.c
> +++ b/drivers/clk/sunxi/clk-sun4i-display.c
> @@ -107,7 +107,7 @@ static int sun4i_a10_display_reset_xlate(struct
> reset_controller_dev *rcdev,
>  static void __init sun4i_a10_display_init(struct device_node *node,
>  					  const struct
> sun4i_a10_display_clk_data *data)
>  {
> -	const char *parents[data->parents];
> +	const char *parents[4];
>  	const char *clk_name = node->name;
>  	struct reset_data *reset_data;
>  	struct clk_divider *div = NULL;
> @@ -126,8 +126,8 @@ static void __init sun4i_a10_display_init(struct
> device_node *node,
>  		return;
>  	}
>  
> -	ret = of_clk_parent_fill(node, parents, data->parents);
> -	if (ret != data->parents) {
> +	ret = of_clk_parent_fill(node, parents,
> ARRAY_SIZE(parents));
> +	if (ret != ARRAY_SIZE(parents)) {
>  		pr_err("%s: Could not retrieve the parents\n",
> clk_name);
>  		goto unmap;
>  	}

This change breaks at least de_[bf]e clocks which have 3 clock parents.
Stephen Boyd May 11, 2016, 10:13 p.m. UTC | #3
On 05/10, Maxime Ripard wrote:
> Hi Stephen,
> 
> On Mon, May 09, 2016 at 03:39:24PM -0700, Stephen Boyd wrote:
> > On 05/09, Stephen Boyd wrote:
> > > 
> > > Ok I applied this one to clk-next.
> > > 
> > 
> > And I squashed this in to silence the following checker warning.
> > 
> > drivers/clk/sunxi/clk-sun4i-display.c:110:33: warning: Variable
> > length array is used.
> 
> Thanks, just out of curiosity, which checker are you talking about?
> sparse?
> 

I use sparse and smatch. I can't recall which one is complaining
here and technically smatch uses sparse underneath.
Stephen Boyd May 11, 2016, 10:15 p.m. UTC | #4
On 05/10, Priit Laes wrote:
> On Mon, 2016-05-09 at 15:39 -0700, Stephen Boyd wrote:
> > On 05/09, Stephen Boyd wrote:
> > > 
> > > 
> > > Ok I applied this one to clk-next.
> > > 
> > And I squashed this in to silence the following checker warning.
> > 
> > drivers/clk/sunxi/clk-sun4i-display.c:110:33: warning: Variable
> > length array is used.
> > 
> > ---8<---
> > diff --git a/drivers/clk/sunxi/clk-sun4i-display.c
> > b/drivers/clk/sunxi/clk-sun4i-display.c
> > index f02e250e64ed..f8ff6c4a5633 100644
> > --- a/drivers/clk/sunxi/clk-sun4i-display.c
> > +++ b/drivers/clk/sunxi/clk-sun4i-display.c
> > @@ -107,7 +107,7 @@ static int sun4i_a10_display_reset_xlate(struct
> > reset_controller_dev *rcdev,
> >  static void __init sun4i_a10_display_init(struct device_node *node,
> >  					  const struct
> > sun4i_a10_display_clk_data *data)
> >  {
> > -	const char *parents[data->parents];
> > +	const char *parents[4];
> 
> This change breaks at least de_[bf]e clocks which have 3 clock parents.
> 

I just used the largest data->parents number, which was 4. How
does that break anything?
Priit Laes May 12, 2016, 3:39 a.m. UTC | #5
On Wed, 2016-05-11 at 15:15 -0700, Stephen Boyd wrote:
> On 05/10, Priit Laes wrote:
> > 
> > On Mon, 2016-05-09 at 15:39 -0700, Stephen Boyd wrote:
> > > 
> > > On 05/09, Stephen Boyd wrote:
> > > > 
> > > > 
> > > > 
> > > > Ok I applied this one to clk-next.
> > > > 
> > > And I squashed this in to silence the following checker warning.
> > > 
> > > drivers/clk/sunxi/clk-sun4i-display.c:110:33: warning: Variable
> > > length array is used.
> > > 
> > > ---8<---
> > > diff --git a/drivers/clk/sunxi/clk-sun4i-display.c
> > > b/drivers/clk/sunxi/clk-sun4i-display.c
> > > index f02e250e64ed..f8ff6c4a5633 100644
> > > --- a/drivers/clk/sunxi/clk-sun4i-display.c
> > > +++ b/drivers/clk/sunxi/clk-sun4i-display.c
> > > @@ -107,7 +107,7 @@ static int
> > > sun4i_a10_display_reset_xlate(struct
> > > reset_controller_dev *rcdev,
> > >  static void __init sun4i_a10_display_init(struct device_node
> > > *node,
> > >  					  const struct
> > > sun4i_a10_display_clk_data *data)
> > >  {
> > > -	const char *parents[data->parents];
> > > +	const char *parents[4];
> > This change breaks at least de_[bf]e clocks which have 3 clock
> > parents.

> I just used the largest data->parents number, which was 4. How
> does that break anything?

If you look at the sun4i_a10_display_init, it contains this block:

    ret = of_clk_parent_fill(node, parents, ARRAY_SIZE(parents));
    if (ret != ARRAY_SIZE(parents)) {
        pr_err("%s: Could not retrieve the parents\n", clk_name);
        goto unmap;
    }

of_clk_parent_fill returns 3 for de_be/de_fe nodes, and
ARRAY_SIZE(parents) is 4.

Päikest,
Priit :)
Maxime Ripard May 12, 2016, 6:59 a.m. UTC | #6
On Thu, May 12, 2016 at 06:39:20AM +0300, Priit Laes wrote:
> On Wed, 2016-05-11 at 15:15 -0700, Stephen Boyd wrote:
> > On 05/10, Priit Laes wrote:
> > > 
> > > On Mon, 2016-05-09 at 15:39 -0700, Stephen Boyd wrote:
> > > > 
> > > > On 05/09, Stephen Boyd wrote:
> > > > > 
> > > > > 
> > > > > 
> > > > > Ok I applied this one to clk-next.
> > > > > 
> > > > And I squashed this in to silence the following checker warning.
> > > > 
> > > > drivers/clk/sunxi/clk-sun4i-display.c:110:33: warning: Variable
> > > > length array is used.
> > > > 
> > > > ---8<---
> > > > diff --git a/drivers/clk/sunxi/clk-sun4i-display.c
> > > > b/drivers/clk/sunxi/clk-sun4i-display.c
> > > > index f02e250e64ed..f8ff6c4a5633 100644
> > > > --- a/drivers/clk/sunxi/clk-sun4i-display.c
> > > > +++ b/drivers/clk/sunxi/clk-sun4i-display.c
> > > > @@ -107,7 +107,7 @@ static int
> > > > sun4i_a10_display_reset_xlate(struct
> > > > reset_controller_dev *rcdev,
> > > >  static void __init sun4i_a10_display_init(struct device_node
> > > > *node,
> > > >  					  const struct
> > > > sun4i_a10_display_clk_data *data)
> > > >  {
> > > > -	const char *parents[data->parents];
> > > > +	const char *parents[4];
> > > This change breaks at least de_[bf]e clocks which have 3 clock
> > > parents.
> 
> > I just used the largest data->parents number, which was 4. How
> > does that break anything?
> 
> If you look at the sun4i_a10_display_init, it contains this block:
> 
>     ret = of_clk_parent_fill(node, parents, ARRAY_SIZE(parents));
>     if (ret != ARRAY_SIZE(parents)) {
>         pr_err("%s: Could not retrieve the parents\n", clk_name);
>         goto unmap;
>     }
> 
> of_clk_parent_fill returns 3 for de_be/de_fe nodes, and
> ARRAY_SIZE(parents) is 4.

Replacing both ARRAY_SIZE(parents) by data->parents would work though.

Maxime
diff mbox

Patch

diff --git a/drivers/clk/sunxi/clk-sun4i-display.c b/drivers/clk/sunxi/clk-sun4i-display.c
index f02e250e64ed..f8ff6c4a5633 100644
--- a/drivers/clk/sunxi/clk-sun4i-display.c
+++ b/drivers/clk/sunxi/clk-sun4i-display.c
@@ -107,7 +107,7 @@  static int sun4i_a10_display_reset_xlate(struct reset_controller_dev *rcdev,
 static void __init sun4i_a10_display_init(struct device_node *node,
 					  const struct sun4i_a10_display_clk_data *data)
 {
-	const char *parents[data->parents];
+	const char *parents[4];
 	const char *clk_name = node->name;
 	struct reset_data *reset_data;
 	struct clk_divider *div = NULL;
@@ -126,8 +126,8 @@  static void __init sun4i_a10_display_init(struct device_node *node,
 		return;
 	}
 
-	ret = of_clk_parent_fill(node, parents, data->parents);
-	if (ret != data->parents) {
+	ret = of_clk_parent_fill(node, parents, ARRAY_SIZE(parents));
+	if (ret != ARRAY_SIZE(parents)) {
 		pr_err("%s: Could not retrieve the parents\n", clk_name);
 		goto unmap;
 	}