rtc: au1xxx: convert to devm_rtc_allocate_device
Alexandre Belloni
maintainerPATCH 1/4 rtc: au1xxx: convert to devm_rtc_allocate_device
This allows further improvement of the driver.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/rtc-au1xxx.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/rtc/rtc-au1xxx.c +6 -7
@@ -99,16 +99,15 @@ static int au1xtoy_rtc_probe(struct platform_device *pdev)while (alchemy_rdsys (AU1000_SYS_CNTRCTRL ) &SYS_CNTRL_C0S )msleep (1 ); - rtcdev =devm_rtc_device_register (&pdev->dev,"rtc-au1xxx" , - &au1xtoy_rtc_ops,THIS_MODULE ); -if (IS_ERR (rtcdev)) { - ret =PTR_ERR (rtcdev); - goto out_err; - } + rtcdev =devm_rtc_allocate_device (&pdev->dev); +if (IS_ERR (rtcdev)) +return PTR_ERR (rtcdev); + + rtcdev->ops = &au1xtoy_rtc_ops;platform_set_drvdata (pdev, rtcdev); -return 0 ; +return rtc_register_device (rtcdev); out_err:return ret;
Signature · 1 line
2.24.1
Alexandre Belloni
maintainerPATCH 2/4 rtc: au1xxx: remove goto label
Simplify the driver by removing the goto label as it only does return ret.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/rtc-au1xxx.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/rtc/rtc-au1xxx.c +2 -9
@@ -65,17 +65,13 @@ static int au1xtoy_rtc_probe(struct platform_device *pdev) {struct rtc_device *rtcdev;unsigned long t; -int ret; t =alchemy_rdsys (AU1000_SYS_CNTRCTRL );if (!(t &CNTR_OK )) {dev_err (&pdev->dev,"counters not working; aborting.\n" ); - ret = -ENODEV ; - goto out_err; +return -ENODEV ; } - ret = -ETIMEDOUT ; -/* set counter0 tickrate to 1Hz if necessary */ if (alchemy_rdsys (AU1000_SYS_TOYTRIM ) !=32767 ) {/* wait until hardware gives access to TRIM register */
@@ -88,7 +84,7 @@ static int au1xtoy_rtc_probe(struct platform_device *pdev)* counters are unusable. */ dev_err (&pdev->dev,"timeout waiting for access\n" ); - goto out_err; +return -ETIMEDOUT ; }/* set 1Hz TOY tick rate */
@@ -108,9 +104,6 @@ static int au1xtoy_rtc_probe(struct platform_device *pdev)platform_set_drvdata (pdev, rtcdev);return rtc_register_device (rtcdev); - -out_err: -return ret; }static struct platform_driver au1xrtc_driver = {
Signature · 1 line
2.24.1
Alexandre Belloni
maintainerPATCH 3/4 rtc: au1xxx: set range
In reply to Alexandre BelloniThe Alchemy counter0 is a 32bit seconds counter.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/rtc-au1xxx.c | 1 + 1 file changed, 1 insertion(+)
drivers/rtc/rtc-au1xxx.c +1 -0
@@ -100,6 +100,7 @@ static int au1xtoy_rtc_probe(struct platform_device *pdev)return PTR_ERR (rtcdev); rtcdev->ops = &au1xtoy_rtc_ops; + rtcdev->range_max =U32_MAX ;platform_set_drvdata (pdev, rtcdev);
Signature · 1 line
2.24.1
Alexandre Belloni
maintainerPATCH 4/4 rtc: au1xxx: switch to rtc_time64_to_tm/rtc_tm_to_time64
In reply to Alexandre BelloniCall the 64bit versions of rtc_tm time conversion.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/rtc-au1xxx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-au1xxx.c +2 -2
@@ -34,7 +34,7 @@ static int au1xtoy_rtc_read_time(struct device *dev, struct rtc_time *tm) t =alchemy_rdsys (AU1000_SYS_TOYREAD ); -rtc_time_to_tm (t, tm); +rtc_time64_to_tm (t, tm);return 0 ; }
@@ -43,7 +43,7 @@ static int au1xtoy_rtc_set_time(struct device *dev, struct rtc_time *tm) {unsigned long t; -rtc_tm_to_time (tm, &t); + t =rtc_tm_to_time64 (tm);alchemy_wrsys (t,AU1000_SYS_TOYWRITE );
Signature · 1 line
2.24.1