power: reset: ltc2952: Fix use of floating point literals
PATCH 1/1 power: reset: ltc2952: Fix use of floating point literals
A new commit in LLVM causes an error on the use of 'long double' when '-mno-x87' is used, which the kernel does through an alias, '-mno-80387' (see the LLVM commit below for more details around why it does this).
drivers/power/reset/ltc2952-poweroff.c:162:28: error: expression requires 'long double' type support, but target 'x86_64-unknown-linux-gnu' does not support it
data->wde_interval = 300L * 1E6L;
^
drivers/power/reset/ltc2952-poweroff.c:162:21: error: expression requires 'long double' type support, but target 'x86_64-unknown-linux-gnu' does not support it
data->wde_interval = 300L * 1E6L;
^
drivers/power/reset/ltc2952-poweroff.c:163:41: error: expression requires 'long double' type support, but target 'x86_64-unknown-linux-gnu' does not support it
data->trigger_delay = ktime_set(2, 500L*1E6L);
^3 errors generated.
This happens due to the use of a 'long double' literal. The 'E6' part of '1E6L' causes the literal to be a 'double' then the 'L' suffix promotes it to 'long double'.
There is no visible reason for floating point values in this driver, as the values are only assigned to integer types. Use USEC_PER_SEC, which is the same integer value as '1E6L', to avoid changing functionality but fix the error.
--- 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 =300L *USEC_PER_SEC ; + data->trigger_delay =ktime_set (2 ,500L *USEC_PER_SEC );hrtimer_init (&data->timer_trigger,CLOCK_MONOTONIC ,HRTIMER_MODE_REL ); data->timer_trigger.function = ltc2952_poweroff_timer_trigger;
base-commit: d4439a1189f93d0ac1eaf0197db8e6b3e197d5c7
Signature · 1 line
2.34.0.rc0
Quoted 26 lines · Nathan Chancellor
A new commit in LLVM causes an error on the use of 'long double' when '-mno-x87' is used, which the kernel does through an alias, '-mno-80387' (see the LLVM commit below for more details around why it does this).
drivers/power/reset/ltc2952-poweroff.c:162:28: error: expression requires 'long double' type support, but target 'x86_64-unknown-linux-gnu' does not support itdata->wde_interval = 300L * 1E6L; ^ drivers/power/reset/ltc2952-poweroff.c:162:21: error: expression requires 'long double' type support, but target 'x86_64-unknown-linux-gnu' does not support it data->wde_interval = 300L * 1E6L; ^ drivers/power/reset/ltc2952-poweroff.c:163:41: error: expression requires 'long double' type support, but target 'x86_64-unknown-linux-gnu' does not support it data->trigger_delay = ktime_set(2, 500L*1E6L); ^3 errors generated.
This happens due to the use of a 'long double' literal. The 'E6' part of '1E6L' causes the literal to be a 'double' then the 'L' suffix promotes it to 'long double'.
There is no visible reason for floating point values in this driver, as the values are only assigned to integer types. Use
USEC_PER_SEC, which is the same integer value as '1E6L', to avoid changing functionality but fix the error.
Quoted 4 lines
Fixes 6647156c00cc ("power: reset: add LTC2952 poweroff driver")Signed-off-by Nathan Chancellor <[email protected]>
Thanks for the patch!
Quoted 24 lines
--- 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 =300L *USEC_PER_SEC ; + data->trigger_delay =ktime_set (2 ,500L *USEC_PER_SEC );hrtimer_init (&data->timer_trigger,CLOCK_MONOTONIC ,HRTIMER_MODE_REL ); data->timer_trigger.function = ltc2952_poweroff_timer_trigger;base-commit:
d4439a1189f93d0ac1eaf0197db8e6b3e197d5c7--
2.34.0.rc0
Signature · 2 lines
Thanks, ~Nick Desaulniers