From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Richard Weinberger <richard@nod.at>,
David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>,
Marek Vasut <marek.vasut@gmail.com>,
Sylvain Lemieux <slemieux.tyco@gmail.com>,
linux-mtd@lists.infradead.org, Vladimir Zapolskiy <vz@mleia.com>
Subject: Re: [PATCH v3 10/11] mtd: rawnand: lpc32xx_slc: clean the probe function
Date: Thu, 26 Apr 2018 19:26:48 +0200 [thread overview]
Message-ID: <20180426192648.4df1ad55@bbrezillon> (raw)
In-Reply-To: <20180421180043.18366-11-miquel.raynal@bootlin.com>
On Sat, 21 Apr 2018 20:00:42 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> Before fixing the error path of the probe function, fix the style of the
> entire function and particularly the goto labels: they should indicate
> what the next cleanup to do is.
>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
> drivers/mtd/nand/raw/lpc32xx_slc.c | 26 ++++++++++++++------------
> 1 file changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/lpc32xx_slc.c b/drivers/mtd/nand/raw/lpc32xx_slc.c
> index 5f7cc6da0a7f..342f666ad435 100644
> --- a/drivers/mtd/nand/raw/lpc32xx_slc.c
> +++ b/drivers/mtd/nand/raw/lpc32xx_slc.c
> @@ -831,11 +831,11 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
> if (IS_ERR(host->clk)) {
> dev_err(&pdev->dev, "Clock failure\n");
> res = -ENOENT;
> - goto err_exit1;
> + goto release_gpio;
> }
> res = clk_prepare_enable(host->clk);
> if (res)
> - goto err_exit1;
> + goto release_gpio;
>
> /* Set NAND IO addresses and command/ready functions */
> chip->IO_ADDR_R = SLC_DATA(host->io_base);
> @@ -874,19 +874,19 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
> GFP_KERNEL);
> if (host->data_buf == NULL) {
> res = -ENOMEM;
> - goto err_exit2;
> + goto release_clk;
> }
>
> res = lpc32xx_nand_dma_setup(host);
> if (res) {
> res = -EIO;
> - goto err_exit2;
> + goto release_clk;
> }
>
> /* Find NAND device */
> res = nand_scan_ident(mtd, 1, NULL);
> if (res)
> - goto err_exit3;
> + goto release_dma;
>
> /* OOB and ECC CPU and DMA work areas */
> host->ecc_buf = (uint32_t *)(host->data_buf + LPC32XX_DMA_DATA_SIZE);
> @@ -920,21 +920,23 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
> */
> res = nand_scan_tail(mtd);
> if (res)
> - goto err_exit3;
> + goto release_dma;
>
> mtd->name = "nxp_lpc3220_slc";
> res = mtd_device_register(mtd, host->ncfg->parts,
> host->ncfg->num_parts);
> - if (!res)
> - return res;
> + if (res)
> + goto release_nand;
>
> + return 0;
> +
> +release_nand:
> nand_release(mtd);
> -
> -err_exit3:
> +release_dma:
> dma_release_channel(host->dma_chan);
> -err_exit2:
> +release_clk:
You mean unprepare_clk.
> clk_disable_unprepare(host->clk);
> -err_exit1:
> +release_gpio:
And I'd go for enable_wp here since it's not releasing the gpio at all.
No need to resend, I'll fix it when applying
> lpc32xx_wp_enable(host);
>
> return res;
next prev parent reply other threads:[~2018-04-26 17:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-21 18:00 [PATCH v3 00/11] Fix NAND controllers probe functions error path Miquel Raynal
2018-04-21 18:00 ` [PATCH v3 01/11] mtd: rawnand: docg4: fix the probe function " Miquel Raynal
2018-07-04 10:07 ` Miquel Raynal
2018-04-21 18:00 ` [PATCH v3 02/11] mtd: rawnand: fsl_elbc: fix " Miquel Raynal
2018-04-21 18:00 ` [PATCH v3 03/11] mtd: rawnand: fsl_ifc: " Miquel Raynal
2018-04-21 18:00 ` [PATCH v3 04/11] mtd: rawnand: fsmc: clean the probe function style Miquel Raynal
2018-04-21 18:00 ` [PATCH v3 05/11] mtd: rawnand: fsmc: fix the probe function error path Miquel Raynal
2018-04-21 18:00 ` [PATCH v3 06/11] mtd: rawnand: hisi504: clean " Miquel Raynal
2018-04-21 18:00 ` [PATCH v3 07/11] mtd: rawnand: hisi504: fix " Miquel Raynal
2018-04-21 18:00 ` [PATCH v3 08/11] mtd: rawnand: lpc32xx_mlc: clean the probe function Miquel Raynal
2018-04-21 18:00 ` [PATCH v3 09/11] mtd: rawnand: lpc32xx_mlc: fix the probe function error path Miquel Raynal
2018-04-21 18:00 ` [PATCH v3 10/11] mtd: rawnand: lpc32xx_slc: clean the probe function Miquel Raynal
2018-04-26 17:26 ` Boris Brezillon [this message]
2018-04-21 18:00 ` [PATCH v3 11/11] mtd: rawnand: lpc32xx_slc: fix the probe function error path Miquel Raynal
2018-04-26 19:51 ` [PATCH v3 00/11] Fix NAND controllers probe functions " 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=20180426192648.4df1ad55@bbrezillon \
--to=boris.brezillon@bootlin.com \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=slemieux.tyco@gmail.com \
--cc=vz@mleia.com \
/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).