rtc: wilco-ec: Remove yday and wday calculations
PATCH v2 1/2 rtc: wilco-ec: Remove yday and wday calculations
The tm_yday and tm_wday fields are not used by userspace, so since they aren't needed within the driver, don't bother calculating them. This is especially needed since the rtc_year_days() call was crashing if the HW returned an invalid time.
--- drivers/rtc/rtc-wilco-ec.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/rtc/rtc-wilco-ec.c +0 -4
@@ -110,10 +110,6 @@ static int wilco_ec_rtc_read(struct device *dev, struct rtc_time *tm) tm->tm_mday = rtc.day; tm->tm_mon = rtc.month -1 ; tm->tm_year = rtc.year + (rtc.century *100 ) -1900 ; - tm->tm_yday =rtc_year_days (tm->tm_mday, tm->tm_mon, tm->tm_year); - -/* Don't compute day of week, we don't need it. */ - tm->tm_wday =-1 ;return 0 ; }
Signature · 1 line
2.21.0
PATCH v2 2/2 rtc: wilco-ec: Fix license to GPL from GPLv2
--- drivers/rtc/rtc-wilco-ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-wilco-ec.c +1 -1
@@ -184,5 +184,5 @@ module_platform_driver(wilco_ec_rtc_driver);MODULE_ALIAS ("platform:rtc-wilco-ec" );MODULE_AUTHOR ("Nick Crews <[email protected]>" ); -MODULE_LICENSE ("GPL v2" ); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("Wilco EC RTC driver" );
Signature · 1 line
2.21.0
Re: [PATCH v2 2/2] rtc: wilco-ec: Fix license to GPL from GPLv2
Quoted 10 lines · Nick Crews
Signed-off-by Nick Crews <[email protected]>--- drivers/rtc/rtc-wilco-ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/rtc-wilco-ec.c +0
-0
drivers/rtc/rtc-wilco-ec.c module_platform_driver(wilco_ec_rtc_driver); · line 188
Quoted 6 lines
drivers/rtc/rtc-wilco-ec.c +1
-1@@ -184,5 +184,5 @@ module_platform_driver(wilco_ec_rtc_driver);MODULE_ALIAS ("platform:rtc-wilco-ec" );MODULE_AUTHOR ("Nick Crews <[email protected]>" ); -MODULE_LICENSE ("GPL v2" ); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("Wilco EC RTC driver" );
File spdx header says GPL-2.0, this change would make it inconsistent with that...
Best regards,
Pavel
Alexandre Belloni
maintainerRe: [PATCH v2 2/2] rtc: wilco-ec: Fix license to GPL from GPLv2
Quoted 12 lines · Pavel Machek
Quoted 11 lines · Nick Crews
Signed-off-by Nick Crews <[email protected]>--- drivers/rtc/rtc-wilco-ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/rtc-wilco-ec.c +0
-0@@ -184,5 +184,5 @@ module_platform_driver(wilco_ec_rtc_driver);
Quoted 8 lines
drivers/rtc/rtc-wilco-ec.c module_platform_driver(wilco_ec_rtc_driver); · line 188
Quoted 5 lines
drivers/rtc/rtc-wilco-ec.c +1
-1MODULE_ALIAS ("platform:rtc-wilco-ec" );MODULE_AUTHOR ("Nick Crews <[email protected]>" ); -MODULE_LICENSE ("GPL v2" ); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("Wilco EC RTC driver" );File spdx header says GPL-2.0, this change would make it inconsistent with that...
Commit bf7fbeeae6db ("module: Cure the MODULE_LICENSE "GPL" vs. "GPL v2" bogosity") doesn't agree with you (but I was surprised too).
Signature · 3 lines
Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH v2 2/2] rtc: wilco-ec: Fix license to GPL from GPLv2
Would you like me to change this patch at all? Perhaps reference bf7fbeeae6db in the commit description? I probably should have done that since the beginning, I just couldn't find bf7fbeeae6db at first.
Thanks,
Nick
Quoted 31 lines · Alexandre Belloni
Quoted 12 lines · Pavel Machek
Quoted 11 lines · Nick Crews
Signed-off-by Nick Crews <[email protected]>--- drivers/rtc/rtc-wilco-ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/rtc-wilco-ec.c +0
-0@@ -184,5 +184,5 @@ module_platform_driver(wilco_ec_rtc_driver);Quoted 8 lines
drivers/rtc/rtc-wilco-ec.c module_platform_driver(wilco_ec_rtc_driver); · line 188
Quoted 5 lines
drivers/rtc/rtc-wilco-ec.c +1
-1MODULE_ALIAS ("platform:rtc-wilco-ec" );MODULE_AUTHOR ("Nick Crews <[email protected]>" ); -MODULE_LICENSE ("GPL v2" ); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("Wilco EC RTC driver" );File spdx header says GPL-2.0, this change would make it inconsistent with that...
Commit
bf7fbeeae6db("module: Cure theMODULE_LICENSE"GPL" vs. "GPL v2" bogosity") doesn't agree with you (but I was surprised too).--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Re: [PATCH v2 2/2] rtc: wilco-ec: Fix license to GPL from GPLv2
In reply to Alexandre BelloniQuoted 21 lines · Alexandre Belloni
Quoted 12 lines · Pavel Machek
Quoted 11 lines · Nick Crews
Signed-off-by Nick Crews <[email protected]>--- drivers/rtc/rtc-wilco-ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/rtc-wilco-ec.c +0
-0@@ -184,5 +184,5 @@ module_platform_driver(wilco_ec_rtc_driver);Quoted 7 lines
drivers/rtc/rtc-wilco-ec.c module_platform_driver(wilco_ec_rtc_driver); · line 188
Quoted 5 lines
drivers/rtc/rtc-wilco-ec.c +1
-1MODULE_ALIAS ("platform:rtc-wilco-ec" );MODULE_AUTHOR ("Nick Crews <[email protected]>" ); -MODULE_LICENSE ("GPL v2" ); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("Wilco EC RTC driver" );File spdx header says GPL-2.0, this change would make it inconsistent with that...
Quoted 2 lines
Commit
bf7fbeeae6db("module: Cure theMODULE_LICENSE"GPL" vs. "GPL v2" bogosity") doesn't agree with you (but I was surprised too).
Still don't get it. bf7fbeeae6db makes MODULE_LICENSE less useful, and declares "GPL" == "GPL v2" in MODULE_LICENSE. So.. this change is no longer wrong, it is just unneccessary...? Why do it? It is not a fix as a subject line says...
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH v2 2/2] rtc: wilco-ec: Fix license to GPL from GPLv2
Quoted 23 lines · Pavel Machek
Quoted 21 lines · Alexandre Belloni
Quoted 19 lines · Pavel Machek
Quoted 10 lines · Nick Crews
Signed-off-by Nick Crews <[email protected]>--- drivers/rtc/rtc-wilco-ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/rtc-wilco-ec.c +0
-0drivers/rtc/rtc-wilco-ec.c module_platform_driver(wilco_ec_rtc_driver); · line 188
Quoted 6 lines
drivers/rtc/rtc-wilco-ec.c +1
-1@@ -184,5 +184,5 @@ module_platform_driver(wilco_ec_rtc_driver);MODULE_ALIAS ("platform:rtc-wilco-ec" );MODULE_AUTHOR ("Nick Crews <[email protected]>" ); -MODULE_LICENSE ("GPL v2" ); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("Wilco EC RTC driver" );File spdx header says GPL-2.0, this change would make it inconsistent with that...
Quoted 7 lines
Quoted 2 lines
Commit
bf7fbeeae6db("module: Cure theMODULE_LICENSE"GPL" vs. "GPL v2" bogosity") doesn't agree with you (but I was surprised too).Still don't get it.
bf7fbeeae6dbmakesMODULE_LICENSEless useful, and declares "GPL" == "GPL v2" inMODULE_LICENSE. So.. this change is no longer wrong, it is just unneccessary...? Why do it? It is not a fix as a subject line says...
All new modules should have the plain "GPL", or at least that's what I was told when I submitted a patch adding a "GPL v2" license. Therefore I assumed that if the distinction was worthwhile there, I should try to make existing code consistent too. Sounds fine to me to drop this though, unless anyone else has strong opinions,
Quoted 5 lines
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 16 lines · Nick Crews
The
tm_ydayandtm_wdayfields are not used by userspace, so since they aren't needed within the driver, don't bother calculating them. This is especially needed since thertc_year_days()call was crashing if the HW returned an invalid time.Signed-off-by Nick Crews <[email protected]>--- drivers/rtc/rtc-wilco-ec.c | 4 ---- 1 file changed, 4 deletions(-)drivers/rtc/rtc-wilco-ec.c +0
-0
drivers/rtc/rtc-wilco-ec.c static int wilco_ec_rtc_read(struct device *dev, struct rtc_time *tm) · line 114
Quoted 9 lines
drivers/rtc/rtc-wilco-ec.c +0
-4@@ -110,10 +110,6 @@ static int wilco_ec_rtc_read(struct device *dev, struct rtc_time *tm) tm->tm_mday = rtc.day; tm->tm_mon = rtc.month -1 ; tm->tm_year = rtc.year + (rtc.century *100 ) -1900 ; - tm->tm_yday =rtc_year_days (tm->tm_mday, tm->tm_mon, tm->tm_year); - -/* Don't compute day of week, we don't need it. */ - tm->tm_wday =-1 ;return 0 ;
Are you sure? It would be bad to pass unititialized memory to userspace...
If userspace does not need those fields, why are they there?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Alexandre Belloni
maintainerQuoted 25 lines · Pavel Machek
Quoted 24 lines · Nick Crews
The
tm_ydayandtm_wdayfields are not used by userspace, so since they aren't needed within the driver, don't bother calculating them. This is especially needed since thertc_year_days()call was crashing if the HW returned an invalid time.Signed-off-by Nick Crews <[email protected]>--- drivers/rtc/rtc-wilco-ec.c | 4 ---- 1 file changed, 4 deletions(-)drivers/rtc/rtc-wilco-ec.c +0
-4@@ -110,10 +110,6 @@ static int wilco_ec_rtc_read(struct device *dev, struct rtc_time *tm) tm->tm_mday = rtc.day; tm->tm_mon = rtc.month -1 ; tm->tm_year = rtc.year + (rtc.century *100 ) -1900 ; - tm->tm_yday =rtc_year_days (tm->tm_mday, tm->tm_mon, tm->tm_year); - -/* Don't compute day of week, we don't need it. */ - tm->tm_wday =-1 ;
Quoted 4 lines
drivers/rtc/rtc-wilco-ec.c static int wilco_ec_rtc_read(struct device *dev, struct rtc_time *tm) · line 114
Quoted 1 line
drivers/rtc/rtc-wilco-ec.c +0
-0return 0 ;Are you sure? It would be bad to pass unititialized memory to userspace...
This problem doesn't exist because userspace is passing the memory, not the other way around.
Quoted 2 lines
If userspace does not need those fields, why are they there?
This is coming from struct tm, it is part of C89 but I think I was not born when this decision was made. man rtc properly reports that those fields are unused and no userspace tools are actually making use of them. Nobody cares about the broken down representation of the time. What is done is use the ioctl then mktime to have a UNIX timestamp.
"The mktime function ignores the specified contents of the tm_wday, tm_yday, tm_gmtoff, and tm_zone members of the broken-down time structure. It uses the values of the other components to determine the calendar time; it’s permissible for these components to have unnormalized values outside their normal ranges. The last thing that mktime does is adjust the components of the brokentime structure, including the members that were initially ignored."
Signature · 3 lines
Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Quoted 44 lines · Alexandre Belloni
Quoted 25 lines · Pavel Machek
Quoted 24 lines · Nick Crews
The
tm_ydayandtm_wdayfields are not used by userspace, so since they aren't needed within the driver, don't bother calculating them. This is especially needed since thertc_year_days()call was crashing if the HW returned an invalid time.Signed-off-by Nick Crews <[email protected]>--- drivers/rtc/rtc-wilco-ec.c | 4 ---- 1 file changed, 4 deletions(-)drivers/rtc/rtc-wilco-ec.c +0
-4@@ -110,10 +110,6 @@ static int wilco_ec_rtc_read(struct device *dev, struct rtc_time *tm) tm->tm_mday = rtc.day; tm->tm_mon = rtc.month -1 ; tm->tm_year = rtc.year + (rtc.century *100 ) -1900 ; - tm->tm_yday =rtc_year_days (tm->tm_mday, tm->tm_mon, tm->tm_year); - -/* Don't compute day of week, we don't need it. */ - tm->tm_wday =-1 ;Quoted 4 lines
drivers/rtc/rtc-wilco-ec.c static int wilco_ec_rtc_read(struct device *dev, struct rtc_time *tm) · line 114
Quoted 1 line
drivers/rtc/rtc-wilco-ec.c +0
-0return 0 ;Are you sure? It would be bad to pass unititialized memory to userspace...
This problem doesn't exist because userspace is passing the memory, not the other way around.
Quoted 2 lines
If userspace does not need those fields, why are they there?
This is coming from struct tm, it is part of C89 but I think I was not born when this decision was made. man rtc properly reports that those fields are unused and no userspace tools are actually making use of them. Nobody cares about the broken down representation of the time. What is done is use the ioctl then mktime to have a UNIX timestamp.
Quoted 7 lines
"The mktime function ignores the specified contents of the
tm_wday,tm_yday,tm_gmtoff, andtm_zonemembers of the broken-down time structure. It uses the values of the other components to determine the calendar time; it’s permissible for these components to have unnormalized values outside their normal ranges. The last thing that mktime does is adjust the components of the brokentime structure, including the members that were initially ignored."
This is very non-obvious and I only knew this from talking to you, Alexandre. Perhaps we should add this note to the RTC core, such as in the description for rtc_class_ops?
For this patch, do you want me to make any further changes?
Thanks,
Nick
Quoted 6 lines
--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Alexandre Belloni
maintainerQuoted 14 lines · Nick Crews
Quoted 6 lines
This is coming from struct tm, it is part of C89 but I think I was not born when this decision was made. man rtc properly reports that those fields are unused and no userspace tools are actually making use of them. Nobody cares about the broken down representation of the time. What is done is use the ioctl then mktime to have a UNIX timestamp.
Quoted 7 lines
"The mktime function ignores the specified contents of the
tm_wday,tm_yday,tm_gmtoff, andtm_zonemembers of the broken-down time structure. It uses the values of the other components to determine the calendar time; it’s permissible for these components to have unnormalized values outside their normal ranges. The last thing that mktime does is adjust the components of the brokentime structure, including the members that were initially ignored."
Quoted 4 lines
This is very non-obvious and I only knew this from talking to you, Alexandre. Perhaps we should add this note to the RTC core, such as in the description for
rtc_class_ops?
I'm planning to add documentation on what should be done in an RTC driver, I'll ensure to add something on this topic.
Quoted 2 lines
For this patch, do you want me to make any further changes?
No need for any changes, however, I can't apply it right now because we are in the middle of the merge window.
Signature · 3 lines
Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Hi Alexandre,
Sorry to be a pain, but I passed this by some other Chrome OS kernel engineers, and when the HW gives a bogus time we want logging at a more severe level than the dev_dbg() call in the core, so I'm going to send another revision. It's going to require duplicated calls to rtc_valid_tm(), but we feel that it is required.
Thanks,
Nick
Quoted 35 lines · Alexandre Belloni
Quoted 14 lines · Nick Crews
Quoted 6 lines
This is coming from struct tm, it is part of C89 but I think I was not born when this decision was made. man rtc properly reports that those fields are unused and no userspace tools are actually making use of them. Nobody cares about the broken down representation of the time. What is done is use the ioctl then mktime to have a UNIX timestamp.
Quoted 7 lines
"The mktime function ignores the specified contents of the
tm_wday,tm_yday,tm_gmtoff, andtm_zonemembers of the broken-down time structure. It uses the values of the other components to determine the calendar time; it’s permissible for these components to have unnormalized values outside their normal ranges. The last thing that mktime does is adjust the components of the brokentime structure, including the members that were initially ignored."Quoted 4 lines
This is very non-obvious and I only knew this from talking to you, Alexandre. Perhaps we should add this note to the RTC core, such as in the description for
rtc_class_ops?I'm planning to add documentation on what should be done in an RTC driver, I'll ensure to add something on this topic.
Quoted 2 lines
For this patch, do you want me to make any further changes?
No need for any changes, however, I can't apply it right now because we are in the middle of the merge window.
--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com