Message ID | 20220708104347.13462-1-phil.edworthy@renesas.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2] sh: clk: Extend valid clk ptr checks using IS_ERR_OR_NULL | expand |
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
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
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);
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(-)