Commit e0ea20bf authored by Miquel Raynal's avatar Miquel Raynal Committed by Boris Brezillon
Browse files

mtd: rawnand: lpc32xx_slc: clean the probe function



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: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
parent 838c07b0
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -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 enable_wp;
	}
	res = clk_prepare_enable(host->clk);
	if (res)
		goto err_exit1;
		goto enable_wp;

	/* 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 unprepare_clk;
	}

	res = lpc32xx_nand_dma_setup(host);
	if (res) {
		res = -EIO;
		goto err_exit2;
		goto unprepare_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;

	nand_release(mtd);
	return 0;

err_exit3:
release_nand:
	nand_release(mtd);
release_dma:
	dma_release_channel(host->dma_chan);
err_exit2:
unprepare_clk:
	clk_disable_unprepare(host->clk);
err_exit1:
enable_wp:
	lpc32xx_wp_enable(host);

	return res;