linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/2] ASoC: kirkwood: clk: probe defer when clock not yet ready
Date: Sat, 21 Sep 2013 11:12:21 +0100	[thread overview]
Message-ID: <20130921101221.GH12758@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20130921120006.47b00fe7@armhf>

On Sat, Sep 21, 2013 at 12:00:06PM +0200, Jean-Francois Moine wrote:
> diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
> index 442a313..f8b28d9 100644
> --- a/drivers/clk/clkdev.c
> +++ b/drivers/clk/clkdev.c
> @@ -157,8 +157,13 @@ struct clk *clk_get(struct device *dev, const char *con_id)
>  
>  	if (dev) {
>  		clk = of_clk_get_by_name(dev->of_node, con_id);
> -		if (!IS_ERR(clk) && __clk_get(clk))
> -			return clk;
> +		if (!IS_ERR(clk)) {
> +			if (__clk_get(clk))
> +				return clk;
> +		} else {
> +			if (PTR_ERR(clk) == -EPROBE_DEFER)
> +				return clk;
> +		}

Thanks for patching this file and bringing this code to my attention.
The original is fscked.  Calling __clk_get() outside of any lock is
a serious bug and leads to races.

Also, a failing __clk_get() probably should not drop through to
clk_get_sys(), but should instead do this:

		if (!IS_ERR(clk)) {
			if (!__clk_get(clk))
				clk = ERR_PTR(-ENOENT);
			return clk;
		}

since a _found_ clock but one which can't be used (due to the module
going away) is not a reason to drop through to clk_get_sys().

Which means your change should look like this:

		if (!IS_ERR(clk)) {
			if (!__clk_get(clk))
				clk = ERR_PTR(-ENOENT);
			return clk;
		}
		if (PTR_ERR(clk) == -EPROBE_DEFER)
			return clk;

  reply	other threads:[~2013-09-21 10:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-21 10:00 [PATCH v2 1/2] ASoC: kirkwood: clk: probe defer when clock not yet ready Jean-Francois Moine
2013-09-21 10:12 ` Russell King - ARM Linux [this message]
2013-09-21 10:47 ` Russell King - ARM Linux
2013-09-21 10:51   ` Russell King - ARM Linux
2013-09-21 17:06   ` Jean-Francois Moine

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=20130921101221.GH12758@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 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).