Commit 2dba8518 authored by Russell King's avatar Russell King Committed by Russell King

[RTC] rtc-pl031: use proper resources, use proper apis, clean up includes

Clean up PL031 RTC includes, make driver use proper resource checking,
and use amba bus specific accessors.
Acked-by: default avatarAlessandro Zummo <a.zummo@towertech.it>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent f70c5253
...@@ -12,23 +12,12 @@ ...@@ -12,23 +12,12 @@
* as published by the Free Software Foundation; either version * as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
*/ */
#include <linux/platform_device.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/rtc.h> #include <linux/rtc.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/fs.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/string.h>
#include <linux/pm.h>
#include <linux/bitops.h>
#include <linux/amba/bus.h> #include <linux/amba/bus.h>
#include <linux/io.h>
#include <asm/io.h>
#include <asm/hardware.h>
#include <asm/irq.h>
#include <asm/rtc.h>
/* /*
* Register definitions * Register definitions
...@@ -142,13 +131,12 @@ static int pl031_remove(struct amba_device *adev) ...@@ -142,13 +131,12 @@ static int pl031_remove(struct amba_device *adev)
{ {
struct pl031_local *ldata = dev_get_drvdata(&adev->dev); struct pl031_local *ldata = dev_get_drvdata(&adev->dev);
if (ldata) { amba_set_drvdata(adev, NULL);
dev_set_drvdata(&adev->dev, NULL); free_irq(adev->irq[0], ldata->rtc);
free_irq(adev->irq[0], ldata->rtc); rtc_device_unregister(ldata->rtc);
rtc_device_unregister(ldata->rtc); iounmap(ldata->base);
iounmap(ldata->base); kfree(ldata);
kfree(ldata); amba_release_regions(adev);
}
return 0; return 0;
} }
...@@ -158,13 +146,15 @@ static int pl031_probe(struct amba_device *adev, void *id) ...@@ -158,13 +146,15 @@ static int pl031_probe(struct amba_device *adev, void *id)
int ret; int ret;
struct pl031_local *ldata; struct pl031_local *ldata;
ret = amba_request_regions(adev, NULL);
if (ret)
goto err_req;
ldata = kmalloc(sizeof(struct pl031_local), GFP_KERNEL); ldata = kmalloc(sizeof(struct pl031_local), GFP_KERNEL);
if (!ldata) { if (!ldata) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
dev_set_drvdata(&adev->dev, ldata);
ldata->base = ioremap(adev->res.start, ldata->base = ioremap(adev->res.start,
adev->res.end - adev->res.start + 1); adev->res.end - adev->res.start + 1);
...@@ -173,6 +163,8 @@ static int pl031_probe(struct amba_device *adev, void *id) ...@@ -173,6 +163,8 @@ static int pl031_probe(struct amba_device *adev, void *id)
goto out_no_remap; goto out_no_remap;
} }
amba_set_drvdata(adev, ldata);
if (request_irq(adev->irq[0], pl031_interrupt, IRQF_DISABLED, if (request_irq(adev->irq[0], pl031_interrupt, IRQF_DISABLED,
"rtc-pl031", ldata->rtc)) { "rtc-pl031", ldata->rtc)) {
ret = -EIO; ret = -EIO;
...@@ -192,10 +184,12 @@ static int pl031_probe(struct amba_device *adev, void *id) ...@@ -192,10 +184,12 @@ static int pl031_probe(struct amba_device *adev, void *id)
free_irq(adev->irq[0], ldata->rtc); free_irq(adev->irq[0], ldata->rtc);
out_no_irq: out_no_irq:
iounmap(ldata->base); iounmap(ldata->base);
amba_set_drvdata(adev, NULL);
out_no_remap: out_no_remap:
dev_set_drvdata(&adev->dev, NULL);
kfree(ldata); kfree(ldata);
out: out:
amba_release_regions(adev);
err_req:
return ret; return ret;
} }
......
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