aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2016-04-26 05:03:22 -0400
committerTejun Heo <tj@kernel.org>2016-05-12 10:53:27 -0400
commit73ec1b5ab3a713141318ee845d8b0cc822db65b1 (patch)
tree1cb6f5567d9b405ca2349ebcf6544c8f1187f4f7
parentaf50f3a8b61cfdfcf4a01b01ec2759200d362605 (diff)
ata: sata_dwc_460ex: use devm_ioremap
This simplifies error handling and cleanup by using devm to manage IO mappings. Tested-by: Christian Lamparter <chunkeey@googlemail.com> Signed-off-by: Mans Rullgard <mans@mansr.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r--drivers/ata/sata_dwc_460ex.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index b4459fd6cd37..aaff5e85c35c 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -139,7 +139,6 @@ struct sata_dwc_device {
139 struct device *dev; /* generic device struct */ 139 struct device *dev; /* generic device struct */
140 struct ata_probe_ent *pe; /* ptr to probe-ent */ 140 struct ata_probe_ent *pe; /* ptr to probe-ent */
141 struct ata_host *host; 141 struct ata_host *host;
142 u8 __iomem *reg_base;
143 struct sata_dwc_regs __iomem *sata_dwc_regs; /* DW SATA specific */ 142 struct sata_dwc_regs __iomem *sata_dwc_regs; /* DW SATA specific */
144 u32 sactive_issued; 143 u32 sactive_issued;
145 u32 sactive_queued; 144 u32 sactive_queued;
@@ -241,7 +240,7 @@ static int sata_dwc_dma_init_old(struct platform_device *pdev,
241 struct sata_dwc_device *hsdev) 240 struct sata_dwc_device *hsdev)
242{ 241{
243 struct device_node *np = pdev->dev.of_node; 242 struct device_node *np = pdev->dev.of_node;
244 int err; 243 struct resource *res;
245 244
246 hsdev->dma = devm_kzalloc(&pdev->dev, sizeof(*hsdev->dma), GFP_KERNEL); 245 hsdev->dma = devm_kzalloc(&pdev->dev, sizeof(*hsdev->dma), GFP_KERNEL);
247 if (!hsdev->dma) 246 if (!hsdev->dma)
@@ -257,21 +256,16 @@ static int sata_dwc_dma_init_old(struct platform_device *pdev,
257 } 256 }
258 257
259 /* Get physical SATA DMA register base address */ 258 /* Get physical SATA DMA register base address */
260 hsdev->dma->regs = of_iomap(np, 1); 259 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
261 if (!hsdev->dma->regs) { 260 hsdev->dma->regs = devm_ioremap_resource(&pdev->dev, res);
261 if (IS_ERR(hsdev->dma->regs)) {
262 dev_err(&pdev->dev, 262 dev_err(&pdev->dev,
263 "ioremap failed for AHBDMA register address\n"); 263 "ioremap failed for AHBDMA register address\n");
264 return -ENODEV; 264 return PTR_ERR(hsdev->dma->regs);
265 } 265 }
266 266
267 /* Initialize AHB DMAC */ 267 /* Initialize AHB DMAC */
268 err = dw_dma_probe(hsdev->dma); 268 return dw_dma_probe(hsdev->dma);
269 if (err) {
270 iounmap(hsdev->dma->regs);
271 return err;
272 }
273
274 return 0;
275} 269}
276 270
277static void sata_dwc_dma_exit_old(struct sata_dwc_device *hsdev) 271static void sata_dwc_dma_exit_old(struct sata_dwc_device *hsdev)
@@ -280,7 +274,6 @@ static void sata_dwc_dma_exit_old(struct sata_dwc_device *hsdev)
280 return; 274 return;
281 275
282 dw_dma_remove(hsdev->dma); 276 dw_dma_remove(hsdev->dma);
283 iounmap(hsdev->dma->regs);
284} 277}
285 278
286#endif 279#endif
@@ -1219,6 +1212,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
1219 struct ata_port_info pi = sata_dwc_port_info[0]; 1212 struct ata_port_info pi = sata_dwc_port_info[0];
1220 const struct ata_port_info *ppi[] = { &pi, NULL }; 1213 const struct ata_port_info *ppi[] = { &pi, NULL };
1221 struct device_node *np = ofdev->dev.of_node; 1214 struct device_node *np = ofdev->dev.of_node;
1215 struct resource *res;
1222 1216
1223 /* Allocate DWC SATA device */ 1217 /* Allocate DWC SATA device */
1224 host = ata_host_alloc_pinfo(&ofdev->dev, ppi, SATA_DWC_MAX_PORTS); 1218 host = ata_host_alloc_pinfo(&ofdev->dev, ppi, SATA_DWC_MAX_PORTS);
@@ -1229,13 +1223,13 @@ static int sata_dwc_probe(struct platform_device *ofdev)
1229 host->private_data = hsdev; 1223 host->private_data = hsdev;
1230 1224
1231 /* Ioremap SATA registers */ 1225 /* Ioremap SATA registers */
1232 base = of_iomap(np, 0); 1226 res = platform_get_resource(ofdev, IORESOURCE_MEM, 0);
1233 if (!base) { 1227 base = devm_ioremap_resource(&ofdev->dev, res);
1228 if (IS_ERR(base)) {
1234 dev_err(&ofdev->dev, 1229 dev_err(&ofdev->dev,
1235 "ioremap failed for SATA register address\n"); 1230 "ioremap failed for SATA register address\n");
1236 return -ENODEV; 1231 return PTR_ERR(base);
1237 } 1232 }
1238 hsdev->reg_base = base;
1239 dev_dbg(&ofdev->dev, "ioremap done for SATA register address\n"); 1233 dev_dbg(&ofdev->dev, "ioremap done for SATA register address\n");
1240 1234
1241 /* Synopsys DWC SATA specific Registers */ 1235 /* Synopsys DWC SATA specific Registers */
@@ -1299,7 +1293,6 @@ static int sata_dwc_probe(struct platform_device *ofdev)
1299 1293
1300error_out: 1294error_out:
1301 phy_exit(hsdev->phy); 1295 phy_exit(hsdev->phy);
1302 iounmap(base);
1303 return err; 1296 return err;
1304} 1297}
1305 1298
@@ -1318,7 +1311,6 @@ static int sata_dwc_remove(struct platform_device *ofdev)
1318 sata_dwc_dma_exit_old(hsdev); 1311 sata_dwc_dma_exit_old(hsdev);
1319#endif 1312#endif
1320 1313
1321 iounmap(hsdev->reg_base);
1322 dev_dbg(&ofdev->dev, "done\n"); 1314 dev_dbg(&ofdev->dev, "done\n");
1323 return 0; 1315 return 0;
1324} 1316}