diff mbox series

[v0,04/42] clk: renesas: Check notifier registration return value

Message ID 20211108101157.15189-5-bp@alien8.de (mailing list archive)
State Changes Requested, archived
Headers show
Series None | expand

Commit Message

Borislav Petkov Nov. 8, 2021, 10:11 a.m. UTC
From: Borislav Petkov <bp@suse.de>

Avoid homegrown notifier registration checks.

No functional changes.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: linux-renesas-soc@vger.kernel.org
Cc: linux-clk@vger.kernel.org
---
 drivers/clk/renesas/clk-div6.c     | 4 +++-
 drivers/clk/renesas/rcar-cpg-lib.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

Comments

Geert Uytterhoeven Nov. 8, 2021, 2:12 p.m. UTC | #1
Hi Borislav,

Thanks for your patch!

On Mon, Nov 8, 2021 at 1:49 PM Borislav Petkov <bp@alien8.de> wrote:
> From: Borislav Petkov <bp@suse.de>
>
> Avoid homegrown notifier registration checks.

Which homegrown notifier registration check is avoided?
IIANM, you're adding a homegrown notifier registration check?

> No functional changes.
>
> Signed-off-by: Borislav Petkov <bp@suse.de>

> --- a/drivers/clk/renesas/clk-div6.c
> +++ b/drivers/clk/renesas/clk-div6.c
> @@ -306,7 +306,9 @@ struct clk * __init cpg_div6_register(const char *name,
>
>         if (notifiers) {
>                 clock->nb.notifier_call = cpg_div6_clock_notifier_call;
> -               raw_notifier_chain_register(notifiers, &clock->nb);
> +
> +               if (raw_notifier_chain_register(notifiers, &clock->nb))
> +                       pr_warn("CPG DIV6 clock notifier already registered\n");

A duplicate registration cannot happen, as the notifier is freshly allocated.

>         }
>
>         return clk;
> diff --git a/drivers/clk/renesas/rcar-cpg-lib.c b/drivers/clk/renesas/rcar-cpg-lib.c
> index e93f0011eb07..fbbb6f4a8148 100644
> --- a/drivers/clk/renesas/rcar-cpg-lib.c
> +++ b/drivers/clk/renesas/rcar-cpg-lib.c
> @@ -59,7 +59,9 @@ void cpg_simple_notifier_register(struct raw_notifier_head *notifiers,
>                                   struct cpg_simple_notifier *csn)
>  {
>         csn->nb.notifier_call = cpg_simple_notifier_call;
> -       raw_notifier_chain_register(notifiers, &csn->nb);
> +
> +       if (raw_notifier_chain_register(notifiers, &csn->nb))
> +               pr_warn("CPG notifier already registered\n");

A duplicate registration cannot happen, as the notifier is freshly allocated.

>  }
>

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
diff mbox series

Patch

diff --git a/drivers/clk/renesas/clk-div6.c b/drivers/clk/renesas/clk-div6.c
index 3abd6e5400ad..7d89ca01889a 100644
--- a/drivers/clk/renesas/clk-div6.c
+++ b/drivers/clk/renesas/clk-div6.c
@@ -306,7 +306,9 @@  struct clk * __init cpg_div6_register(const char *name,
 
 	if (notifiers) {
 		clock->nb.notifier_call = cpg_div6_clock_notifier_call;
-		raw_notifier_chain_register(notifiers, &clock->nb);
+
+		if (raw_notifier_chain_register(notifiers, &clock->nb))
+			pr_warn("CPG DIV6 clock notifier already registered\n");
 	}
 
 	return clk;
diff --git a/drivers/clk/renesas/rcar-cpg-lib.c b/drivers/clk/renesas/rcar-cpg-lib.c
index e93f0011eb07..fbbb6f4a8148 100644
--- a/drivers/clk/renesas/rcar-cpg-lib.c
+++ b/drivers/clk/renesas/rcar-cpg-lib.c
@@ -59,7 +59,9 @@  void cpg_simple_notifier_register(struct raw_notifier_head *notifiers,
 				  struct cpg_simple_notifier *csn)
 {
 	csn->nb.notifier_call = cpg_simple_notifier_call;
-	raw_notifier_chain_register(notifiers, &csn->nb);
+
+	if (raw_notifier_chain_register(notifiers, &csn->nb))
+		pr_warn("CPG notifier already registered\n");
 }
 
 /*