All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
To: Geert Uytterhoeven <geert+renesas@glider.be>,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	Rich Felker <dalias@libc.org>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>
Cc: linux-sh@vger.kernel.org, linux-clk@vger.kernel.org
Subject: Re: [PATCH] sh: clk: Fix clk_enable() to return 0 on NULL clk
Date: Thu, 02 Feb 2023 17:28:09 +0100	[thread overview]
Message-ID: <0565e1b146995f9f8339bb81ac23218dba371133.camel@physik.fu-berlin.de> (raw)
In-Reply-To: <b53e6b557b4240579933b3359dda335ff94ed5af.1675354849.git.geert+renesas@glider.be>

Hi Geert!

On Thu, 2023-02-02 at 17:20 +0100, Geert Uytterhoeven wrote:
> On SH, devm_clk_get_optional_enabled() fails with -EINVAL if the clock
> is not found.  This happens because __devm_clk_get() assumes it can pass
> a NULL clock pointer (as returned by clk_get_optional()) to the init()
> function (clk_prepare_enable() in this case), while the SH
> implementation of clk_enable() considers that an error.
> 
> Fix this by making the SH clk_enable() implementation return zero
> instead, like the Common Clock Framework does.
> 
> Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Exposed by commit 599566c1c3692052 ("r8169: use
> devm_clk_get_optional_enabled() to simplify the code"), cfr.
> https://lore.kernel.org/all/585c4b48790d71ca43b66fc24ea8d84917c4a0e1.camel@physik.fu-berlin.de
> 
> Boot-tested on qemu/rts7751r2d, which did not show the problem though.
> ---
>  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 d996782a710642cd..7a73f5e4a1fc70cc 100644
> --- a/drivers/sh/clk/core.c
> +++ b/drivers/sh/clk/core.c
> @@ -295,7 +295,7 @@ int clk_enable(struct clk *clk)
>  	int ret;
>  
>  	if (!clk)
> -		return -EINVAL;
> +		return 0;
>  
>  	spin_lock_irqsave(&clock_lock, flags);
>  	ret = __clk_enable(clk);

I can confirm that this patch makes the r8169 driver work again!

Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

  reply	other threads:[~2023-02-02 16:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 16:20 [PATCH] sh: clk: Fix clk_enable() to return 0 on NULL clk Geert Uytterhoeven
2023-02-02 16:28 ` John Paul Adrian Glaubitz [this message]
2023-02-02 23:17 ` Stephen Boyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0565e1b146995f9f8339bb81ac23218dba371133.camel@physik.fu-berlin.de \
    --to=glaubitz@physik.fu-berlin.de \
    --cc=dalias@libc.org \
    --cc=geert+renesas@glider.be \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    --cc=ysato@users.sourceforge.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.