Skip to content

Commit

Permalink
pata_imx: cleanup error path
Browse files Browse the repository at this point in the history
- rename free_priv label to 'err' since priv is allocated with devm_*
  and not freed here.
- add missing 'goto err' in case ata_host_activate fails
- add 'ret' variable to return correct error value instead of hardcoded
  -ENOMEM in error case.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
  • Loading branch information
Sascha Hauer authored and Jeff Garzik committed Apr 11, 2013
1 parent 50f5a34 commit ff540d0
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions drivers/ata/pata_imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ static int pata_imx_probe(struct platform_device *pdev)
struct pata_imx_priv *priv;
int irq = 0;
struct resource *io_res;
int ret;

io_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (io_res == NULL)
Expand All @@ -121,8 +122,10 @@ static int pata_imx_probe(struct platform_device *pdev)
clk_prepare_enable(priv->clk);

host = ata_host_alloc(&pdev->dev, 1);
if (!host)
goto free_priv;
if (!host) {
ret = -ENOMEM;
goto err;
}

host->private_data = priv;
ap = host->ports[0];
Expand All @@ -135,7 +138,8 @@ static int pata_imx_probe(struct platform_device *pdev)
resource_size(io_res));
if (!priv->host_regs) {
dev_err(&pdev->dev, "failed to map IO/CTL base\n");
goto free_priv;
ret = -EBUSY;
goto err;
}

ap->ioaddr.cmd_addr = priv->host_regs + PATA_IMX_DRIVE_DATA;
Expand All @@ -158,13 +162,17 @@ static int pata_imx_probe(struct platform_device *pdev)
priv->host_regs + PATA_IMX_ATA_INT_EN);

/* activate */
return ata_host_activate(host, irq, ata_sff_interrupt, 0,
ret = ata_host_activate(host, irq, ata_sff_interrupt, 0,
&pata_imx_sht);

free_priv:
if (ret)
goto err;

return 0;
err:
clk_disable_unprepare(priv->clk);

return -ENOMEM;
return ret;
}

static int pata_imx_remove(struct platform_device *pdev)
Expand Down

0 comments on commit ff540d0

Please sign in to comment.