From: gmbnomis@gmail.com (Simon Baatz)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] mtd: nand: orion: fix clk handling
Date: Mon, 13 Mar 2017 21:43:44 +0100 [thread overview]
Message-ID: <20170313204344.GA24471@gandalf> (raw)
In-Reply-To: <20170313071241.y5ydl274t22awrys@pengutronix.de>
Hello Uwe,
On Mon, Mar 13, 2017 at 08:12:41AM +0100, Uwe Kleine-K?nig wrote:
> Hello Simon,
>
> On Sun, Mar 12, 2017 at 10:34:06PM +0100, Simon Baatz wrote:
> > The clk handling in orion_nand.c had two problems:
> >
> > - In the probe function, clk_put() was called for an enabled clock,
> > which violates the API (see documentation for clk_put() in
> > include/linux/clk.h)
> >
> > - In the error path of the probe function, clk_put() could be called
> > twice for the same clock.
> >
> > In order to clean this up, use the managed function devm_clk_get() and
> > store the pointer to the clk in the driver data.
...
> > /* Not all platforms can gate the clock, so it is not
> > an error if the clock does not exists. */
> > - clk = clk_get(&pdev->dev, NULL);
> > - if (!IS_ERR(clk)) {
> > - clk_prepare_enable(clk);
> > - clk_put(clk);
> > - }
> > + info->clk = devm_clk_get(&pdev->dev, NULL);
> > + if (!IS_ERR(info->clk))
> > + clk_prepare_enable(info->clk);
>
> Orthogonal to your patch I suggest:
>
> - info->clk = devm_clk_get(&pdev->dev, NULL);
> - if (!IS_ERR(info->clk))
> - clk_prepare_enable(info->clk);
> + info->clk = devm_clk_get_optional(&pdev->dev, NULL);
> + if (IS_ERR(info->clk)) {
> + ret = PTR_ERR(info->clk);
> + if (ret != -EPROBE_DEFER)
> + dev_err(...);
> + return ret;
> + }
>
> to correct error handling.
> (I didn't check if a plain return is right here, and also other users of
> info->clk need adaption.)
Nice! However, I can't find a devm_clk_get_optional() anywhere(?) Is
it in some upcoming patch?
- Simon
next prev parent reply other threads:[~2017-03-13 20:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-12 21:34 [PATCH] mtd: nand: orion: fix clk handling Simon Baatz
2017-03-13 7:12 ` Uwe Kleine-König
2017-03-13 20:43 ` Simon Baatz [this message]
2017-03-13 20:58 ` Uwe Kleine-König
2017-03-16 9:12 ` Boris Brezillon
2017-03-16 21:50 ` Simon Baatz
2017-03-17 6:36 ` Boris Brezillon
2017-03-16 9:05 ` Boris Brezillon
2017-03-16 21:44 ` Simon Baatz
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=20170313204344.GA24471@gandalf \
--to=gmbnomis@gmail.com \
--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).