提交 465c29d3 编写于 作者: P Pasi Savanainen 提交者: Samuel Ortiz

mfd: Convert Intel MSIC driver to use devm_* interfaces.

The devm_* functions eliminate the need for manual resource releasing
and simplify error handling. Resources allocated by devm_* are freed
automatically on driver detach.
Signed-off-by: NPasi Savanainen <ext-pasi.m.savanainen@gmail.com>
Acked-by: NMika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
上级 2fe372fc
...@@ -406,7 +406,7 @@ static int __devinit intel_msic_probe(struct platform_device *pdev) ...@@ -406,7 +406,7 @@ static int __devinit intel_msic_probe(struct platform_device *pdev)
return -ENXIO; return -ENXIO;
} }
msic = kzalloc(sizeof(*msic), GFP_KERNEL); msic = devm_kzalloc(&pdev->dev, sizeof(*msic), GFP_KERNEL);
if (!msic) if (!msic)
return -ENOMEM; return -ENOMEM;
...@@ -421,21 +421,13 @@ static int __devinit intel_msic_probe(struct platform_device *pdev) ...@@ -421,21 +421,13 @@ static int __devinit intel_msic_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { if (!res) {
dev_err(&pdev->dev, "failed to get SRAM iomem resource\n"); dev_err(&pdev->dev, "failed to get SRAM iomem resource\n");
ret = -ENODEV; return -ENODEV;
goto fail_free_msic;
} }
res = request_mem_region(res->start, resource_size(res), pdev->name); msic->irq_base = devm_request_and_ioremap(&pdev->dev, res);
if (!res) {
ret = -EBUSY;
goto fail_free_msic;
}
msic->irq_base = ioremap_nocache(res->start, resource_size(res));
if (!msic->irq_base) { if (!msic->irq_base) {
dev_err(&pdev->dev, "failed to map SRAM memory\n"); dev_err(&pdev->dev, "failed to map SRAM memory\n");
ret = -ENOMEM; return -ENOMEM;
goto fail_release_region;
} }
platform_set_drvdata(pdev, msic); platform_set_drvdata(pdev, msic);
...@@ -443,7 +435,7 @@ static int __devinit intel_msic_probe(struct platform_device *pdev) ...@@ -443,7 +435,7 @@ static int __devinit intel_msic_probe(struct platform_device *pdev)
ret = intel_msic_init_devices(msic); ret = intel_msic_init_devices(msic);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to initialize MSIC devices\n"); dev_err(&pdev->dev, "failed to initialize MSIC devices\n");
goto fail_unmap_mem; return ret;
} }
dev_info(&pdev->dev, "Intel MSIC version %c%d (vendor %#x)\n", dev_info(&pdev->dev, "Intel MSIC version %c%d (vendor %#x)\n",
...@@ -451,27 +443,14 @@ static int __devinit intel_msic_probe(struct platform_device *pdev) ...@@ -451,27 +443,14 @@ static int __devinit intel_msic_probe(struct platform_device *pdev)
msic->vendor); msic->vendor);
return 0; return 0;
fail_unmap_mem:
iounmap(msic->irq_base);
fail_release_region:
release_mem_region(res->start, resource_size(res));
fail_free_msic:
kfree(msic);
return ret;
} }
static int __devexit intel_msic_remove(struct platform_device *pdev) static int __devexit intel_msic_remove(struct platform_device *pdev)
{ {
struct intel_msic *msic = platform_get_drvdata(pdev); struct intel_msic *msic = platform_get_drvdata(pdev);
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
intel_msic_remove_devices(msic); intel_msic_remove_devices(msic);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
iounmap(msic->irq_base);
release_mem_region(res->start, resource_size(res));
kfree(msic);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册