linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] power: reset: ltc2952: fix float conversion error
@ 2021-12-04 22:01 Arnd Bergmann
  2021-12-07 18:41 ` Nick Desaulniers
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2021-12-04 22:01 UTC (permalink / raw)
  To: Sebastian Reichel, René Moll
  Cc: Arnd Bergmann, Nathan Chancellor, Nick Desaulniers, linux-pm,
	linux-kernel, llvm

From: Arnd Bergmann <arnd@arndb.de>

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.

Fixes: 6647156c00cc ("power: reset: add LTC2952 poweroff driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/power/reset/ltc2952-poweroff.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/power/reset/ltc2952-poweroff.c b/drivers/power/reset/ltc2952-poweroff.c
index fbb344353fe4..9fc88a9f244c 100644
--- a/drivers/power/reset/ltc2952-poweroff.c
+++ b/drivers/power/reset/ltc2952-poweroff.c
@@ -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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] power: reset: ltc2952: fix float conversion error
  2021-12-04 22:01 [PATCH] power: reset: ltc2952: fix float conversion error Arnd Bergmann
@ 2021-12-07 18:41 ` Nick Desaulniers
  2021-12-07 19:00   ` Nick Desaulniers
  2021-12-07 19:05   ` Nathan Chancellor
  0 siblings, 2 replies; 4+ messages in thread
From: Nick Desaulniers @ 2021-12-07 18:41 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Sebastian Reichel, René Moll, Arnd Bergmann,
	Nathan Chancellor, linux-pm, linux-kernel, llvm

On Sat, Dec 4, 2021 at 2:02 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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.
>
> Fixes: 6647156c00cc ("power: reset: add LTC2952 poweroff driver")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

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.

Link: https://github.com/ClangBuiltLinux/linux/issues/1497
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>  drivers/power/reset/ltc2952-poweroff.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/power/reset/ltc2952-poweroff.c b/drivers/power/reset/ltc2952-poweroff.c
> index fbb344353fe4..9fc88a9f244c 100644
> --- a/drivers/power/reset/ltc2952-poweroff.c
> +++ b/drivers/power/reset/ltc2952-poweroff.c
> @@ -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
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] power: reset: ltc2952: fix float conversion error
  2021-12-07 18:41 ` Nick Desaulniers
@ 2021-12-07 19:00   ` Nick Desaulniers
  2021-12-07 19:05   ` Nathan Chancellor
  1 sibling, 0 replies; 4+ messages in thread
From: Nick Desaulniers @ 2021-12-07 19:00 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Sebastian Reichel, René Moll, Arnd Bergmann,
	Nathan Chancellor, linux-pm, linux-kernel, llvm

On Tue, Dec 7, 2021 at 10:41 AM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Sat, Dec 4, 2021 at 2:02 PM Arnd Bergmann <arnd@kernel.org> wrote:
> >
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > 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.
> >
> > Fixes: 6647156c00cc ("power: reset: add LTC2952 poweroff driver")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> 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.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/1497
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

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

>
> > ---
> >  drivers/power/reset/ltc2952-poweroff.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/power/reset/ltc2952-poweroff.c b/drivers/power/reset/ltc2952-poweroff.c
> > index fbb344353fe4..9fc88a9f244c 100644
> > --- a/drivers/power/reset/ltc2952-poweroff.c
> > +++ b/drivers/power/reset/ltc2952-poweroff.c
> > @@ -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
> >
>
>
> --
> Thanks,
> ~Nick Desaulniers



-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] power: reset: ltc2952: fix float conversion error
  2021-12-07 18:41 ` Nick Desaulniers
  2021-12-07 19:00   ` Nick Desaulniers
@ 2021-12-07 19:05   ` Nathan Chancellor
  1 sibling, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2021-12-07 19:05 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Arnd Bergmann, Sebastian Reichel, René Moll, Arnd Bergmann,
	linux-pm, linux-kernel, llvm

On Tue, Dec 07, 2021 at 10:41:24AM -0800, Nick Desaulniers wrote:
> On Sat, Dec 4, 2021 at 2:02 PM Arnd Bergmann <arnd@kernel.org> wrote:
> >
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > 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.
> >
> > Fixes: 6647156c00cc ("power: reset: add LTC2952 poweroff driver")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> 
> 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.

> That said, this change is still worthwhile for the improved semantics, IMO.
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/1497
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

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

> > ---
> >  drivers/power/reset/ltc2952-poweroff.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/power/reset/ltc2952-poweroff.c b/drivers/power/reset/ltc2952-poweroff.c
> > index fbb344353fe4..9fc88a9f244c 100644
> > --- a/drivers/power/reset/ltc2952-poweroff.c
> > +++ b/drivers/power/reset/ltc2952-poweroff.c
> > @@ -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
> >
> 
> 
> -- 
> Thanks,
> ~Nick Desaulniers

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-07 19:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-04 22:01 [PATCH] power: reset: ltc2952: fix float conversion error Arnd Bergmann
2021-12-07 18:41 ` Nick Desaulniers
2021-12-07 19:00   ` Nick Desaulniers
2021-12-07 19:05   ` Nathan Chancellor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).