linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] sh: clk: Extend valid clk ptr checks using IS_ERR_OR_NULL
@ 2022-07-08 10:43 Phil Edworthy
  2022-07-08 11:10 ` Geert Uytterhoeven
  2022-07-11  4:05 ` Rob Landley
  0 siblings, 2 replies; 3+ messages in thread
From: Phil Edworthy @ 2022-07-08 10:43 UTC (permalink / raw)
  To: Yoshinori Sato, Rich Felker; +Cc: Phil Edworthy, linux-sh, Geert Uytterhoeven

We want to allow all drivers to call clk_disable_unprepare() with a
clock pointer that could be a valid IS_ERR() condition containing
errno, as this will simplify driver code.

Therefore, ensure we check not only that the clock pointer is not
NULL, but also is not an error value before using it.

Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
---
Note this has not been tested at all, I don't have any SH boards.

v2:
 - Only use IS_ERR_OR_NULL in clk_disable() as nobody should be
   calling the other functions with a clk ptr that is an error.
 - Improved commit msg to clarify the above
---
 drivers/sh/clk/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c
index d996782a7106..878812583940 100644
--- a/drivers/sh/clk/core.c
+++ b/drivers/sh/clk/core.c
@@ -253,7 +253,7 @@ void clk_disable(struct clk *clk)
 {
 	unsigned long flags;
 
-	if (!clk)
+	if (IS_ERR_OR_NULL(clk))
 		return;
 
 	spin_lock_irqsave(&clock_lock, flags);
-- 
2.34.1


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

* Re: [PATCH v2] sh: clk: Extend valid clk ptr checks using IS_ERR_OR_NULL
  2022-07-08 10:43 [PATCH v2] sh: clk: Extend valid clk ptr checks using IS_ERR_OR_NULL Phil Edworthy
@ 2022-07-08 11:10 ` Geert Uytterhoeven
  2022-07-11  4:05 ` Rob Landley
  1 sibling, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2022-07-08 11:10 UTC (permalink / raw)
  To: Phil Edworthy
  Cc: Yoshinori Sato, Rich Felker, Linux-sh list, Geert Uytterhoeven

On Fri, Jul 8, 2022 at 12:43 PM Phil Edworthy <phil.edworthy@renesas.com> wrote:
> We want to allow all drivers to call clk_disable_unprepare() with a
> clock pointer that could be a valid IS_ERR() condition containing
> errno, as this will simplify driver code.
>
> Therefore, ensure we check not only that the clock pointer is not
> NULL, but also is not an error value before using it.
>
> Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
> ---
> Note this has not been tested at all, I don't have any SH boards.
>
> v2:
>  - Only use IS_ERR_OR_NULL in clk_disable() as nobody should be
>    calling the other functions with a clk ptr that is an error.
>  - Improved commit msg to clarify the above

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

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

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

* Re: [PATCH v2] sh: clk: Extend valid clk ptr checks using IS_ERR_OR_NULL
  2022-07-08 10:43 [PATCH v2] sh: clk: Extend valid clk ptr checks using IS_ERR_OR_NULL Phil Edworthy
  2022-07-08 11:10 ` Geert Uytterhoeven
@ 2022-07-11  4:05 ` Rob Landley
  1 sibling, 0 replies; 3+ messages in thread
From: Rob Landley @ 2022-07-11  4:05 UTC (permalink / raw)
  To: Phil Edworthy, Yoshinori Sato, Rich Felker; +Cc: linux-sh, Geert Uytterhoeven

On 7/8/22 05:43, Phil Edworthy wrote:
> We want to allow all drivers to call clk_disable_unprepare() with a
> clock pointer that could be a valid IS_ERR() condition containing
> errno, as this will simplify driver code.
> 
> Therefore, ensure we check not only that the clock pointer is not
> NULL, but also is not an error value before using it.
> 
> Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
> ---
> Note this has not been tested at all, I don't have any SH boards.

Tested-by: Rob Landley <rob@landley.net>

Rob

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

end of thread, other threads:[~2022-07-11  3:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-08 10:43 [PATCH v2] sh: clk: Extend valid clk ptr checks using IS_ERR_OR_NULL Phil Edworthy
2022-07-08 11:10 ` Geert Uytterhoeven
2022-07-11  4:05 ` Rob Landley

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