From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Daniel Mack <daniel@zonque.org>
Cc: miquel.raynal@bootlin.com, robert.jarzmik@free.fr,
dwmw2@infradead.org, linux-mtd@lists.infradead.org
Subject: Re: [PATCH v2 3/3] mtd: rawnand: marvell: set reg_clk to NULL if it can't be obtained
Date: Sat, 7 Jul 2018 08:36:55 +0200 [thread overview]
Message-ID: <20180707083655.2aa7aff6@bbrezillon> (raw)
In-Reply-To: <20180707062852.26261-3-daniel@zonque.org>
On Sat, 7 Jul 2018 08:28:52 +0200
Daniel Mack <daniel@zonque.org> wrote:
> Don't keep an error-pointer around in the private struct. If this optional
> clock can't be obtained, simply set the pointer to NULL instead so we can
> use clk_prepare_enable() on it without further checks,
>
> Signed-off-by: Daniel Mack <daniel@zonque.org>
> ---
> drivers/mtd/nand/raw/marvell_nand.c | 24 +++++++++++++-----------
> 1 file changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
> index e72070fe8af9..9246c3ea6ebc 100644
> --- a/drivers/mtd/nand/raw/marvell_nand.c
> +++ b/drivers/mtd/nand/raw/marvell_nand.c
> @@ -2752,15 +2752,19 @@ static int marvell_nfc_probe(struct platform_device *pdev)
> return ret;
>
> nfc->reg_clk = devm_clk_get(&pdev->dev, "reg");
> - if (PTR_ERR(nfc->reg_clk) != -ENOENT) {
> - if (!IS_ERR(nfc->reg_clk)) {
> - ret = clk_prepare_enable(nfc->reg_clk);
> - if (ret)
> - goto unprepare_core_clk;
> - } else {
> + if (IS_ERR(nfc->reg_clk)) {
> + if (PTR_ERR(nfc->reg_clk) != -ENOENT) {
> ret = PTR_ERR(nfc->reg_clk);
> goto unprepare_core_clk;
> }
> +
> + nfc->reg_clk = NULL;
> + }
> +
> + if (nfc->reg_clk) {
> + ret = clk_prepare_enable(nfc->reg_clk);
> + if (ret)
> + goto unprepare_core_clk;
No need to check nfc->reg_clk value here:
ret = clk_prepare_enable(nfc->reg_clk);
if (ret)
goto unprepare_core_clk;
> }
>
> marvell_nfc_disable_int(nfc, NDCR_ALL_INT);
> @@ -2843,11 +2847,9 @@ static int __maybe_unused marvell_nfc_resume(struct device *dev)
> if (ret < 0)
> return ret;
>
> - if (!IS_ERR(nfc->reg_clk)) {
> - ret = clk_prepare_enable(nfc->reg_clk);
> - if (ret < 0)
> - return ret;
> - }
> + ret = clk_prepare_enable(nfc->reg_clk);
> + if (ret < 0)
> + return ret;
>
> /*
> * Reset nfc->selected_chip so the next command will cause the timing
next prev parent reply other threads:[~2018-07-07 6:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-07 6:28 [PATCH v2 1/3] mtd: rawnand: marvell: add suspend and resume hooks Daniel Mack
2018-07-07 6:28 ` [PATCH v2 2/3] mtd: rawnand: marvell: remove bogus comment in marvell_nfc_select_chip() Daniel Mack
2018-07-07 6:28 ` [PATCH v2 3/3] mtd: rawnand: marvell: set reg_clk to NULL if it can't be obtained Daniel Mack
2018-07-07 6:36 ` Boris Brezillon [this message]
2018-07-07 6:45 ` Daniel Mack
2018-07-07 6:30 ` [PATCH v2 1/3] mtd: rawnand: marvell: add suspend and resume hooks Daniel Mack
2018-07-07 6:32 ` Boris Brezillon
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=20180707083655.2aa7aff6@bbrezillon \
--to=boris.brezillon@bootlin.com \
--cc=daniel@zonque.org \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=robert.jarzmik@free.fr \
/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.