aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-ds1307.c
diff options
context:
space:
mode:
authorDavid Anders <x0132446@ti.com>2012-03-23 18:02:37 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-23 19:58:40 -0400
commit40ce972d59fcfd4979e5de04456122447b40c1cf (patch)
tree609a2480b6164eeb6586c30c5e08622e7045de66 /drivers/rtc/rtc-ds1307.c
parentb24a7267709bb0adb694364572478f919e9c7390 (diff)
rtc: ds1307: comment and format cleanup
Do some cleanup of the comment sections as well as correct some formatting issues reported by checkpatch.pl. Signed-off-by: David Anders <x0132446@ti.com> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Cc: Austin Boyle <Austin.Boyle@aviatnet.com> Cc: Alessandro Zummo <alessandro.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-ds1307.c')
-rw-r--r--drivers/rtc/rtc-ds1307.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index d4543e8730cb..84ab971978cf 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -20,7 +20,8 @@
20 20
21 21
22 22
23/* We can't determine type by probing, but if we expect pre-Linux code 23/*
24 * We can't determine type by probing, but if we expect pre-Linux code
24 * to have set the chip up as a clock (turning on the oscillator and 25 * to have set the chip up as a clock (turning on the oscillator and
25 * setting the date and time), Linux can ignore the non-clock features. 26 * setting the date and time), Linux can ignore the non-clock features.
26 * That's a natural job for a factory or repair bench. 27 * That's a natural job for a factory or repair bench.
@@ -37,7 +38,7 @@ enum ds_type {
37 mcp7941x, 38 mcp7941x,
38 rx_8025, 39 rx_8025,
39 last_ds_type /* always last */ 40 last_ds_type /* always last */
40 // rs5c372 too? different address... 41 /* rs5c372 too? different address... */
41}; 42};
42 43
43 44
@@ -59,7 +60,8 @@ enum ds_type {
59# define DS1337_BIT_CENTURY 0x80 /* in REG_MONTH */ 60# define DS1337_BIT_CENTURY 0x80 /* in REG_MONTH */
60#define DS1307_REG_YEAR 0x06 /* 00-99 */ 61#define DS1307_REG_YEAR 0x06 /* 00-99 */
61 62
62/* Other registers (control, status, alarms, trickle charge, NVRAM, etc) 63/*
64 * Other registers (control, status, alarms, trickle charge, NVRAM, etc)
63 * start at 7, and they differ a LOT. Only control and status matter for 65 * start at 7, and they differ a LOT. Only control and status matter for
64 * basic RTC date and time functionality; be careful using them. 66 * basic RTC date and time functionality; be careful using them.
65 */ 67 */
@@ -366,6 +368,11 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t)
366 | DS1340_BIT_CENTURY; 368 | DS1340_BIT_CENTURY;
367 break; 369 break;
368 case mcp7941x: 370 case mcp7941x:
371 /*
372 * these bits were cleared when preparing the date/time
373 * values and need to be set again before writing the
374 * buffer out to the device.
375 */
369 buf[DS1307_REG_SECS] |= MCP7941X_BIT_ST; 376 buf[DS1307_REG_SECS] |= MCP7941X_BIT_ST;
370 buf[DS1307_REG_WDAY] |= MCP7941X_BIT_VBATEN; 377 buf[DS1307_REG_WDAY] |= MCP7941X_BIT_VBATEN;
371 break; 378 break;
@@ -411,7 +418,8 @@ static int ds1337_read_alarm(struct device *dev, struct rtc_wkalrm *t)
411 ds1307->regs[6], ds1307->regs[7], 418 ds1307->regs[6], ds1307->regs[7],
412 ds1307->regs[8]); 419 ds1307->regs[8]);
413 420
414 /* report alarm time (ALARM1); assume 24 hour and day-of-month modes, 421 /*
422 * report alarm time (ALARM1); assume 24 hour and day-of-month modes,
415 * and that all four fields are checked matches 423 * and that all four fields are checked matches
416 */ 424 */
417 t->time.tm_sec = bcd2bin(ds1307->regs[0] & 0x7f); 425 t->time.tm_sec = bcd2bin(ds1307->regs[0] & 0x7f);
@@ -439,7 +447,7 @@ static int ds1337_read_alarm(struct device *dev, struct rtc_wkalrm *t)
439 447
440static int ds1337_set_alarm(struct device *dev, struct rtc_wkalrm *t) 448static int ds1337_set_alarm(struct device *dev, struct rtc_wkalrm *t)
441{ 449{
442 struct i2c_client *client = to_i2c_client(dev); 450 struct i2c_client *client = to_i2c_client(dev);
443 struct ds1307 *ds1307 = i2c_get_clientdata(client); 451 struct ds1307 *ds1307 = i2c_get_clientdata(client);
444 unsigned char *buf = ds1307->regs; 452 unsigned char *buf = ds1307->regs;
445 u8 control, status; 453 u8 control, status;
@@ -602,8 +610,6 @@ static struct bin_attribute nvram = {
602 610
603/*----------------------------------------------------------------------*/ 611/*----------------------------------------------------------------------*/
604 612
605static struct i2c_driver ds1307_driver;
606
607static int __devinit ds1307_probe(struct i2c_client *client, 613static int __devinit ds1307_probe(struct i2c_client *client,
608 const struct i2c_device_id *id) 614 const struct i2c_device_id *id)
609{ 615{
@@ -624,7 +630,8 @@ static int __devinit ds1307_probe(struct i2c_client *client,
624 && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) 630 && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
625 return -EIO; 631 return -EIO;
626 632
627 if (!(ds1307 = kzalloc(sizeof(struct ds1307), GFP_KERNEL))) 633 ds1307 = kzalloc(sizeof(struct ds1307), GFP_KERNEL);
634 if (!ds1307)
628 return -ENOMEM; 635 return -ENOMEM;
629 636
630 i2c_set_clientdata(client, ds1307); 637 i2c_set_clientdata(client, ds1307);
@@ -659,7 +666,8 @@ static int __devinit ds1307_probe(struct i2c_client *client,
659 if (ds1307->regs[0] & DS1337_BIT_nEOSC) 666 if (ds1307->regs[0] & DS1337_BIT_nEOSC)
660 ds1307->regs[0] &= ~DS1337_BIT_nEOSC; 667 ds1307->regs[0] &= ~DS1337_BIT_nEOSC;
661 668
662 /* Using IRQ? Disable the square wave and both alarms. 669 /*
670 * Using IRQ? Disable the square wave and both alarms.
663 * For some variants, be sure alarms can trigger when we're 671 * For some variants, be sure alarms can trigger when we're
664 * running on Vbackup (BBSQI/BBSQW) 672 * running on Vbackup (BBSQI/BBSQW)
665 */ 673 */
@@ -765,7 +773,8 @@ read_rtc:
765 goto exit_free; 773 goto exit_free;
766 } 774 }
767 775
768 /* minimal sanity checking; some chips (like DS1340) don't 776 /*
777 * minimal sanity checking; some chips (like DS1340) don't
769 * specify the extra bits as must-be-zero, but there are 778 * specify the extra bits as must-be-zero, but there are
770 * still a few values that are clearly out-of-range. 779 * still a few values that are clearly out-of-range.
771 */ 780 */
@@ -837,7 +846,8 @@ read_rtc:
837 switch (ds1307->type) { 846 switch (ds1307->type) {
838 case ds_1340: 847 case ds_1340:
839 case m41t00: 848 case m41t00:
840 /* NOTE: ignores century bits; fix before deploying 849 /*
850 * NOTE: ignores century bits; fix before deploying
841 * systems that will run through year 2100. 851 * systems that will run through year 2100.
842 */ 852 */
843 break; 853 break;
@@ -847,7 +857,8 @@ read_rtc:
847 if (!(tmp & DS1307_BIT_12HR)) 857 if (!(tmp & DS1307_BIT_12HR))
848 break; 858 break;
849 859
850 /* Be sure we're in 24 hour mode. Multi-master systems 860 /*
861 * Be sure we're in 24 hour mode. Multi-master systems
851 * take note... 862 * take note...
852 */ 863 */
853 tmp = bcd2bin(tmp & 0x1f); 864 tmp = bcd2bin(tmp & 0x1f);
@@ -902,7 +913,7 @@ exit_free:
902 913
903static int __devexit ds1307_remove(struct i2c_client *client) 914static int __devexit ds1307_remove(struct i2c_client *client)
904{ 915{
905 struct ds1307 *ds1307 = i2c_get_clientdata(client); 916 struct ds1307 *ds1307 = i2c_get_clientdata(client);
906 917
907 if (test_and_clear_bit(HAS_ALARM, &ds1307->flags)) { 918 if (test_and_clear_bit(HAS_ALARM, &ds1307->flags)) {
908 free_irq(client->irq, client); 919 free_irq(client->irq, client);