aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/Kconfig12
-rw-r--r--drivers/rtc/hctosys.c4
-rw-r--r--drivers/rtc/interface.c26
-rw-r--r--drivers/rtc/rtc-at32ap700x.c20
-rw-r--r--drivers/rtc/rtc-cmos.c3
-rw-r--r--drivers/rtc/rtc-dev.c12
-rw-r--r--drivers/rtc/rtc-ds1307.c93
-rw-r--r--drivers/rtc/rtc-ds1553.c2
-rw-r--r--drivers/rtc/rtc-ds1672.c2
-rw-r--r--drivers/rtc/rtc-ds1742.c5
-rw-r--r--drivers/rtc/rtc-isl1208.c2
-rw-r--r--drivers/rtc/rtc-m48t59.c9
-rw-r--r--drivers/rtc/rtc-max6900.c2
-rw-r--r--drivers/rtc/rtc-max6902.c12
-rw-r--r--drivers/rtc/rtc-pcf8563.c2
-rw-r--r--drivers/rtc/rtc-pcf8583.c2
-rw-r--r--drivers/rtc/rtc-s3c.c2
-rw-r--r--drivers/rtc/rtc-sa1100.c31
-rw-r--r--drivers/rtc/rtc-sh.c30
-rw-r--r--drivers/rtc/rtc-stk17ta8.c2
-rw-r--r--drivers/rtc/rtc-x1205.c2
21 files changed, 200 insertions, 75 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index cbde770eb121..45e4b9648176 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -36,7 +36,9 @@ config RTC_HCTOSYS_DEVICE
36 help 36 help
37 The RTC device that will be used to (re)initialize the system 37 The RTC device that will be used to (re)initialize the system
38 clock, usually rtc0. Initialization is done when the system 38 clock, usually rtc0. Initialization is done when the system
39 starts up, and when it resumes from a low power state. 39 starts up, and when it resumes from a low power state. This
40 device should record time in UTC, since the kernel won't do
41 timezone correction.
40 42
41 The driver for this RTC device must be loaded before late_initcall 43 The driver for this RTC device must be loaded before late_initcall
42 functions run, so it must usually be statically linked. 44 functions run, so it must usually be statically linked.
@@ -133,8 +135,8 @@ config RTC_DRV_DS1307
133 135
134 The first seven registers on these chips hold an RTC, and other 136 The first seven registers on these chips hold an RTC, and other
135 registers may add features such as NVRAM, a trickle charger for 137 registers may add features such as NVRAM, a trickle charger for
136 the RTC/NVRAM backup power, and alarms. This driver may not 138 the RTC/NVRAM backup power, and alarms. NVRAM is visible in
137 expose all those available chip features. 139 sysfs, but other chip features may not be available.
138 140
139 This driver can also be built as a module. If so, the module 141 This driver can also be built as a module. If so, the module
140 will be called rtc-ds1307. 142 will be called rtc-ds1307.
@@ -402,7 +404,7 @@ config RTC_DRV_SA1100
402 404
403config RTC_DRV_SH 405config RTC_DRV_SH
404 tristate "SuperH On-Chip RTC" 406 tristate "SuperH On-Chip RTC"
405 depends on RTC_CLASS && (CPU_SH3 || CPU_SH4) 407 depends on RTC_CLASS && SUPERH
406 help 408 help
407 Say Y here to enable support for the on-chip RTC found in 409 Say Y here to enable support for the on-chip RTC found in
408 most SuperH processors. 410 most SuperH processors.
@@ -445,7 +447,7 @@ config RTC_DRV_AT91RM9200
445 447
446config RTC_DRV_BFIN 448config RTC_DRV_BFIN
447 tristate "Blackfin On-Chip RTC" 449 tristate "Blackfin On-Chip RTC"
448 depends on BFIN 450 depends on BLACKFIN
449 help 451 help
450 If you say yes here you will get support for the 452 If you say yes here you will get support for the
451 Blackfin On-Chip Real Time Clock. 453 Blackfin On-Chip Real Time Clock.
diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c
index 178527252c6a..33c0e98243ee 100644
--- a/drivers/rtc/hctosys.c
+++ b/drivers/rtc/hctosys.c
@@ -47,8 +47,8 @@ static int __init rtc_hctosys(void)
47 do_settimeofday(&tv); 47 do_settimeofday(&tv);
48 48
49 dev_info(rtc->dev.parent, 49 dev_info(rtc->dev.parent,
50 "setting the system clock to " 50 "setting system clock to "
51 "%d-%02d-%02d %02d:%02d:%02d (%u)\n", 51 "%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n",
52 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 52 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
53 tm.tm_hour, tm.tm_min, tm.tm_sec, 53 tm.tm_hour, tm.tm_min, tm.tm_sec,
54 (unsigned int) tv.tv_sec); 54 (unsigned int) tv.tv_sec);
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index de0da545c7a1..7e3ad4f3b343 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -251,20 +251,23 @@ void rtc_update_irq(struct rtc_device *rtc,
251} 251}
252EXPORT_SYMBOL_GPL(rtc_update_irq); 252EXPORT_SYMBOL_GPL(rtc_update_irq);
253 253
254static int __rtc_match(struct device *dev, void *data)
255{
256 char *name = (char *)data;
257
258 if (strncmp(dev->bus_id, name, BUS_ID_SIZE) == 0)
259 return 1;
260 return 0;
261}
262
254struct rtc_device *rtc_class_open(char *name) 263struct rtc_device *rtc_class_open(char *name)
255{ 264{
256 struct device *dev; 265 struct device *dev;
257 struct rtc_device *rtc = NULL; 266 struct rtc_device *rtc = NULL;
258 267
259 down(&rtc_class->sem); 268 dev = class_find_device(rtc_class, name, __rtc_match);
260 list_for_each_entry(dev, &rtc_class->devices, node) { 269 if (dev)
261 if (strncmp(dev->bus_id, name, BUS_ID_SIZE) == 0) { 270 rtc = to_rtc_device(dev);
262 dev = get_device(dev);
263 if (dev)
264 rtc = to_rtc_device(dev);
265 break;
266 }
267 }
268 271
269 if (rtc) { 272 if (rtc) {
270 if (!try_module_get(rtc->owner)) { 273 if (!try_module_get(rtc->owner)) {
@@ -272,7 +275,6 @@ struct rtc_device *rtc_class_open(char *name)
272 rtc = NULL; 275 rtc = NULL;
273 } 276 }
274 } 277 }
275 up(&rtc_class->sem);
276 278
277 return rtc; 279 return rtc;
278} 280}
@@ -293,7 +295,7 @@ int rtc_irq_register(struct rtc_device *rtc, struct rtc_task *task)
293 return -EINVAL; 295 return -EINVAL;
294 296
295 /* Cannot register while the char dev is in use */ 297 /* Cannot register while the char dev is in use */
296 if (!(mutex_trylock(&rtc->char_lock))) 298 if (test_and_set_bit_lock(RTC_DEV_BUSY, &rtc->flags))
297 return -EBUSY; 299 return -EBUSY;
298 300
299 spin_lock_irq(&rtc->irq_task_lock); 301 spin_lock_irq(&rtc->irq_task_lock);
@@ -303,7 +305,7 @@ int rtc_irq_register(struct rtc_device *rtc, struct rtc_task *task)
303 } 305 }
304 spin_unlock_irq(&rtc->irq_task_lock); 306 spin_unlock_irq(&rtc->irq_task_lock);
305 307
306 mutex_unlock(&rtc->char_lock); 308 clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags);
307 309
308 return retval; 310 return retval;
309} 311}
diff --git a/drivers/rtc/rtc-at32ap700x.c b/drivers/rtc/rtc-at32ap700x.c
index 2999214ca534..d3b9b14267ab 100644
--- a/drivers/rtc/rtc-at32ap700x.c
+++ b/drivers/rtc/rtc-at32ap700x.c
@@ -225,18 +225,12 @@ static int __init at32_rtc_probe(struct platform_device *pdev)
225 goto out; 225 goto out;
226 } 226 }
227 227
228 ret = request_irq(irq, at32_rtc_interrupt, IRQF_SHARED, "rtc", rtc);
229 if (ret) {
230 dev_dbg(&pdev->dev, "could not request irq %d\n", irq);
231 goto out;
232 }
233
234 rtc->irq = irq; 228 rtc->irq = irq;
235 rtc->regs = ioremap(regs->start, regs->end - regs->start + 1); 229 rtc->regs = ioremap(regs->start, regs->end - regs->start + 1);
236 if (!rtc->regs) { 230 if (!rtc->regs) {
237 ret = -ENOMEM; 231 ret = -ENOMEM;
238 dev_dbg(&pdev->dev, "could not map I/O memory\n"); 232 dev_dbg(&pdev->dev, "could not map I/O memory\n");
239 goto out_free_irq; 233 goto out;
240 } 234 }
241 spin_lock_init(&rtc->lock); 235 spin_lock_init(&rtc->lock);
242 236
@@ -253,12 +247,18 @@ static int __init at32_rtc_probe(struct platform_device *pdev)
253 | RTC_BIT(CTRL_EN)); 247 | RTC_BIT(CTRL_EN));
254 } 248 }
255 249
250 ret = request_irq(irq, at32_rtc_interrupt, IRQF_SHARED, "rtc", rtc);
251 if (ret) {
252 dev_dbg(&pdev->dev, "could not request irq %d\n", irq);
253 goto out_iounmap;
254 }
255
256 rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, 256 rtc->rtc = rtc_device_register(pdev->name, &pdev->dev,
257 &at32_rtc_ops, THIS_MODULE); 257 &at32_rtc_ops, THIS_MODULE);
258 if (IS_ERR(rtc->rtc)) { 258 if (IS_ERR(rtc->rtc)) {
259 dev_dbg(&pdev->dev, "could not register rtc device\n"); 259 dev_dbg(&pdev->dev, "could not register rtc device\n");
260 ret = PTR_ERR(rtc->rtc); 260 ret = PTR_ERR(rtc->rtc);
261 goto out_iounmap; 261 goto out_free_irq;
262 } 262 }
263 263
264 platform_set_drvdata(pdev, rtc); 264 platform_set_drvdata(pdev, rtc);
@@ -268,10 +268,10 @@ static int __init at32_rtc_probe(struct platform_device *pdev)
268 268
269 return 0; 269 return 0;
270 270
271out_iounmap:
272 iounmap(rtc->regs);
273out_free_irq: 271out_free_irq:
274 free_irq(irq, rtc); 272 free_irq(irq, rtc);
273out_iounmap:
274 iounmap(rtc->regs);
275out: 275out:
276 kfree(rtc); 276 kfree(rtc);
277 return ret; 277 return ret;
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index e3fe83a23cf7..29cf1457ca10 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -120,7 +120,8 @@ static int cmos_read_alarm(struct device *dev, struct rtc_wkalrm *t)
120 t->time.tm_hour = CMOS_READ(RTC_HOURS_ALARM); 120 t->time.tm_hour = CMOS_READ(RTC_HOURS_ALARM);
121 121
122 if (cmos->day_alrm) { 122 if (cmos->day_alrm) {
123 t->time.tm_mday = CMOS_READ(cmos->day_alrm); 123 /* ignore upper bits on readback per ACPI spec */
124 t->time.tm_mday = CMOS_READ(cmos->day_alrm) & 0x3f;
124 if (!t->time.tm_mday) 125 if (!t->time.tm_mday)
125 t->time.tm_mday = -1; 126 t->time.tm_mday = -1;
126 127
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index 814583bd2fe7..025c60a17a4a 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -26,10 +26,7 @@ static int rtc_dev_open(struct inode *inode, struct file *file)
26 struct rtc_device, char_dev); 26 struct rtc_device, char_dev);
27 const struct rtc_class_ops *ops = rtc->ops; 27 const struct rtc_class_ops *ops = rtc->ops;
28 28
29 /* We keep the lock as long as the device is in use 29 if (test_and_set_bit_lock(RTC_DEV_BUSY, &rtc->flags))
30 * and return immediately if busy
31 */
32 if (!(mutex_trylock(&rtc->char_lock)))
33 return -EBUSY; 30 return -EBUSY;
34 31
35 file->private_data = rtc; 32 file->private_data = rtc;
@@ -43,8 +40,8 @@ static int rtc_dev_open(struct inode *inode, struct file *file)
43 return 0; 40 return 0;
44 } 41 }
45 42
46 /* something has gone wrong, release the lock */ 43 /* something has gone wrong */
47 mutex_unlock(&rtc->char_lock); 44 clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags);
48 return err; 45 return err;
49} 46}
50 47
@@ -405,7 +402,7 @@ static int rtc_dev_release(struct inode *inode, struct file *file)
405 if (rtc->ops->release) 402 if (rtc->ops->release)
406 rtc->ops->release(rtc->dev.parent); 403 rtc->ops->release(rtc->dev.parent);
407 404
408 mutex_unlock(&rtc->char_lock); 405 clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags);
409 return 0; 406 return 0;
410} 407}
411 408
@@ -440,7 +437,6 @@ void rtc_dev_prepare(struct rtc_device *rtc)
440 437
441 rtc->dev.devt = MKDEV(MAJOR(rtc_devt), rtc->id); 438 rtc->dev.devt = MKDEV(MAJOR(rtc_devt), rtc->id);
442 439
443 mutex_init(&rtc->char_lock);
444#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL 440#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
445 INIT_WORK(&rtc->uie_task, rtc_uie_task); 441 INIT_WORK(&rtc->uie_task, rtc_uie_task);
446 setup_timer(&rtc->uie_timer, rtc_uie_timer, (unsigned long)rtc); 442 setup_timer(&rtc->uie_timer, rtc_uie_timer, (unsigned long)rtc);
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index db6f3f0d8982..bc1c7fe94ad3 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -89,6 +89,7 @@ enum ds_type {
89 89
90struct ds1307 { 90struct ds1307 {
91 u8 reg_addr; 91 u8 reg_addr;
92 bool has_nvram;
92 u8 regs[8]; 93 u8 regs[8];
93 enum ds_type type; 94 enum ds_type type;
94 struct i2c_msg msg[2]; 95 struct i2c_msg msg[2];
@@ -242,6 +243,87 @@ static const struct rtc_class_ops ds13xx_rtc_ops = {
242 .set_time = ds1307_set_time, 243 .set_time = ds1307_set_time,
243}; 244};
244 245
246/*----------------------------------------------------------------------*/
247
248#define NVRAM_SIZE 56
249
250static ssize_t
251ds1307_nvram_read(struct kobject *kobj, struct bin_attribute *attr,
252 char *buf, loff_t off, size_t count)
253{
254 struct i2c_client *client;
255 struct ds1307 *ds1307;
256 struct i2c_msg msg[2];
257 int result;
258
259 client = to_i2c_client(container_of(kobj, struct device, kobj));
260 ds1307 = i2c_get_clientdata(client);
261
262 if (unlikely(off >= NVRAM_SIZE))
263 return 0;
264 if ((off + count) > NVRAM_SIZE)
265 count = NVRAM_SIZE - off;
266 if (unlikely(!count))
267 return count;
268
269 msg[0].addr = client->addr;
270 msg[0].flags = 0;
271 msg[0].len = 1;
272 msg[0].buf = buf;
273
274 buf[0] = 8 + off;
275
276 msg[1].addr = client->addr;
277 msg[1].flags = I2C_M_RD;
278 msg[1].len = count;
279 msg[1].buf = buf;
280
281 result = i2c_transfer(to_i2c_adapter(client->dev.parent), msg, 2);
282 if (result != 2) {
283 dev_err(&client->dev, "%s error %d\n", "nvram read", result);
284 return -EIO;
285 }
286 return count;
287}
288
289static ssize_t
290ds1307_nvram_write(struct kobject *kobj, struct bin_attribute *attr,
291 char *buf, loff_t off, size_t count)
292{
293 struct i2c_client *client;
294 u8 buffer[NVRAM_SIZE + 1];
295 int ret;
296
297 client = to_i2c_client(container_of(kobj, struct device, kobj));
298
299 if (unlikely(off >= NVRAM_SIZE))
300 return -EFBIG;
301 if ((off + count) > NVRAM_SIZE)
302 count = NVRAM_SIZE - off;
303 if (unlikely(!count))
304 return count;
305
306 buffer[0] = 8 + off;
307 memcpy(buffer + 1, buf, count);
308
309 ret = i2c_master_send(client, buffer, count + 1);
310 return (ret < 0) ? ret : (ret - 1);
311}
312
313static struct bin_attribute nvram = {
314 .attr = {
315 .name = "nvram",
316 .mode = S_IRUGO | S_IWUSR,
317 .owner = THIS_MODULE,
318 },
319
320 .read = ds1307_nvram_read,
321 .write = ds1307_nvram_write,
322 .size = NVRAM_SIZE,
323};
324
325/*----------------------------------------------------------------------*/
326
245static struct i2c_driver ds1307_driver; 327static struct i2c_driver ds1307_driver;
246 328
247static int __devinit ds1307_probe(struct i2c_client *client) 329static int __devinit ds1307_probe(struct i2c_client *client)
@@ -413,6 +495,14 @@ read_rtc:
413 goto exit_free; 495 goto exit_free;
414 } 496 }
415 497
498 if (chip->nvram56) {
499 err = sysfs_create_bin_file(&client->dev.kobj, &nvram);
500 if (err == 0) {
501 ds1307->has_nvram = true;
502 dev_info(&client->dev, "56 bytes nvram\n");
503 }
504 }
505
416 return 0; 506 return 0;
417 507
418exit_bad: 508exit_bad:
@@ -432,6 +522,9 @@ static int __devexit ds1307_remove(struct i2c_client *client)
432{ 522{
433 struct ds1307 *ds1307 = i2c_get_clientdata(client); 523 struct ds1307 *ds1307 = i2c_get_clientdata(client);
434 524
525 if (ds1307->has_nvram)
526 sysfs_remove_bin_file(&client->dev.kobj, &nvram);
527
435 rtc_device_unregister(ds1307->rtc); 528 rtc_device_unregister(ds1307->rtc);
436 kfree(ds1307); 529 kfree(ds1307);
437 return 0; 530 return 0;
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c
index bb53c09bad16..d9e848dcd450 100644
--- a/drivers/rtc/rtc-ds1553.c
+++ b/drivers/rtc/rtc-ds1553.c
@@ -291,7 +291,7 @@ static ssize_t ds1553_nvram_write(struct kobject *kobj,
291static struct bin_attribute ds1553_nvram_attr = { 291static struct bin_attribute ds1553_nvram_attr = {
292 .attr = { 292 .attr = {
293 .name = "nvram", 293 .name = "nvram",
294 .mode = S_IRUGO | S_IWUGO, 294 .mode = S_IRUGO | S_IWUSR,
295 }, 295 },
296 .size = RTC_OFFSET, 296 .size = RTC_OFFSET,
297 .read = ds1553_nvram_read, 297 .read = ds1553_nvram_read,
diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c
index dfef1637bfb8..e0900ca678ec 100644
--- a/drivers/rtc/rtc-ds1672.c
+++ b/drivers/rtc/rtc-ds1672.c
@@ -16,7 +16,7 @@
16#define DRV_VERSION "0.3" 16#define DRV_VERSION "0.3"
17 17
18/* Addresses to scan: none. This chip cannot be detected. */ 18/* Addresses to scan: none. This chip cannot be detected. */
19static unsigned short normal_i2c[] = { I2C_CLIENT_END }; 19static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
20 20
21/* Insmod parameters */ 21/* Insmod parameters */
22I2C_CLIENT_INSMOD; 22I2C_CLIENT_INSMOD;
diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c
index c535b78698e2..2e73f0b183b2 100644
--- a/drivers/rtc/rtc-ds1742.c
+++ b/drivers/rtc/rtc-ds1742.c
@@ -160,10 +160,13 @@ static ssize_t ds1742_nvram_write(struct kobject *kobj,
160static struct bin_attribute ds1742_nvram_attr = { 160static struct bin_attribute ds1742_nvram_attr = {
161 .attr = { 161 .attr = {
162 .name = "nvram", 162 .name = "nvram",
163 .mode = S_IRUGO | S_IWUGO, 163 .mode = S_IRUGO | S_IWUSR,
164 }, 164 },
165 .read = ds1742_nvram_read, 165 .read = ds1742_nvram_read,
166 .write = ds1742_nvram_write, 166 .write = ds1742_nvram_write,
167 /* REVISIT: size in sysfs won't match actual size... if it's
168 * not a constant, each RTC should have its own attribute.
169 */
167}; 170};
168 171
169static int __devinit ds1742_rtc_probe(struct platform_device *pdev) 172static int __devinit ds1742_rtc_probe(struct platform_device *pdev)
diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index 1c743641b73b..725b0c73c333 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -61,7 +61,7 @@
61/* i2c configuration */ 61/* i2c configuration */
62#define ISL1208_I2C_ADDR 0xde 62#define ISL1208_I2C_ADDR 0xde
63 63
64static unsigned short normal_i2c[] = { 64static const unsigned short normal_i2c[] = {
65 ISL1208_I2C_ADDR>>1, I2C_CLIENT_END 65 ISL1208_I2C_ADDR>>1, I2C_CLIENT_END
66}; 66};
67I2C_CLIENT_INSMOD; /* defines addr_data */ 67I2C_CLIENT_INSMOD; /* defines addr_data */
diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
index bf60d35f580b..cd0bbc0e8038 100644
--- a/drivers/rtc/rtc-m48t59.c
+++ b/drivers/rtc/rtc-m48t59.c
@@ -353,11 +353,12 @@ static ssize_t m48t59_nvram_write(struct kobject *kobj,
353static struct bin_attribute m48t59_nvram_attr = { 353static struct bin_attribute m48t59_nvram_attr = {
354 .attr = { 354 .attr = {
355 .name = "nvram", 355 .name = "nvram",
356 .mode = S_IRUGO | S_IWUGO, 356 .mode = S_IRUGO | S_IWUSR,
357 .owner = THIS_MODULE, 357 .owner = THIS_MODULE,
358 }, 358 },
359 .read = m48t59_nvram_read, 359 .read = m48t59_nvram_read,
360 .write = m48t59_nvram_write, 360 .write = m48t59_nvram_write,
361 .size = M48T59_NVRAM_SIZE,
361}; 362};
362 363
363static int __devinit m48t59_rtc_probe(struct platform_device *pdev) 364static int __devinit m48t59_rtc_probe(struct platform_device *pdev)
@@ -464,7 +465,7 @@ static int __devexit m48t59_rtc_remove(struct platform_device *pdev)
464 return 0; 465 return 0;
465} 466}
466 467
467static struct platform_driver m48t59_rtc_platdrv = { 468static struct platform_driver m48t59_rtc_driver = {
468 .driver = { 469 .driver = {
469 .name = "rtc-m48t59", 470 .name = "rtc-m48t59",
470 .owner = THIS_MODULE, 471 .owner = THIS_MODULE,
@@ -475,12 +476,12 @@ static struct platform_driver m48t59_rtc_platdrv = {
475 476
476static int __init m48t59_rtc_init(void) 477static int __init m48t59_rtc_init(void)
477{ 478{
478 return platform_driver_register(&m48t59_rtc_platdrv); 479 return platform_driver_register(&m48t59_rtc_driver);
479} 480}
480 481
481static void __exit m48t59_rtc_exit(void) 482static void __exit m48t59_rtc_exit(void)
482{ 483{
483 platform_driver_unregister(&m48t59_rtc_platdrv); 484 platform_driver_unregister(&m48t59_rtc_driver);
484} 485}
485 486
486module_init(m48t59_rtc_init); 487module_init(m48t59_rtc_init);
diff --git a/drivers/rtc/rtc-max6900.c b/drivers/rtc/rtc-max6900.c
index a1cd448639c9..7683412970c4 100644
--- a/drivers/rtc/rtc-max6900.c
+++ b/drivers/rtc/rtc-max6900.c
@@ -54,7 +54,7 @@
54 54
55#define MAX6900_I2C_ADDR 0xa0 55#define MAX6900_I2C_ADDR 0xa0
56 56
57static unsigned short normal_i2c[] = { 57static const unsigned short normal_i2c[] = {
58 MAX6900_I2C_ADDR >> 1, 58 MAX6900_I2C_ADDR >> 1,
59 I2C_CLIENT_END 59 I2C_CLIENT_END
60}; 60};
diff --git a/drivers/rtc/rtc-max6902.c b/drivers/rtc/rtc-max6902.c
index 3e183cfee10f..1f956dc5d56e 100644
--- a/drivers/rtc/rtc-max6902.c
+++ b/drivers/rtc/rtc-max6902.c
@@ -89,13 +89,9 @@ static int max6902_get_reg(struct device *dev, unsigned char address,
89 89
90 /* do the i/o */ 90 /* do the i/o */
91 status = spi_sync(spi, &message); 91 status = spi_sync(spi, &message);
92 if (status == 0)
93 status = message.status;
94 else
95 return status;
96
97 *data = chip->rx_buf[1];
98 92
93 if (status == 0)
94 *data = chip->rx_buf[1];
99 return status; 95 return status;
100} 96}
101 97
@@ -125,9 +121,7 @@ static int max6902_get_datetime(struct device *dev, struct rtc_time *dt)
125 121
126 /* do the i/o */ 122 /* do the i/o */
127 status = spi_sync(spi, &message); 123 status = spi_sync(spi, &message);
128 if (status == 0) 124 if (status)
129 status = message.status;
130 else
131 return status; 125 return status;
132 126
133 /* The chip sends data in this order: 127 /* The chip sends data in this order:
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c
index 0242d803ebe5..b3317fcc16c3 100644
--- a/drivers/rtc/rtc-pcf8563.c
+++ b/drivers/rtc/rtc-pcf8563.c
@@ -25,7 +25,7 @@
25 * located at 0x51 will pass the validation routine due to 25 * located at 0x51 will pass the validation routine due to
26 * the way the registers are implemented. 26 * the way the registers are implemented.
27 */ 27 */
28static unsigned short normal_i2c[] = { I2C_CLIENT_END }; 28static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
29 29
30/* Module parameters */ 30/* Module parameters */
31I2C_CLIENT_INSMOD; 31I2C_CLIENT_INSMOD;
diff --git a/drivers/rtc/rtc-pcf8583.c b/drivers/rtc/rtc-pcf8583.c
index 556d0e7da35b..c973ba94c422 100644
--- a/drivers/rtc/rtc-pcf8583.c
+++ b/drivers/rtc/rtc-pcf8583.c
@@ -40,7 +40,7 @@ struct pcf8583 {
40#define CTRL_ALARM 0x02 40#define CTRL_ALARM 0x02
41#define CTRL_TIMER 0x01 41#define CTRL_TIMER 0x01
42 42
43static unsigned short normal_i2c[] = { 0x50, I2C_CLIENT_END }; 43static const unsigned short normal_i2c[] = { 0x50, I2C_CLIENT_END };
44 44
45/* Module parameters */ 45/* Module parameters */
46I2C_CLIENT_INSMOD; 46I2C_CLIENT_INSMOD;
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 8c1012b432bb..e2041b4d0c85 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -542,8 +542,6 @@ static int s3c_rtc_probe(struct platform_device *pdev)
542 542
543/* RTC Power management control */ 543/* RTC Power management control */
544 544
545static struct timespec s3c_rtc_delta;
546
547static int ticnt_save; 545static int ticnt_save;
548 546
549static int s3c_rtc_suspend(struct platform_device *pdev, pm_message_t state) 547static int s3c_rtc_suspend(struct platform_device *pdev, pm_message_t state)
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index 6f1e9a9804bc..2eb38520f0c8 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -337,6 +337,8 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
337 if (IS_ERR(rtc)) 337 if (IS_ERR(rtc))
338 return PTR_ERR(rtc); 338 return PTR_ERR(rtc);
339 339
340 device_init_wakeup(&pdev->dev, 1);
341
340 platform_set_drvdata(pdev, rtc); 342 platform_set_drvdata(pdev, rtc);
341 343
342 return 0; 344 return 0;
@@ -352,9 +354,38 @@ static int sa1100_rtc_remove(struct platform_device *pdev)
352 return 0; 354 return 0;
353} 355}
354 356
357#ifdef CONFIG_PM
358static int sa1100_rtc_suspend(struct platform_device *pdev, pm_message_t state)
359{
360 if (pdev->dev.power.power_state.event != state.event) {
361 if (state.event == PM_EVENT_SUSPEND &&
362 device_may_wakeup(&pdev->dev))
363 enable_irq_wake(IRQ_RTCAlrm);
364
365 pdev->dev.power.power_state = state;
366 }
367 return 0;
368}
369
370static int sa1100_rtc_resume(struct platform_device *pdev)
371{
372 if (pdev->dev.power.power_state.event != PM_EVENT_ON) {
373 if (device_may_wakeup(&pdev->dev))
374 disable_irq_wake(IRQ_RTCAlrm);
375 pdev->dev.power.power_state = PMSG_ON;
376 }
377 return 0;
378}
379#else
380#define sa1100_rtc_suspend NULL
381#define sa1100_rtc_resume NULL
382#endif
383
355static struct platform_driver sa1100_rtc_driver = { 384static struct platform_driver sa1100_rtc_driver = {
356 .probe = sa1100_rtc_probe, 385 .probe = sa1100_rtc_probe,
357 .remove = sa1100_rtc_remove, 386 .remove = sa1100_rtc_remove,
387 .suspend = sa1100_rtc_suspend,
388 .resume = sa1100_rtc_resume,
358 .driver = { 389 .driver = {
359 .name = "sa1100-rtc", 390 .name = "sa1100-rtc",
360 }, 391 },
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index 78277a118b67..c1d6a1880ccf 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -26,17 +26,7 @@
26#include <asm/rtc.h> 26#include <asm/rtc.h>
27 27
28#define DRV_NAME "sh-rtc" 28#define DRV_NAME "sh-rtc"
29#define DRV_VERSION "0.1.3" 29#define DRV_VERSION "0.1.6"
30
31#ifdef CONFIG_CPU_SH3
32#define rtc_reg_size sizeof(u16)
33#define RTC_BIT_INVERTED 0 /* No bug on SH7708, SH7709A */
34#define RTC_DEF_CAPABILITIES 0UL
35#elif defined(CONFIG_CPU_SH4)
36#define rtc_reg_size sizeof(u32)
37#define RTC_BIT_INVERTED 0x40 /* bug on SH7750, SH7750S */
38#define RTC_DEF_CAPABILITIES RTC_CAP_4_DIGIT_YEAR
39#endif
40 30
41#define RTC_REG(r) ((r) * rtc_reg_size) 31#define RTC_REG(r) ((r) * rtc_reg_size)
42 32
@@ -58,6 +48,18 @@
58#define RCR1 RTC_REG(14) /* Control */ 48#define RCR1 RTC_REG(14) /* Control */
59#define RCR2 RTC_REG(15) /* Control */ 49#define RCR2 RTC_REG(15) /* Control */
60 50
51/*
52 * Note on RYRAR and RCR3: Up until this point most of the register
53 * definitions are consistent across all of the available parts. However,
54 * the placement of the optional RYRAR and RCR3 (the RYRAR control
55 * register used to control RYRCNT/RYRAR compare) varies considerably
56 * across various parts, occasionally being mapped in to a completely
57 * unrelated address space. For proper RYRAR support a separate resource
58 * would have to be handed off, but as this is purely optional in
59 * practice, we simply opt not to support it, thereby keeping the code
60 * quite a bit more simplified.
61 */
62
61/* ALARM Bits - or with BCD encoded value */ 63/* ALARM Bits - or with BCD encoded value */
62#define AR_ENB 0x80 /* Enable for alarm cmp */ 64#define AR_ENB 0x80 /* Enable for alarm cmp */
63 65
@@ -351,8 +353,10 @@ static int sh_rtc_read_time(struct device *dev, struct rtc_time *tm)
351 tm->tm_sec, tm->tm_min, tm->tm_hour, 353 tm->tm_sec, tm->tm_min, tm->tm_hour,
352 tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_wday); 354 tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_wday);
353 355
354 if (rtc_valid_tm(tm) < 0) 356 if (rtc_valid_tm(tm) < 0) {
355 dev_err(dev, "invalid date\n"); 357 dev_err(dev, "invalid date\n");
358 rtc_time_to_tm(0, tm);
359 }
356 360
357 return 0; 361 return 0;
358} 362}
@@ -588,7 +592,7 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
588 592
589 rtc->rtc_dev = rtc_device_register("sh", &pdev->dev, 593 rtc->rtc_dev = rtc_device_register("sh", &pdev->dev,
590 &sh_rtc_ops, THIS_MODULE); 594 &sh_rtc_ops, THIS_MODULE);
591 if (IS_ERR(rtc)) { 595 if (IS_ERR(rtc->rtc_dev)) {
592 ret = PTR_ERR(rtc->rtc_dev); 596 ret = PTR_ERR(rtc->rtc_dev);
593 goto err_badmap; 597 goto err_badmap;
594 } 598 }
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c
index 8288b6b2bf2b..a265da7c6ff8 100644
--- a/drivers/rtc/rtc-stk17ta8.c
+++ b/drivers/rtc/rtc-stk17ta8.c
@@ -291,7 +291,7 @@ static ssize_t stk17ta8_nvram_write(struct kobject *kobj,
291static struct bin_attribute stk17ta8_nvram_attr = { 291static struct bin_attribute stk17ta8_nvram_attr = {
292 .attr = { 292 .attr = {
293 .name = "nvram", 293 .name = "nvram",
294 .mode = S_IRUGO | S_IWUGO, 294 .mode = S_IRUGO | S_IWUSR,
295 .owner = THIS_MODULE, 295 .owner = THIS_MODULE,
296 }, 296 },
297 .size = RTC_OFFSET, 297 .size = RTC_OFFSET,
diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c
index b3fae357ca49..b90fb1866ce9 100644
--- a/drivers/rtc/rtc-x1205.c
+++ b/drivers/rtc/rtc-x1205.c
@@ -32,7 +32,7 @@
32 * unknown chips, the user must explicitly set the probe parameter. 32 * unknown chips, the user must explicitly set the probe parameter.
33 */ 33 */
34 34
35static unsigned short normal_i2c[] = { I2C_CLIENT_END }; 35static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
36 36
37/* Insmod parameters */ 37/* Insmod parameters */
38I2C_CLIENT_INSMOD; 38I2C_CLIENT_INSMOD;