diff mbox

clk: shmobile: r8a7779: check return of of_property_read_string_index()

Message ID 87pp7o2xqg.wl%kuninori.morimoto.gx@renesas.com (mailing list archive)
State Rejected
Delegated to: Geert Uytterhoeven
Headers show

Commit Message

Kuninori Morimoto April 1, 2015, 6:02 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

This patch indicates error message if return value of
of_property_read_string_index() was not zero.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/clk/shmobile/clk-r8a7779.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Geert Uytterhoeven April 1, 2015, 8:48 a.m. UTC | #1
Hi Morimoto-san,

On Wed, Apr 1, 2015 at 8:02 AM, Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>
> This patch indicates error message if return value of
> of_property_read_string_index() was not zero.
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  drivers/clk/shmobile/clk-r8a7779.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/shmobile/clk-r8a7779.c b/drivers/clk/shmobile/clk-r8a7779.c
> index 652ecac..af439b2 100644
> --- a/drivers/clk/shmobile/clk-r8a7779.c
> +++ b/drivers/clk/shmobile/clk-r8a7779.c
> @@ -155,8 +155,10 @@ static void __init r8a7779_cpg_clocks_init(struct device_node *np)
>                 const char *name;
>                 struct clk *clk;
>
> -               of_property_read_string_index(np, "clock-output-names", i,
> -                                             &name);
> +               if (of_property_read_string_index(np, "clock-output-names", i,
> +                                                 &name))
> +                       pr_err("%s: can't get clock-output-names (%d)\n",
> +                              __func__, i);

Shouldn't you add a "continue;" here, too?

Anyway, I don't think this can fail, as
i < of_property_count_strings(np, "clock-output-names");

>                 clk = r8a7779_cpg_register_clock(np, cpg, config,
>                                                  plla_mult, name);

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Kuninori Morimoto April 2, 2015, 12:12 a.m. UTC | #2
Hi Geert

> > diff --git a/drivers/clk/shmobile/clk-r8a7779.c b/drivers/clk/shmobile/clk-r8a7779.c
> > index 652ecac..af439b2 100644
> > --- a/drivers/clk/shmobile/clk-r8a7779.c
> > +++ b/drivers/clk/shmobile/clk-r8a7779.c
> > @@ -155,8 +155,10 @@ static void __init r8a7779_cpg_clocks_init(struct device_node *np)
> >                 const char *name;
> >                 struct clk *clk;
> >
> > -               of_property_read_string_index(np, "clock-output-names", i,
> > -                                             &name);
> > +               if (of_property_read_string_index(np, "clock-output-names", i,
> > +                                                 &name))
> > +                       pr_err("%s: can't get clock-output-names (%d)\n",
> > +                              __func__, i);
> 
> Shouldn't you add a "continue;" here, too?
> 
> Anyway, I don't think this can fail, as
> i < of_property_count_strings(np, "clock-output-names");

Hmm.. indeed.
Thank you for your review, please drop this patch.

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/clk/shmobile/clk-r8a7779.c b/drivers/clk/shmobile/clk-r8a7779.c
index 652ecac..af439b2 100644
--- a/drivers/clk/shmobile/clk-r8a7779.c
+++ b/drivers/clk/shmobile/clk-r8a7779.c
@@ -155,8 +155,10 @@  static void __init r8a7779_cpg_clocks_init(struct device_node *np)
 		const char *name;
 		struct clk *clk;
 
-		of_property_read_string_index(np, "clock-output-names", i,
-					      &name);
+		if (of_property_read_string_index(np, "clock-output-names", i,
+						  &name))
+			pr_err("%s: can't get clock-output-names (%d)\n",
+			       __func__, i);
 
 		clk = r8a7779_cpg_register_clock(np, cpg, config,
 						 plla_mult, name);