rtc: tx4939: remove useless test
Alexandre Belloni
maintainerPATCH 1/4 rtc: tx4939: remove useless test
The tested condition will never happen as the core always passes a fully set struct tm (using rtc_ktime_to_tm) to the .set_alarm callback.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/rtc-tx4939.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/rtc/rtc-tx4939.c +0 -7
@@ -123,13 +123,6 @@ static int tx4939_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)unsigned long sec;unsigned char buf[6 ]; -if (alrm->time.tm_sec <0 || - alrm->time.tm_min <0 || - alrm->time.tm_hour <0 || - alrm->time.tm_mday <0 || - alrm->time.tm_mon <0 || - alrm->time.tm_year <0 ) -return -EINVAL ;rtc_tm_to_time (&alrm->time, &sec); buf[0 ] =0 ; buf[1 ] =0 ;
Signature · 1 line
2.20.1
Alexandre Belloni
maintainerPATCH 2/4 rtc: tx4939: set range
The TX4939 RTC is a 48bit counter that counts two on every clock edge of 32.768 KHz oscillator clock so it counts 32bit seconds.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/rtc-tx4939.c | 1 + 1 file changed, 1 insertion(+)
drivers/rtc/rtc-tx4939.c +1 -0
@@ -276,6 +276,7 @@ static int __init tx4939_rtc_probe(struct platform_device *pdev) rtc->ops = &tx4939_rtc_ops; rtc->nvram_old_abi = true; + rtc->range_max =U32_MAX ; pdata->rtc = rtc;
Signature · 1 line
2.20.1
Alexandre Belloni
maintainerPATCH 3/4 rtc: tx4939: switch to rtc_time64_to_tm/rtc_tm_to_time64
In reply to Alexandre BelloniCall the 64bit versions of rtc_time_to_tm now that the range is enforced by the core.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/rtc-tx4939.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-tx4939.c +3 -3
@@ -111,7 +111,7 @@ static int tx4939_rtc_read_time(struct device *dev, struct rtc_time *tm)spin_unlock_irq (&pdata->lock); sec = ((unsigned long )buf[5 ] <<24 ) | (buf[4 ] <<16 ) | (buf[3 ] <<8 ) | buf[2 ]; -rtc_time_to_tm (sec, tm); +rtc_time64_to_tm (sec, tm);return 0 ; }
@@ -123,7 +123,7 @@ static int tx4939_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)unsigned long sec;unsigned char buf[6 ]; -rtc_tm_to_time (&alrm->time, &sec); + sec =rtc_tm_to_time64 (&alrm->time); buf[0 ] =0 ; buf[1 ] =0 ; buf[2 ] = sec;
@@ -166,7 +166,7 @@ static int tx4939_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)spin_unlock_irq (&pdata->lock); sec = ((unsigned long )buf[5 ] <<24 ) | (buf[4 ] <<16 ) | (buf[3 ] <<8 ) | buf[2 ]; -rtc_time_to_tm (sec, &alrm->time); +rtc_time64_to_tm (sec, &alrm->time);return rtc_valid_tm (&alrm->time); }
Signature · 1 line
2.20.1
Alexandre Belloni
maintainerPATCH 4/4 rtc: tx4939: use .set_time
In reply to Alexandre BelloniSwitch from .set_mmss to .set_time as the former is deprecated.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/rtc-tx4939.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/rtc/rtc-tx4939.c +3 -2
@@ -65,10 +65,11 @@ static int tx4939_rtc_cmd(struct tx4939_rtc_reg __iomem *rtcreg, int cmd)return 0 ; } -static int tx4939_rtc_set_mmss (struct device *dev,unsigned long secs) +static int tx4939_rtc_set_time (struct device *dev,struct rtc_time *tm) {struct tx4939rtc_plat_data *pdata =get_tx4939rtc_plat_data (dev);struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg; +unsigned long secs =rtc_tm_to_time64 (tm);int i, ret;unsigned char buf[6 ];
@@ -203,7 +204,7 @@ static const struct rtc_class_ops tx4939_rtc_ops = { .read_time = tx4939_rtc_read_time, .read_alarm = tx4939_rtc_read_alarm, .set_alarm = tx4939_rtc_set_alarm, - .set_mmss = tx4939_rtc_set_mmss, + .set_time = tx4939_rtc_set_time, .alarm_irq_enable = tx4939_rtc_alarm_irq_enable, };
Signature · 1 line
2.20.1