power: reset: ltc2952: fix float conversion error
PATCH 1/1 power: reset: ltc2952: fix float conversion error
From: Arnd Bergmann <[email protected]>
clang-14 does not like the way this driver converts a 'long double' to an integer when the target architecture disables floating point support:
drivers/power/reset/ltc2952-poweroff.c:162:28: error: expression requires 'long double' type support, but target 'x86_64-unknown-linux' does not support it
data->wde_interval = 300L * 1E6L;
^Turn this into pure integer math and make it more readable at the same time using the NSEC_PER_MSEC macro instead.
--- drivers/power/reset/ltc2952-poweroff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/reset/ltc2952-poweroff.c +2 -2
@@ -159,8 +159,8 @@ static void ltc2952_poweroff_kill(void)static void ltc2952_poweroff_default (struct ltc2952_poweroff *data) { - data->wde_interval =300L *1E6L ; - data->trigger_delay =ktime_set (2 ,500L *1E6L ); + data->wde_interval =300 *NSEC_PER_MSEC ; + data->trigger_delay =ktime_set (2 ,500 *NSEC_PER_MSEC );hrtimer_init (&data->timer_trigger,CLOCK_MONOTONIC ,HRTIMER_MODE_REL ); data->timer_trigger.function = ltc2952_poweroff_timer_trigger;
Signature · 1 line
2.29.2
Quoted 8 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
clang-14 does not like the way this driver converts a 'long double' to an integer when the target architecture disables floating point support:
drivers/power/reset/ltc2952-poweroff.c:162:28: error: expression requires 'long double' type support, but target 'x86_64-unknown-linux' does not support it
Quoted 8 lines
data->wde_interval = 300L * 1E6L; ^Turn this into pure integer math and make it more readable at the same time using the
NSEC_PER_MSECmacro instead.Fixes 6647156c00cc ("power: reset: add LTC2952 poweroff driver")Signed-off-by Arnd Bergmann <[email protected]>
Thanks for the patch! The change in clang-14 (ToT) that triggered this has had another patch on top reverting these diagnostics.
https://reviews.llvm.org/D114162
That said, this change is still worthwhile for the improved semantics, IMO.
Quoted 22 lines
--- drivers/power/reset/ltc2952-poweroff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/power/reset/ltc2952-poweroff.c +2
-3@@ -159,8 +159,8 @@ static void ltc2952_poweroff_kill(void)static void ltc2952_poweroff_default (struct ltc2952_poweroff *data) { - data->wde_interval =300L *1E6L ; - data->trigger_delay =ktime_set (2 ,500L *1E6L ); + data->wde_interval =300 *NSEC_PER_MSEC ; + data->trigger_delay =ktime_set (2 ,500 *NSEC_PER_MSEC );hrtimer_init (&data->timer_trigger,CLOCK_MONOTONIC ,HRTIMER_MODE_REL ); data->timer_trigger.function = ltc2952_poweroff_timer_trigger; --2.29.2
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 19 lines · Nick Desaulniers
Quoted 8 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
clang-14 does not like the way this driver converts a 'long double' to an integer when the target architecture disables floating point support:
drivers/power/reset/ltc2952-poweroff.c:162:28: error: expression requires 'long double' type support, but target 'x86_64-unknown-linux' does not support itQuoted 8 lines
data->wde_interval = 300L * 1E6L; ^Turn this into pure integer math and make it more readable at the same time using the
NSEC_PER_MSECmacro instead.Fixes 6647156c00cc ("power: reset: add LTC2952 poweroff driver")Signed-off-by Arnd Bergmann <[email protected]>
Quoted 8 lines
Thanks for the patch! The change in clang-14 (ToT) that triggered this has had another patch on top reverting these diagnostics.
https://reviews.llvm.org/D114162That said, this change is still worthwhile for the improved semantics, IMO.
Ah, a fix has already been picked up:
https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git/commit/?id=644106cdb89844be2496b21175b7c0c2e0fab381
Quoted 28 lines
Quoted 21 lines
--- drivers/power/reset/ltc2952-poweroff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/power/reset/ltc2952-poweroff.c +2
-3@@ -159,8 +159,8 @@ static void ltc2952_poweroff_kill(void)static void ltc2952_poweroff_default (struct ltc2952_poweroff *data) { - data->wde_interval =300L *1E6L ; - data->trigger_delay =ktime_set (2 ,500L *1E6L ); + data->wde_interval =300 *NSEC_PER_MSEC ; + data->trigger_delay =ktime_set (2 ,500 *NSEC_PER_MSEC );hrtimer_init (&data->timer_trigger,CLOCK_MONOTONIC ,HRTIMER_MODE_REL ); data->timer_trigger.function = ltc2952_poweroff_timer_trigger; --Quoted 2 lines
2.29.2
--
Thanks,
~Nick Desaulniers
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 15 lines · Nick Desaulniers
Quoted 14 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
clang-14 does not like the way this driver converts a 'long double' to an integer when the target architecture disables floating point support:
drivers/power/reset/ltc2952-poweroff.c:162:28: error: expression requires 'long double' type support, but target 'x86_64-unknown-linux' does not support itdata->wde_interval = 300L * 1E6L; ^Turn this into pure integer math and make it more readable at the same time using the
NSEC_PER_MSECmacro instead.
Quoted 6 lines
Quoted 2 lines
Fixes 6647156c00cc ("power: reset: add LTC2952 poweroff driver")Signed-off-by Arnd Bergmann <[email protected]>Thanks for the patch! The change in clang-14 (ToT) that triggered this has had another patch on top reverting these diagnostics.
https://reviews.llvm.org/D114162
I can still reproduce this failure on current ToT (33e3554ea33d) on x86_64 allmodconfig; it seems like that patch only fixes it for 32-bit x86.
Quoted 4 lines
That said, this change is still worthwhile for the improved semantics, IMO.
My patch appears to be accepted in Sebastian's branch already, it seems like it just needs to be sent to Linus (it also looks like that branch doesn't flow into -next, it probably should):
https://git.kernel.org/sre/linux-power-supply/c/644106cdb89844be2496b21175b7c0c2e0fab381
Cheers,
Nathan
Quoted 27 lines
Quoted 22 lines
--- drivers/power/reset/ltc2952-poweroff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/power/reset/ltc2952-poweroff.c +2
-3@@ -159,8 +159,8 @@ static void ltc2952_poweroff_kill(void)static void ltc2952_poweroff_default (struct ltc2952_poweroff *data) { - data->wde_interval =300L *1E6L ; - data->trigger_delay =ktime_set (2 ,500L *1E6L ); + data->wde_interval =300 *NSEC_PER_MSEC ; + data->trigger_delay =ktime_set (2 ,500 *NSEC_PER_MSEC );hrtimer_init (&data->timer_trigger,CLOCK_MONOTONIC ,HRTIMER_MODE_REL ); data->timer_trigger.function = ltc2952_poweroff_timer_trigger; --2.29.2
Signature · 2 lines
Thanks, ~Nick Desaulniers
(Minus most folks, plus Phoebe)
Quoted 20 lines · Nathan Chancellor
Quoted 18 lines · Nick Desaulniers
Quoted 16 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
clang-14 does not like the way this driver converts a 'long double' to an integer when the target architecture disables floating point support:
drivers/power/reset/ltc2952-poweroff.c:162:28: error: expression requires 'long double' type support, but target 'x86_64-unknown-linux' does not support itdata->wde_interval = 300L * 1E6L; ^Turn this into pure integer math and make it more readable at the same time using the
NSEC_PER_MSECmacro instead.Fixes 6647156c00cc ("power: reset: add LTC2952 poweroff driver")Signed-off-by Arnd Bergmann <[email protected]>
Quoted 7 lines
Quoted 3 lines
Thanks for the patch! The change in clang-14 (ToT) that triggered this has had another patch on top reverting these diagnostics.
https://reviews.llvm.org/D114162I can still reproduce this failure on current ToT (
33e3554ea33d) onx86_64allmodconfig; it seems like that patch only fixes it for 32-bit x86.
As a heads up Phoebe, in case there's any interest in doing something similar to https://reviews.llvm.org/D114162 but for 64b.
Quoted 43 lines
Quoted 5 lines
That said, this change is still worthwhile for the improved semantics, IMO.
My patch appears to be accepted in Sebastian's branch already, it seems like it just needs to be sent to Linus (it also looks like that branch doesn't flow into -next, it probably should):
https://git.kernel.org/sre/linux-power-supply/c/644106cdb89844be2496b21175b7c0c2e0fab381
Cheers,
NathanQuoted 27 lines
Quoted 20 lines
--- drivers/power/reset/ltc2952-poweroff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/power/reset/ltc2952-poweroff.c +2
-3@@ -159,8 +159,8 @@ static void ltc2952_poweroff_kill(void)static void ltc2952_poweroff_default (struct ltc2952_poweroff *data) { - data->wde_interval =300L *1E6L ; - data->trigger_delay =ktime_set (2 ,500L *1E6L ); + data->wde_interval =300 *NSEC_PER_MSEC ; + data->trigger_delay =ktime_set (2 ,500 *NSEC_PER_MSEC );hrtimer_init (&data->timer_trigger,CLOCK_MONOTONIC ,HRTIMER_MODE_REL ); data->timer_trigger.function = ltc2952_poweroff_timer_trigger; --Quoted 2 lines
2.29.2
--
Thanks,
~Nick Desaulniers
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 27 lines · Nick Desaulniers
(Minus most folks, plus Phoebe)
Quoted 24 lines · Nathan Chancellor
Quoted 21 lines · Nick Desaulniers
Quoted 8 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
clang-14 does not like the way this driver converts a 'long double' to an integer when the target architecture disables floating point support:
drivers/power/reset/ltc2952-poweroff.c:162:28: error: expression requires 'long double' type support, but target 'x86_64-unknown-linux' does not support itQuoted 8 lines
data->wde_interval = 300L * 1E6L; ^Turn this into pure integer math and make it more readable at the same time using the
NSEC_PER_MSECmacro instead.Fixes 6647156c00cc ("power: reset: add LTC2952 poweroff driver")Signed-off-by Arnd Bergmann <[email protected]>Thanks for the patch! The change in clang-14 (ToT) that triggered this has had another patch on top reverting these diagnostics.
https://reviews.llvm.org/D114162
Quoted 6 lines
Quoted 3 lines
I can still reproduce this failure on current ToT (
33e3554ea33d) onx86_64allmodconfig; it seems like that patch only fixes it for 32-bit x86.As a heads up Phoebe, in case there's any interest in doing something similar to https://reviews.llvm.org/D114162 but for 64b.
Phoebe pointed out on our issue tracker that GCC will error when long double is used with -mno-80837 as well:
https://github.com/ClangBuiltLinux/linux/issues/1497#issuecomment-983245202
It just appears that GCC is able to avoid these errors in the particular cases that the kernel triggers in clang:
https://github.com/ClangBuiltLinux/linux/issues/1497#issuecomment-983739365
Cheers,
Nathan