rtc: pl031: use devm_* for allocating memory and mapping resource
Use the devm_* APIs for allocating memory and mapping the memory in the probe function to relieve the driver from having to deal with this in the cleanup paths. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
This commit is contained in:
parent
eb508b36d5
commit
273c868e85
|
@ -310,8 +310,6 @@ static int pl031_remove(struct amba_device *adev)
|
||||||
device_init_wakeup(&adev->dev, false);
|
device_init_wakeup(&adev->dev, false);
|
||||||
free_irq(adev->irq[0], ldata);
|
free_irq(adev->irq[0], ldata);
|
||||||
rtc_device_unregister(ldata->rtc);
|
rtc_device_unregister(ldata->rtc);
|
||||||
iounmap(ldata->base);
|
|
||||||
kfree(ldata);
|
|
||||||
amba_release_regions(adev);
|
amba_release_regions(adev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -329,18 +327,19 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_req;
|
goto err_req;
|
||||||
|
|
||||||
ldata = kzalloc(sizeof(struct pl031_local), GFP_KERNEL);
|
ldata = devm_kzalloc(&adev->dev, sizeof(struct pl031_local),
|
||||||
|
GFP_KERNEL);
|
||||||
if (!ldata) {
|
if (!ldata) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
ldata->vendor = vendor;
|
ldata->vendor = vendor;
|
||||||
|
|
||||||
ldata->base = ioremap(adev->res.start, resource_size(&adev->res));
|
ldata->base = devm_ioremap(&adev->dev, adev->res.start,
|
||||||
|
resource_size(&adev->res));
|
||||||
if (!ldata->base) {
|
if (!ldata->base) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto out_no_remap;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
amba_set_drvdata(adev, ldata);
|
amba_set_drvdata(adev, ldata);
|
||||||
|
@ -378,7 +377,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
THIS_MODULE);
|
THIS_MODULE);
|
||||||
if (IS_ERR(ldata->rtc)) {
|
if (IS_ERR(ldata->rtc)) {
|
||||||
ret = PTR_ERR(ldata->rtc);
|
ret = PTR_ERR(ldata->rtc);
|
||||||
goto out_no_rtc;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request_irq(adev->irq[0], pl031_interrupt,
|
if (request_irq(adev->irq[0], pl031_interrupt,
|
||||||
|
@ -391,10 +390,6 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
|
|
||||||
out_no_irq:
|
out_no_irq:
|
||||||
rtc_device_unregister(ldata->rtc);
|
rtc_device_unregister(ldata->rtc);
|
||||||
out_no_rtc:
|
|
||||||
iounmap(ldata->base);
|
|
||||||
out_no_remap:
|
|
||||||
kfree(ldata);
|
|
||||||
out:
|
out:
|
||||||
amba_release_regions(adev);
|
amba_release_regions(adev);
|
||||||
err_req:
|
err_req:
|
||||||
|
|
Loading…
Reference in New Issue