* [PATCH] platform/x86: fujitsu-laptop: Revert UNSUPPORTED_CMD back to an int
@ 2018-03-10 20:43 Michał Kępień
2018-03-11 4:10 ` Jonathan Woithe
0 siblings, 1 reply; 3+ messages in thread
From: Michał Kępień @ 2018-03-10 20:43 UTC (permalink / raw)
To: Jonathan Woithe, Darren Hart, Andy Shevchenko
Cc: Dan Carpenter, platform-driver-x86, linux-kernel
UNSUPPORTED_CMD was previously 0x80000000 (int), but commit 819cddae7cfa
("platform/x86: fujitsu-laptop: Clean up constants") changed it into an
unsigned long due to BIT() being used to define it. As call_fext_func()
returns an int, 0x80000000 would get type promoted when compared to an
unsigned long, which on a 64-bit system would cause it to become
0xffffffff80000000 due to sign extension. This causes one logical
condition in fujitsu-laptop to always be true and another one to always
be false on 64-bit systems. Fix this by reverting UNSUPPORTED_CMD back
to an int.
This patch fixes the following smatch warnings:
drivers/platform/x86/fujitsu-laptop.c:763 acpi_fujitsu_laptop_leds_register() warn: always true condition '(call_fext_func(device, ((1 << (12)) | (1 << (0))), 2, (1 << (16)), 0) != (1 << (31))) => (s32min-s32max != 2147483648)'
drivers/platform/x86/fujitsu-laptop.c:816 acpi_fujitsu_laptop_add() warn: impossible condition '(priv->flags_supported == (1 << (31))) => (0-2147483647,18446744071562067968-u64max == 2147483648)'
Fixes: 819cddae7cfa ("platform/x86: fujitsu-laptop: Clean up constants")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Michał Kępień <kernel@kempniu.pl>
---
This fixes a bug introduced by a commit queued for 4.17, so it needs to
be applied on top of for-next.
drivers/platform/x86/fujitsu-laptop.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 13bcdfea5349..6f4a55a53ced 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -85,7 +85,7 @@
#define FUNC_BACKLIGHT (BIT(12) | BIT(2))
/* FUNC interface - responses */
-#define UNSUPPORTED_CMD BIT(31)
+#define UNSUPPORTED_CMD 0x80000000
/* FUNC interface - status flags */
#define FLAG_RFKILL BIT(5)
--
2.16.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] platform/x86: fujitsu-laptop: Revert UNSUPPORTED_CMD back to an int
2018-03-10 20:43 [PATCH] platform/x86: fujitsu-laptop: Revert UNSUPPORTED_CMD back to an int Michał Kępień
@ 2018-03-11 4:10 ` Jonathan Woithe
2018-03-21 23:30 ` Darren Hart
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Woithe @ 2018-03-11 4:10 UTC (permalink / raw)
To: Micha?? K??pie??
Cc: Darren Hart, Andy Shevchenko, Dan Carpenter, platform-driver-x86,
linux-kernel
On Sat, Mar 10, 2018 at 09:43:53PM +0100, Micha?? K??pie?? wrote:
> UNSUPPORTED_CMD was previously 0x80000000 (int), but commit 819cddae7cfa
> ("platform/x86: fujitsu-laptop: Clean up constants") changed it into an
> unsigned long due to BIT() being used to define it. As call_fext_func()
> returns an int, 0x80000000 would get type promoted when compared to an
> unsigned long, which on a 64-bit system would cause it to become
> 0xffffffff80000000 due to sign extension. This causes one logical
> condition in fujitsu-laptop to always be true and another one to always
> be false on 64-bit systems. Fix this by reverting UNSUPPORTED_CMD back
> to an int.
>
> This patch fixes the following smatch warnings:
>
> drivers/platform/x86/fujitsu-laptop.c:763 acpi_fujitsu_laptop_leds_register() warn: always true condition '(call_fext_func(device, ((1 << (12)) | (1 << (0))), 2, (1 << (16)), 0) != (1 << (31))) => (s32min-s32max != 2147483648)'
> drivers/platform/x86/fujitsu-laptop.c:816 acpi_fujitsu_laptop_add() warn: impossible condition '(priv->flags_supported == (1 << (31))) => (0-2147483647,18446744071562067968-u64max == 2147483648)'
>
> Fixes: 819cddae7cfa ("platform/x86: fujitsu-laptop: Clean up constants")
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Micha?? K??pie?? <kernel@kempniu.pl>
> ---
> This fixes a bug introduced by a commit queued for 4.17, so it needs to
> be applied on top of for-next.
>
> drivers/platform/x86/fujitsu-laptop.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> index 13bcdfea5349..6f4a55a53ced 100644
> --- a/drivers/platform/x86/fujitsu-laptop.c
> +++ b/drivers/platform/x86/fujitsu-laptop.c
> @@ -85,7 +85,7 @@
> #define FUNC_BACKLIGHT (BIT(12) | BIT(2))
>
> /* FUNC interface - responses */
> -#define UNSUPPORTED_CMD BIT(31)
> +#define UNSUPPORTED_CMD 0x80000000
>
> /* FUNC interface - status flags */
> #define FLAG_RFKILL BIT(5)
This looks like a sensible, succinct solution to the regression.
Reviewed-by: Jonathan Woithe <jwoithe@just42.net>
Regards
jonathan
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] platform/x86: fujitsu-laptop: Revert UNSUPPORTED_CMD back to an int
2018-03-11 4:10 ` Jonathan Woithe
@ 2018-03-21 23:30 ` Darren Hart
0 siblings, 0 replies; 3+ messages in thread
From: Darren Hart @ 2018-03-21 23:30 UTC (permalink / raw)
To: Jonathan Woithe
Cc: Micha?? K??pie??, Andy Shevchenko, Dan Carpenter,
platform-driver-x86, linux-kernel
On Sun, Mar 11, 2018 at 02:40:56PM +1030, Jonathan Woithe wrote:
> On Sat, Mar 10, 2018 at 09:43:53PM +0100, Micha?? K??pie?? wrote:
> > UNSUPPORTED_CMD was previously 0x80000000 (int), but commit 819cddae7cfa
> > ("platform/x86: fujitsu-laptop: Clean up constants") changed it into an
> > unsigned long due to BIT() being used to define it. As call_fext_func()
> > returns an int, 0x80000000 would get type promoted when compared to an
> > unsigned long, which on a 64-bit system would cause it to become
> > 0xffffffff80000000 due to sign extension. This causes one logical
> > condition in fujitsu-laptop to always be true and another one to always
> > be false on 64-bit systems. Fix this by reverting UNSUPPORTED_CMD back
> > to an int.
> >
> > This patch fixes the following smatch warnings:
> >
> > drivers/platform/x86/fujitsu-laptop.c:763 acpi_fujitsu_laptop_leds_register() warn: always true condition '(call_fext_func(device, ((1 << (12)) | (1 << (0))), 2, (1 << (16)), 0) != (1 << (31))) => (s32min-s32max != 2147483648)'
> > drivers/platform/x86/fujitsu-laptop.c:816 acpi_fujitsu_laptop_add() warn: impossible condition '(priv->flags_supported == (1 << (31))) => (0-2147483647,18446744071562067968-u64max == 2147483648)'
> >
> > Fixes: 819cddae7cfa ("platform/x86: fujitsu-laptop: Clean up constants")
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Signed-off-by: Micha?? K??pie?? <kernel@kempniu.pl>
Queued up, thank you.
--
Darren Hart
VMware Open Source Technology Center
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-03-21 23:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-10 20:43 [PATCH] platform/x86: fujitsu-laptop: Revert UNSUPPORTED_CMD back to an int Michał Kępień
2018-03-11 4:10 ` Jonathan Woithe
2018-03-21 23:30 ` Darren Hart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox