diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2008-04-20 07:08:04 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-05-22 09:56:36 -0400 |
commit | 2dba8518b7761aee3ba757b298efa15dd34eff18 (patch) | |
tree | ab1be221f514a015fac7c0518bd7db4911e29082 /drivers/rtc/rtc-pl031.c | |
parent | f70c5253b41444fd2779e1f76bfe25811d9b8c23 (diff) |
[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: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/rtc/rtc-pl031.c')
-rw-r--r-- | drivers/rtc/rtc-pl031.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index 2fd49edcc712..08b4610ec5a6 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c | |||
@@ -12,23 +12,12 @@ | |||
12 | * as published by the Free Software Foundation; either version | 12 | * as published by the Free Software Foundation; either version |
13 | * 2 of the License, or (at your option) any later version. | 13 | * 2 of the License, or (at your option) any later version. |
14 | */ | 14 | */ |
15 | |||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/module.h> | 15 | #include <linux/module.h> |
18 | #include <linux/rtc.h> | 16 | #include <linux/rtc.h> |
19 | #include <linux/init.h> | 17 | #include <linux/init.h> |
20 | #include <linux/fs.h> | ||
21 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
22 | #include <linux/string.h> | ||
23 | #include <linux/pm.h> | ||
24 | #include <linux/bitops.h> | ||
25 | |||
26 | #include <linux/amba/bus.h> | 19 | #include <linux/amba/bus.h> |
27 | 20 | #include <linux/io.h> | |
28 | #include <asm/io.h> | ||
29 | #include <asm/hardware.h> | ||
30 | #include <asm/irq.h> | ||
31 | #include <asm/rtc.h> | ||
32 | 21 | ||
33 | /* | 22 | /* |
34 | * Register definitions | 23 | * Register definitions |
@@ -142,13 +131,12 @@ static int pl031_remove(struct amba_device *adev) | |||
142 | { | 131 | { |
143 | struct pl031_local *ldata = dev_get_drvdata(&adev->dev); | 132 | struct pl031_local *ldata = dev_get_drvdata(&adev->dev); |
144 | 133 | ||
145 | if (ldata) { | 134 | amba_set_drvdata(adev, NULL); |
146 | dev_set_drvdata(&adev->dev, NULL); | 135 | free_irq(adev->irq[0], ldata->rtc); |
147 | free_irq(adev->irq[0], ldata->rtc); | 136 | rtc_device_unregister(ldata->rtc); |
148 | rtc_device_unregister(ldata->rtc); | 137 | iounmap(ldata->base); |
149 | iounmap(ldata->base); | 138 | kfree(ldata); |
150 | kfree(ldata); | 139 | amba_release_regions(adev); |
151 | } | ||
152 | 140 | ||
153 | return 0; | 141 | return 0; |
154 | } | 142 | } |
@@ -158,13 +146,15 @@ static int pl031_probe(struct amba_device *adev, void *id) | |||
158 | int ret; | 146 | int ret; |
159 | struct pl031_local *ldata; | 147 | struct pl031_local *ldata; |
160 | 148 | ||
149 | ret = amba_request_regions(adev, NULL); | ||
150 | if (ret) | ||
151 | goto err_req; | ||
161 | 152 | ||
162 | ldata = kmalloc(sizeof(struct pl031_local), GFP_KERNEL); | 153 | ldata = kmalloc(sizeof(struct pl031_local), GFP_KERNEL); |
163 | if (!ldata) { | 154 | if (!ldata) { |
164 | ret = -ENOMEM; | 155 | ret = -ENOMEM; |
165 | goto out; | 156 | goto out; |
166 | } | 157 | } |
167 | dev_set_drvdata(&adev->dev, ldata); | ||
168 | 158 | ||
169 | ldata->base = ioremap(adev->res.start, | 159 | ldata->base = ioremap(adev->res.start, |
170 | adev->res.end - adev->res.start + 1); | 160 | adev->res.end - adev->res.start + 1); |
@@ -173,6 +163,8 @@ static int pl031_probe(struct amba_device *adev, void *id) | |||
173 | goto out_no_remap; | 163 | goto out_no_remap; |
174 | } | 164 | } |
175 | 165 | ||
166 | amba_set_drvdata(adev, ldata); | ||
167 | |||
176 | if (request_irq(adev->irq[0], pl031_interrupt, IRQF_DISABLED, | 168 | if (request_irq(adev->irq[0], pl031_interrupt, IRQF_DISABLED, |
177 | "rtc-pl031", ldata->rtc)) { | 169 | "rtc-pl031", ldata->rtc)) { |
178 | ret = -EIO; | 170 | ret = -EIO; |
@@ -192,10 +184,12 @@ out_no_rtc: | |||
192 | free_irq(adev->irq[0], ldata->rtc); | 184 | free_irq(adev->irq[0], ldata->rtc); |
193 | out_no_irq: | 185 | out_no_irq: |
194 | iounmap(ldata->base); | 186 | iounmap(ldata->base); |
187 | amba_set_drvdata(adev, NULL); | ||
195 | out_no_remap: | 188 | out_no_remap: |
196 | dev_set_drvdata(&adev->dev, NULL); | ||
197 | kfree(ldata); | 189 | kfree(ldata); |
198 | out: | 190 | out: |
191 | amba_release_regions(adev); | ||
192 | err_req: | ||
199 | return ret; | 193 | return ret; |
200 | } | 194 | } |
201 | 195 | ||