rtc: remove redundant code in rtc_reset
cover rtc: remove redundant code in rtc_reset
Someone at $dayjob pointed out some inconsistent behaviour between the ds1307 and the ds1337 rtc drivers for an old version of u-boot. Basically with ds1307 "date reset" changed the time whereas for the ds1337 it did not.
I was about to send a patch to add code to ds1337 when I noticed Marek's commit 1a1fa2406689 ("rtc: Set valid date after reset"). This meant that newer versions of u-boot did indeed have consistent behaviour for "date reset" regardless of the rtc driver but now there were a handful of drivers that had redundant code to do something that is now handled in the generic layers.
This series removes the now redundant code from the affected drivers. I've compile tested these changes but I only have access to hardware with ds1307/ds1337 (or variants thereof) so I haven't been able to test the last 4 patches on actual hardware.
Chris Packham (5):
rtc: ds1307: remove redundant code in rtc_reset
rtc: ds1374: remove redundant code in rtc_reset
rtc: mx27rtc: remove redundant code in rtc_reset
rtc: rs5c372: remove redundant code in rtc_reset
rtc: rx8025: remove redundant code in rtc_reset
drivers/rtc/ds1307.c | 33 --------------------------------- drivers/rtc/ds1374.c | 15 --------------- drivers/rtc/mx27rtc.c | 6 +----- drivers/rtc/rs5c372.c | 24 +----------------------- drivers/rtc/rx8025.c | 18 +----------------- 5 files changed, 3 insertions(+), 93 deletions(-)
Signature · 1 line
2.16.2
PATCH 1/5 rtc: ds1307: remove redundant code in rtc_reset
As of commit 1a1fa2406689 ("rtc: Set valid date after reset") the command "date reset" will set the date/time to 2000-01-01 0:00:00 after calling rtc_reset(). This means that the ds1307 implementation of rtc_reset() doesn't need to call rtc_set().
---
drivers/rtc/ds1307.c | 33 --------------------------------- 1 file changed, 33 deletions(-)
drivers/rtc/ds1307.c +0 -33
@@ -184,25 +184,8 @@ int rtc_set (struct rtc_time *tmp)*/ void rtc_reset (void ) { -struct rtc_time tmp; -rtc_write (RTC_SEC_REG_ADDR ,0x00 );/* clearing Clock Halt */ rtc_write (RTC_CTL_REG_ADDR ,RTC_CTL_BIT_SQWE |RTC_CTL_BIT_RS1 |RTC_CTL_BIT_RS0 ); - - tmp.tm_year =1970 ; - tmp.tm_mon =1 ; - tmp.tm_mday=1 ; - tmp.tm_hour =0 ; - tmp.tm_min =0 ; - tmp.tm_sec =0 ; - -rtc_set (&tmp); - -printf ("RTC: %4d-%02d-%02d %2d:%02d:%02d UTC\n" , - tmp.tm_year, tmp.tm_mon, tmp.tm_mday, - tmp.tm_hour, tmp.tm_min, tmp.tm_sec); - -return ; }
@@ -321,14 +304,6 @@ read_rtc:static int ds1307_rtc_reset (struct udevice *dev) {int ret; -struct rtc_time tmp = { - .tm_year =1970 , - .tm_mon =1 , - .tm_mday =1 , - .tm_hour =0 , - .tm_min =0 , - .tm_sec =0 , - };/* clear Clock Halt */ ret =dm_i2c_reg_write (dev,RTC_SEC_REG_ADDR ,0x00 );
@@ -340,14 +315,6 @@ static int ds1307_rtc_reset(struct udevice *dev)if (ret <0 )return ret; - ret =ds1307_rtc_set (dev, &tmp); -if (ret <0 ) -return ret; - -debug ("RTC: %4d-%02d-%02d %2d:%02d:%02d UTC\n" , - tmp.tm_year, tmp.tm_mon, tmp.tm_mday, - tmp.tm_hour, tmp.tm_min, tmp.tm_sec); -return 0 ; }
Signature · 1 line
2.16.2
PATCH 1/5 rtc: ds1307: remove redundant code in rtc_reset
Quoted 10 lines · Chris Packham
As of commit
1a1fa2406689("rtc: Set valid date after reset") the command "date reset" will set the date/time to 2000-01-01 0:00:00 after callingrtc_reset(). This means that the ds1307 implementation ofrtc_reset()doesn't need to callrtc_set().Signed-off-by Chris Packham <[email protected]>---
drivers/rtc/ds1307.c | 33 --------------------------------- 1 file changed, 33 deletions(-)
PATCH 1/5 rtc: ds1307: remove redundant code in rtc_reset
In reply to Chris PackhamQuoted 7 lines · Chris Packham
As of commit
1a1fa2406689("rtc: Set valid date after reset") the command "date reset" will set the date/time to 2000-01-01 0:00:00 after callingrtc_reset(). This means that the ds1307 implementation ofrtc_reset()doesn't need to callrtc_set().Signed-off-by Chris Packham <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180407/b5c74b8c/attachment.sig>
PATCH 2/5 rtc: ds1374: remove redundant code in rtc_reset
In reply to Chris PackhamAs of commit 1a1fa2406689 ("rtc: Set valid date after reset") the command "date reset" will set the date/time to 2000-01-01 0:00:00 after calling rtc_reset(). This means that the ds1374 implementation of rtc_reset() doesn't need to call rtc_set().
---
drivers/rtc/ds1374.c | 15 --------------- 1 file changed, 15 deletions(-)
drivers/rtc/ds1374.c +0 -15
@@ -172,8 +172,6 @@ int rtc_set (struct rtc_time *tmp){*/ void rtc_reset (void ){ -struct rtc_time tmp; -/* clear status flags */ rtc_write (RTC_SR_ADDR , (RTC_SR_BIT_AF |RTC_SR_BIT_OSF ), false);/* clearing OSF and AF */
@@ -189,19 +187,6 @@ void rtc_reset (void){ |RTC_CTL_BIT_BBSQW), true);/* disable WD/ALM, WDSTR set to INT-pin,set BBSQW and SQW to 32k - set to 1 */ - tmp.tm_year =1970 ; - tmp.tm_mon =1 ; - tmp.tm_mday=1 ; - tmp.tm_hour =0 ; - tmp.tm_min =0 ; - tmp.tm_sec =0 ; - -rtc_set (&tmp); - -printf ("RTC: %4d-%02d-%02d %2d:%02d:%02d UTC\n" , - tmp.tm_year, tmp.tm_mon, tmp.tm_mday, - tmp.tm_hour, tmp.tm_min, tmp.tm_sec); -rtc_write (RTC_WD_ALM_CNT_BYTE2_ADDR ,0xAC , true);rtc_write (RTC_WD_ALM_CNT_BYTE1_ADDR ,0xDE , true);rtc_write (RTC_WD_ALM_CNT_BYTE2_ADDR ,0xAD , true);
Signature · 1 line
2.16.2
PATCH 2/5 rtc: ds1374: remove redundant code in rtc_reset
Quoted 6 lines · Chris Packham
As of commit
1a1fa2406689("rtc: Set valid date after reset") the command "date reset" will set the date/time to 2000-01-01 0:00:00 after callingrtc_reset(). This means that the ds1374 implementation ofrtc_reset()doesn't need to callrtc_set().Signed-off-by Chris Packham <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180407/c5e96c25/attachment.sig>
PATCH 3/5 rtc: mx27rtc: remove redundant code in rtc_reset
In reply to Chris PackhamAs of commit 1a1fa2406689 ("rtc: Set valid date after reset") the command "date reset" will set the date/time to 2000-01-01 0:00:00 after calling rtc_reset(). This means that the mx27rtc implementation of rtc_reset() can be an empty stub function.
---
drivers/rtc/mx27rtc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/rtc/mx27rtc.c +1 -5
@@ -61,9 +61,5 @@ int rtc_set(struct rtc_time *time)void rtc_reset (void ) { -struct rtc_regs *rtc_regs = (struct rtc_regs *)IMX_RTC_BASE ; - -writel (0 , &rtc_regs->dayr); -writel (0 , &rtc_regs->hourmin); -writel (0 , &rtc_regs->seconds); +/* nothing to do */ }
Signature · 1 line
2.16.2
PATCH 3/5 rtc: mx27rtc: remove redundant code in rtc_reset
Quoted 6 lines · Chris Packham
As of commit
1a1fa2406689("rtc: Set valid date after reset") the command "date reset" will set the date/time to 2000-01-01 0:00:00 after callingrtc_reset(). This means that the mx27rtc implementation ofrtc_reset()can be an empty stub function.Signed-off-by Chris Packham <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180407/74beb6cb/attachment.sig>
PATCH 4/5 rtc: rs5c372: remove redundant code in rtc_reset
In reply to Chris PackhamAs of commit 1a1fa2406689 ("rtc: Set valid date after reset") the command "date reset" will set the date/time to 2000-01-01 0:00:00 after calling rtc_reset(). This means that the rs5c372 implementation of rtc_reset() does not need to call rtc_set().
---
drivers/rtc/rs5c372.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-)
drivers/rtc/rs5c372.c +1 -23
@@ -247,35 +247,13 @@ int rtc_set (struct rtc_time *tmp) }/* -* Reset the RTC. We set the date back to 1970-01-01. +* Reset the RTC. */ void rtc_reset (void ) { -struct rtc_time tmp; -if (!setup_done)rs5c372_enable (); - -if (!setup_done) -return ; - - tmp.tm_year =1970 ; - tmp.tm_mon =1 ; -/* Jan. 1, 1970 was a Thursday */ - tmp.tm_wday=4 ; - tmp.tm_mday=1 ; - tmp.tm_hour =0 ; - tmp.tm_min =0 ; - tmp.tm_sec =0 ; - -rtc_set (&tmp); - -printf ("RTC: %4d-%02d-%02d %2d:%02d:%02d UTC\n" , - tmp.tm_year, tmp.tm_mon, tmp.tm_mday, - tmp.tm_hour, tmp.tm_min, tmp.tm_sec); - -return ; }#endif
Signature · 1 line
2.16.2
PATCH 4/5 rtc: rs5c372: remove redundant code in rtc_reset
Quoted 6 lines · Chris Packham
As of commit
1a1fa2406689("rtc: Set valid date after reset") the command "date reset" will set the date/time to 2000-01-01 0:00:00 after callingrtc_reset(). This means that the rs5c372 implementation ofrtc_reset()does not need to callrtc_set().Signed-off-by Chris Packham <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180407/72b17494/attachment.sig>
PATCH 5/5 rtc: rx8025: remove redundant code in rtc_reset
In reply to Chris PackhamAs of commit 1a1fa2406689 ("rtc: Set valid date after reset") the command "date reset" will set the date/time to 2000-01-01 0:00:00 after calling rtc_reset(). This means that the rx8025 implementation of rtc_reset() does not need to call rtc_set().
---
drivers/rtc/rx8025.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-)
drivers/rtc/rx8025.c +1 -17
@@ -163,11 +163,10 @@ int rtc_set (struct rtc_time *tmp) }/* -* Reset the RTC. We setting the date back to 1970-01-01. +* Reset the RTC */ void rtc_reset (void ) { -struct rtc_time tmp;uchar buf[16 ];uchar ctl2;
@@ -178,21 +177,6 @@ void rtc_reset (void) ctl2 &= ~(RTC_CTL2_BIT_PON |RTC_CTL2_BIT_VDET ); ctl2 |=RTC_CTL2_BIT_XST |RTC_CTL2_BIT_VDSL ;rtc_write (RTC_CTL2_REG_ADDR , ctl2); - - tmp.tm_year =1970 ; - tmp.tm_mon =1 ; - tmp.tm_mday=1 ; - tmp.tm_hour =0 ; - tmp.tm_min =0 ; - tmp.tm_sec =0 ; - -rtc_set (&tmp); - -printf ("RTC: %4d-%02d-%02d %2d:%02d:%02d UTC\n" , - tmp.tm_year, tmp.tm_mon, tmp.tm_mday, - tmp.tm_hour, tmp.tm_min, tmp.tm_sec); - -return ; }/*
Signature · 1 line
2.16.2
PATCH 5/5 rtc: rx8025: remove redundant code in rtc_reset
Quoted 6 lines · Chris Packham
As of commit
1a1fa2406689("rtc: Set valid date after reset") the command "date reset" will set the date/time to 2000-01-01 0:00:00 after callingrtc_reset(). This means that the rx8025 implementation ofrtc_reset()does not need to callrtc_set().Signed-off-by Chris Packham <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180407/f41dcd0a/attachment.sig>