Commit d537fc0c authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Tejun Heo

sata_dwc_460ex: convert to devm_kzalloc in ->probe()

The patch converts ->probe() to use devm_kzalloc that simplifies error path.
Note that ata_host_alloc_pinfo() has been using device resources already.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent c592b74f
...@@ -1676,10 +1676,13 @@ static int sata_dwc_probe(struct platform_device *ofdev) ...@@ -1676,10 +1676,13 @@ static int sata_dwc_probe(struct platform_device *ofdev)
u32 dma_chan; u32 dma_chan;
/* Allocate DWC SATA device */ /* Allocate DWC SATA device */
hsdev = kzalloc(sizeof(*hsdev), GFP_KERNEL); host = ata_host_alloc_pinfo(&ofdev->dev, ppi, SATA_DWC_MAX_PORTS);
if (hsdev == NULL) hsdev = devm_kzalloc(&ofdev->dev, sizeof(*hsdev), GFP_KERNEL);
if (!host || !hsdev)
return -ENOMEM; return -ENOMEM;
host->private_data = hsdev;
if (of_property_read_u32(np, "dma-channel", &dma_chan)) { if (of_property_read_u32(np, "dma-channel", &dma_chan)) {
dev_warn(&ofdev->dev, "no dma-channel property set." dev_warn(&ofdev->dev, "no dma-channel property set."
" Use channel 0\n"); " Use channel 0\n");
...@@ -1692,8 +1695,7 @@ static int sata_dwc_probe(struct platform_device *ofdev) ...@@ -1692,8 +1695,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
if (!base) { if (!base) {
dev_err(&ofdev->dev, "ioremap failed for SATA register" dev_err(&ofdev->dev, "ioremap failed for SATA register"
" address\n"); " address\n");
err = -ENODEV; return -ENODEV;
goto error_kmalloc;
} }
hsdev->reg_base = base; hsdev->reg_base = base;
dev_dbg(&ofdev->dev, "ioremap done for SATA register address\n"); dev_dbg(&ofdev->dev, "ioremap done for SATA register address\n");
...@@ -1701,16 +1703,6 @@ static int sata_dwc_probe(struct platform_device *ofdev) ...@@ -1701,16 +1703,6 @@ static int sata_dwc_probe(struct platform_device *ofdev)
/* Synopsys DWC SATA specific Registers */ /* Synopsys DWC SATA specific Registers */
hsdev->sata_dwc_regs = (void *__iomem)(base + SATA_DWC_REG_OFFSET); hsdev->sata_dwc_regs = (void *__iomem)(base + SATA_DWC_REG_OFFSET);
/* Allocate and fill host */
host = ata_host_alloc_pinfo(&ofdev->dev, ppi, SATA_DWC_MAX_PORTS);
if (!host) {
dev_err(&ofdev->dev, "ata_host_alloc_pinfo failed\n");
err = -ENOMEM;
goto error_iomap;
}
host->private_data = hsdev;
/* Setup port */ /* Setup port */
host->ports[0]->ioaddr.cmd_addr = base; host->ports[0]->ioaddr.cmd_addr = base;
host->ports[0]->ioaddr.scr_addr = base + SATA_DWC_SCR_OFFSET; host->ports[0]->ioaddr.scr_addr = base + SATA_DWC_SCR_OFFSET;
...@@ -1778,8 +1770,6 @@ static int sata_dwc_probe(struct platform_device *ofdev) ...@@ -1778,8 +1770,6 @@ static int sata_dwc_probe(struct platform_device *ofdev)
iounmap((void __iomem *)host_pvt.sata_dma_regs); iounmap((void __iomem *)host_pvt.sata_dma_regs);
error_iomap: error_iomap:
iounmap(base); iounmap(base);
error_kmalloc:
kfree(hsdev);
return err; return err;
} }
...@@ -1796,8 +1786,6 @@ static int sata_dwc_remove(struct platform_device *ofdev) ...@@ -1796,8 +1786,6 @@ static int sata_dwc_remove(struct platform_device *ofdev)
iounmap((void __iomem *)host_pvt.sata_dma_regs); iounmap((void __iomem *)host_pvt.sata_dma_regs);
iounmap(hsdev->reg_base); iounmap(hsdev->reg_base);
kfree(hsdev);
kfree(host);
dev_dbg(&ofdev->dev, "done\n"); dev_dbg(&ofdev->dev, "done\n");
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment