aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-ds1216.c
diff options
context:
space:
mode:
authorAlessandro Zummo <a.zummo@towertech.it>2009-01-06 17:42:23 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-06 18:59:25 -0500
commit97a1f9532ed41fd9cf5249fc1afae23fd47d1120 (patch)
treefe263c09d931eafe9bc37c8df2ff52df6b9f7473 /drivers/rtc/rtc-ds1216.c
parent0e1492330cd2c95df2553335d7a77351021a938f (diff)
rtc: rtc-ds1216 fixes
Fixes a few issues with the rtc-ds1216 driver - use rtc_valid_tm - use platform_driver_probe - fix init sequence - it was using rtc_unregister_driver where not needed. I also added resource_size and removed an useless pointer assignment. Signed-off-by: Alessandro Zummo <a.zummo@towertech.it> Tested-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-ds1216.c')
-rw-r--r--drivers/rtc/rtc-ds1216.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/drivers/rtc/rtc-ds1216.c b/drivers/rtc/rtc-ds1216.c
index 9a234a4ec06d..4aedc705518c 100644
--- a/drivers/rtc/rtc-ds1216.c
+++ b/drivers/rtc/rtc-ds1216.c
@@ -10,7 +10,7 @@
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/bcd.h> 11#include <linux/bcd.h>
12 12
13#define DRV_VERSION "0.1" 13#define DRV_VERSION "0.2"
14 14
15struct ds1216_regs { 15struct ds1216_regs {
16 u8 tsec; 16 u8 tsec;
@@ -101,7 +101,8 @@ static int ds1216_rtc_read_time(struct device *dev, struct rtc_time *tm)
101 tm->tm_year = bcd2bin(regs.year); 101 tm->tm_year = bcd2bin(regs.year);
102 if (tm->tm_year < 70) 102 if (tm->tm_year < 70)
103 tm->tm_year += 100; 103 tm->tm_year += 100;
104 return 0; 104
105 return rtc_valid_tm(tm);
105} 106}
106 107
107static int ds1216_rtc_set_time(struct device *dev, struct rtc_time *tm) 108static int ds1216_rtc_set_time(struct device *dev, struct rtc_time *tm)
@@ -138,9 +139,8 @@ static const struct rtc_class_ops ds1216_rtc_ops = {
138 .set_time = ds1216_rtc_set_time, 139 .set_time = ds1216_rtc_set_time,
139}; 140};
140 141
141static int __devinit ds1216_rtc_probe(struct platform_device *pdev) 142static int __init ds1216_rtc_probe(struct platform_device *pdev)
142{ 143{
143 struct rtc_device *rtc;
144 struct resource *res; 144 struct resource *res;
145 struct ds1216_priv *priv; 145 struct ds1216_priv *priv;
146 int ret = 0; 146 int ret = 0;
@@ -152,7 +152,10 @@ static int __devinit ds1216_rtc_probe(struct platform_device *pdev)
152 priv = kzalloc(sizeof *priv, GFP_KERNEL); 152 priv = kzalloc(sizeof *priv, GFP_KERNEL);
153 if (!priv) 153 if (!priv)
154 return -ENOMEM; 154 return -ENOMEM;
155 priv->size = res->end - res->start + 1; 155
156 platform_set_drvdata(pdev, priv);
157
158 priv->size = resource_size(res);
156 if (!request_mem_region(res->start, priv->size, pdev->name)) { 159 if (!request_mem_region(res->start, priv->size, pdev->name)) {
157 ret = -EBUSY; 160 ret = -EBUSY;
158 goto out; 161 goto out;
@@ -163,22 +166,18 @@ static int __devinit ds1216_rtc_probe(struct platform_device *pdev)
163 ret = -ENOMEM; 166 ret = -ENOMEM;
164 goto out; 167 goto out;
165 } 168 }
166 rtc = rtc_device_register("ds1216", &pdev->dev, 169 priv->rtc = rtc_device_register("ds1216", &pdev->dev,
167 &ds1216_rtc_ops, THIS_MODULE); 170 &ds1216_rtc_ops, THIS_MODULE);
168 if (IS_ERR(rtc)) { 171 if (IS_ERR(priv->rtc)) {
169 ret = PTR_ERR(rtc); 172 ret = PTR_ERR(priv->rtc);
170 goto out; 173 goto out;
171 } 174 }
172 priv->rtc = rtc;
173 platform_set_drvdata(pdev, priv);
174 175
175 /* dummy read to get clock into a known state */ 176 /* dummy read to get clock into a known state */
176 ds1216_read(priv->ioaddr, dummy); 177 ds1216_read(priv->ioaddr, dummy);
177 return 0; 178 return 0;
178 179
179out: 180out:
180 if (priv->rtc)
181 rtc_device_unregister(priv->rtc);
182 if (priv->ioaddr) 181 if (priv->ioaddr)
183 iounmap(priv->ioaddr); 182 iounmap(priv->ioaddr);
184 if (priv->baseaddr) 183 if (priv->baseaddr)
@@ -187,7 +186,7 @@ out:
187 return ret; 186 return ret;
188} 187}
189 188
190static int __devexit ds1216_rtc_remove(struct platform_device *pdev) 189static int __exit ds1216_rtc_remove(struct platform_device *pdev)
191{ 190{
192 struct ds1216_priv *priv = platform_get_drvdata(pdev); 191 struct ds1216_priv *priv = platform_get_drvdata(pdev);
193 192
@@ -203,13 +202,12 @@ static struct platform_driver ds1216_rtc_platform_driver = {
203 .name = "rtc-ds1216", 202 .name = "rtc-ds1216",
204 .owner = THIS_MODULE, 203 .owner = THIS_MODULE,
205 }, 204 },
206 .probe = ds1216_rtc_probe, 205 .remove = __exit_p(ds1216_rtc_remove),
207 .remove = __devexit_p(ds1216_rtc_remove),
208}; 206};
209 207
210static int __init ds1216_rtc_init(void) 208static int __init ds1216_rtc_init(void)
211{ 209{
212 return platform_driver_register(&ds1216_rtc_platform_driver); 210 return platform_driver_probe(&ds1216_rtc_platform_driver, ds1216_rtc_probe);
213} 211}
214 212
215static void __exit ds1216_rtc_exit(void) 213static void __exit ds1216_rtc_exit(void)