rtc: add timestamp for end of 2199
Subsystems (2)
Alexandre Belloni
maintainerPATCH 1/5 rtc: add timestamp for end of 2199
Some RTCs handle date up to 2199.
Signed-off-by Alexandre Belloni <[email protected]>
--- include/linux/rtc.h | 1 + 1 file changed, 1 insertion(+)
include/linux/rtc.h +1 -0
@@ -165,6 +165,7 @@ struct rtc_device {#define RTC_TIMESTAMP_BEGIN_2000 946684800LL/* 2000-01-01 00:00:00 */ #define RTC_TIMESTAMP_END_2063 2966371199LL/* 2063-12-31 23:59:59 */ #define RTC_TIMESTAMP_END_2099 4102444799LL/* 2099-12-31 23:59:59 */ +#define RTC_TIMESTAMP_END_2199 7258118399LL/* 2199-12-31 23:59:59 */ #define RTC_TIMESTAMP_END_9999 253402300799LL/* 9999-12-31 23:59:59 */ extern struct rtc_device *devm_rtc_device_register(struct device *dev,
Signature · 1 line
2.21.0
Alexandre Belloni
maintainerPATCH 2/5 rtc: vt8500: remove useless label
err_return doesn't do anything special, simply return instead of goto.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/rtc-vt8500.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/rtc/rtc-vt8500.c +2 -6
@@ -225,10 +225,9 @@ static int vt8500_rtc_probe(struct platform_device *pdev) vt8500_rtc->rtc =devm_rtc_device_register (&pdev->dev,"vt8500-rtc" , &vt8500_rtc_ops,THIS_MODULE );if (IS_ERR (vt8500_rtc->rtc)) { - ret =PTR_ERR (vt8500_rtc->rtc);dev_err (&pdev->dev,"Failed to register RTC device -> %d\n" , ret); - goto err_return; +return PTR_ERR (vt8500_rtc->rtc); } ret = devm_request_irq(&pdev->dev, vt8500_rtc->irq_alarm,
@@ -236,13 +235,10 @@ static int vt8500_rtc_probe(struct platform_device *pdev)if (ret <0 ) {dev_err (&pdev->dev,"can't get irq %i, err %d\n" , vt8500_rtc->irq_alarm, ret); - goto err_return; +return ret; }return 0 ; - -err_return: -return ret; }static int vt8500_rtc_remove (struct platform_device *pdev)
Signature · 1 line
2.21.0
Alexandre Belloni
maintainerPATCH 3/5 rtc: vt8500: remove superfluous error message
In reply to Alexandre BelloniThe RTC core now has error messages in case of registration failure, there is no need to have other messages in the drivers.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/rtc-vt8500.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/rtc/rtc-vt8500.c +1 -4
@@ -224,11 +224,8 @@ static int vt8500_rtc_probe(struct platform_device *pdev) vt8500_rtc->rtc =devm_rtc_device_register (&pdev->dev,"vt8500-rtc" , &vt8500_rtc_ops,THIS_MODULE ); -if (IS_ERR (vt8500_rtc->rtc)) { -dev_err (&pdev->dev, -"Failed to register RTC device -> %d\n" , ret); +if (IS_ERR (vt8500_rtc->rtc))return PTR_ERR (vt8500_rtc->rtc); - } ret =devm_request_irq (&pdev->dev, vt8500_rtc->irq_alarm, vt8500_rtc_irq,0 ,"rtc alarm" , vt8500_rtc);
Signature · 1 line
2.21.0
Alexandre Belloni
maintainerPATCH 4/5 rtc: vt8500: convert to devm_rtc_allocate_device
In reply to Alexandre BelloniThis allows further improvement of the driver.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/rtc-vt8500.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/rtc/rtc-vt8500.c +4 -3
@@ -222,11 +222,12 @@ static int vt8500_rtc_probe(struct platform_device *pdev)writel (VT8500_RTC_CR_ENABLE , vt8500_rtc->regbase +VT8500_RTC_CR ); - vt8500_rtc->rtc =devm_rtc_device_register (&pdev->dev,"vt8500-rtc" , - &vt8500_rtc_ops,THIS_MODULE ); + vt8500_rtc->rtc =devm_rtc_allocate_device (&pdev->dev);if (IS_ERR (vt8500_rtc->rtc))return PTR_ERR (vt8500_rtc->rtc); + vt8500_rtc->rtc->ops = &vt8500_rtc_ops; + ret =devm_request_irq (&pdev->dev, vt8500_rtc->irq_alarm, vt8500_rtc_irq,0 ,"rtc alarm" , vt8500_rtc);if (ret <0 ) {
@@ -235,7 +236,7 @@ static int vt8500_rtc_probe(struct platform_device *pdev)return ret; } -return 0 ; +return rtc_register_device (vt8500_rtc->rtc); }static int vt8500_rtc_remove (struct platform_device *pdev)
Signature · 1 line
2.21.0
Alexandre Belloni
maintainerPATCH 5/5 rtc: vt8500: let the core handle rtc range
In reply to Alexandre BelloniLet the rtc core check the date/time against the RTC range.
Signed-off-by Alexandre Belloni <[email protected]>
--- drivers/rtc/rtc-vt8500.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/rtc/rtc-vt8500.c +2 -6
@@ -122,12 +122,6 @@ static int vt8500_rtc_set_time(struct device *dev, struct rtc_time *tm) {struct vt8500_rtc *vt8500_rtc =dev_get_drvdata (dev); -if (tm->tm_year <100 ) { -dev_warn (dev,"Only years 2000-2199 are supported by the " -"hardware!\n" ); -return -EINVAL ; - } -writel ((bin2bcd (tm->tm_year %100 ) <<DATE_YEAR_S ) | (bin2bcd (tm->tm_mon +1 ) <<DATE_MONTH_S ) | (bin2bcd(tm->tm_mday))
@@ -227,6 +221,8 @@ static int vt8500_rtc_probe(struct platform_device *pdev)return PTR_ERR (vt8500_rtc->rtc); vt8500_rtc->rtc->ops = &vt8500_rtc_ops; + vt8500_rtc->rtc->range_min =RTC_TIMESTAMP_BEGIN_2000 ; + vt8500_rtc->rtc->range_max =RTC_TIMESTAMP_END_2199 ; ret =devm_request_irq (&pdev->dev, vt8500_rtc->irq_alarm, vt8500_rtc_irq,0 ,"rtc alarm" , vt8500_rtc);
Signature · 1 line
2.21.0