linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dell-laptop: Fix backlight detection
@ 2018-07-08 15:02 Damien Thébault
  2018-07-08 15:09 ` Pali Rohár
  2018-07-09 21:57 ` Darren Hart
  0 siblings, 2 replies; 4+ messages in thread
From: Damien Thébault @ 2018-07-08 15:02 UTC (permalink / raw)
  To: Matthew Garrett, Pali Rohár, Darren Hart, Andy Shevchenko,
	Mario Limonciello, platform-driver-x86, linux-kernel

Fix return code check for "max brightness" ACPI call.

The dell laptop ACPI video brightness control is not present on dell
laptops anymore, but was present in older kernel versions.

The code that checks the return value is incorrect since the SMM
refactoring.

The old code was:
  if (buffer->output[0] == 0)

Which was changed to:
  ret = dell_send_request(...)
  if (ret)

However, dell_send_request() will return 0 if buffer->output[0] == 0,
so we must change the check to:
  if (ret == 0)

This issue was found on a Dell M4800 laptop, and the fix tested on it
as well.

Fixes: 549b4930f057 ("dell-smbios: Introduce dispatcher for SMM calls")
Signed-off-by: Damien Thébault <damien@dtbo.net>
Tested-by: Damien Thébault <damien@dtbo.net>
---
 drivers/platform/x86/dell-laptop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/dell-laptop.c
b/drivers/platform/x86/dell-laptop.c index f1fa8612db40..06978c14c83b
100644 --- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -2185,7 +2185,7 @@ static int __init dell_init(void)
 		dell_fill_request(&buffer, token->location, 0, 0, 0);
 		ret = dell_send_request(&buffer,
 					CLASS_TOKEN_READ,
SELECT_TOKEN_AC);
-		if (ret)
+		if (ret == 0)
 			max_intensity = buffer.output[3];
 	}
 
-- 
2.17.1

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

* Re: [PATCH] dell-laptop: Fix backlight detection
  2018-07-08 15:02 [PATCH] dell-laptop: Fix backlight detection Damien Thébault
@ 2018-07-08 15:09 ` Pali Rohár
  2018-07-09  4:14   ` Mario.Limonciello
  2018-07-09 21:57 ` Darren Hart
  1 sibling, 1 reply; 4+ messages in thread
From: Pali Rohár @ 2018-07-08 15:09 UTC (permalink / raw)
  To: Damien Thébault
  Cc: Matthew Garrett, Darren Hart, Andy Shevchenko, Mario Limonciello,
	platform-driver-x86, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1657 bytes --]

On Sunday 08 July 2018 17:02:20 Damien Thébault wrote:
> Fix return code check for "max brightness" ACPI call.
> 
> The dell laptop ACPI video brightness control is not present on dell
> laptops anymore, but was present in older kernel versions.
> 
> The code that checks the return value is incorrect since the SMM
> refactoring.
> 
> The old code was:
>   if (buffer->output[0] == 0)
> 
> Which was changed to:
>   ret = dell_send_request(...)
>   if (ret)
> 
> However, dell_send_request() will return 0 if buffer->output[0] == 0,
> so we must change the check to:
>   if (ret == 0)

You are right, dell_send_request() return non-zero value on error.

> This issue was found on a Dell M4800 laptop, and the fix tested on it
> as well.
> 
> Fixes: 549b4930f057 ("dell-smbios: Introduce dispatcher for SMM calls")
> Signed-off-by: Damien Thébault <damien@dtbo.net>
> Tested-by: Damien Thébault <damien@dtbo.net>
> ---
>  drivers/platform/x86/dell-laptop.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/dell-laptop.c
> b/drivers/platform/x86/dell-laptop.c index f1fa8612db40..06978c14c83b
> 100644 --- a/drivers/platform/x86/dell-laptop.c
> +++ b/drivers/platform/x86/dell-laptop.c
> @@ -2185,7 +2185,7 @@ static int __init dell_init(void)
>  		dell_fill_request(&buffer, token->location, 0, 0, 0);
>  		ret = dell_send_request(&buffer,
>  					CLASS_TOKEN_READ,
> SELECT_TOKEN_AC);
> -		if (ret)
> +		if (ret == 0)
>  			max_intensity = buffer.output[3];
>  	}
>  

Reviewed-by: Pali Rohár <pali.rohar@gmail.com>

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

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

* RE: [PATCH] dell-laptop: Fix backlight detection
  2018-07-08 15:09 ` Pali Rohár
@ 2018-07-09  4:14   ` Mario.Limonciello
  0 siblings, 0 replies; 4+ messages in thread
From: Mario.Limonciello @ 2018-07-09  4:14 UTC (permalink / raw)
  To: pali.rohar, damien; +Cc: mjg59, dvhart, andy, platform-driver-x86, linux-kernel

> -----Original Message-----
> From: Pali Rohár [mailto:pali.rohar@gmail.com]
> Sent: Sunday, July 8, 2018 8:09 AM
> To: Damien Thébault
> Cc: Matthew Garrett; Darren Hart; Andy Shevchenko; Limonciello, Mario; platform-
> driver-x86@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] dell-laptop: Fix backlight detection
> 
> On Sunday 08 July 2018 17:02:20 Damien Thébault wrote:
> > Fix return code check for "max brightness" ACPI call.
> >
> > The dell laptop ACPI video brightness control is not present on dell
> > laptops anymore, but was present in older kernel versions.
> >
> > The code that checks the return value is incorrect since the SMM
> > refactoring.
> >
> > The old code was:
> >   if (buffer->output[0] == 0)
> >
> > Which was changed to:
> >   ret = dell_send_request(...)
> >   if (ret)
> >
> > However, dell_send_request() will return 0 if buffer->output[0] == 0,
> > so we must change the check to:
> >   if (ret == 0)
> 
> You are right, dell_send_request() return non-zero value on error.
> 
> > This issue was found on a Dell M4800 laptop, and the fix tested on it
> > as well.
> >
> > Fixes: 549b4930f057 ("dell-smbios: Introduce dispatcher for SMM calls")
> > Signed-off-by: Damien Thébault <damien@dtbo.net>
> > Tested-by: Damien Thébault <damien@dtbo.net>
> > ---
> >  drivers/platform/x86/dell-laptop.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/platform/x86/dell-laptop.c
> > b/drivers/platform/x86/dell-laptop.c index f1fa8612db40..06978c14c83b
> > 100644 --- a/drivers/platform/x86/dell-laptop.c
> > +++ b/drivers/platform/x86/dell-laptop.c
> > @@ -2185,7 +2185,7 @@ static int __init dell_init(void)
> >  		dell_fill_request(&buffer, token->location, 0, 0, 0);
> >  		ret = dell_send_request(&buffer,
> >  					CLASS_TOKEN_READ,
> > SELECT_TOKEN_AC);
> > -		if (ret)
> > +		if (ret == 0)
> >  			max_intensity = buffer.output[3];
> >  	}
> >
> 
> Reviewed-by: Pali Rohár <pali.rohar@gmail.com>
> 

Thanks for this catch.

Reviewed-by: Mario Limonciello <mario.limonciello@dell.com>

This should probably go to stable as well.

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

* Re: [PATCH] dell-laptop: Fix backlight detection
  2018-07-08 15:02 [PATCH] dell-laptop: Fix backlight detection Damien Thébault
  2018-07-08 15:09 ` Pali Rohár
@ 2018-07-09 21:57 ` Darren Hart
  1 sibling, 0 replies; 4+ messages in thread
From: Darren Hart @ 2018-07-09 21:57 UTC (permalink / raw)
  To: Damien Thébault
  Cc: Matthew Garrett, Pali Rohár, Andy Shevchenko,
	Mario Limonciello, platform-driver-x86, linux-kernel

On Sun, Jul 08, 2018 at 05:02:20PM +0200, Damien Thébault wrote:
> Fix return code check for "max brightness" ACPI call.
> 
> The dell laptop ACPI video brightness control is not present on dell
> laptops anymore, but was present in older kernel versions.
> 
> The code that checks the return value is incorrect since the SMM
> refactoring.
> 
> The old code was:
>   if (buffer->output[0] == 0)
> 
> Which was changed to:
>   ret = dell_send_request(...)
>   if (ret)
> 
> However, dell_send_request() will return 0 if buffer->output[0] == 0,
> so we must change the check to:
>   if (ret == 0)
> 
> This issue was found on a Dell M4800 laptop, and the fix tested on it
> as well.
> 
> Fixes: 549b4930f057 ("dell-smbios: Introduce dispatcher for SMM calls")
> Signed-off-by: Damien Thébault <damien@dtbo.net>
> Tested-by: Damien Thébault <damien@dtbo.net>

Thanks for the analysis and fix Damien.

I was unable to apply the patch. Apparently due to your Content-Tranfer-Encoding
being set to "quoted-printable". This converts "=" characters to =3D.
Please work with your mail client and try sending the patch
to yourself and applying it. Once that works, please resend.

I suspect you may need to do one or both of the following:

- Disable preferences->compose->"wrap pasted text" (or whichever applies to how
  you get the patch into the compose window)

- Set Preferences->Mail Handling->Sending->Transfer Encoding to 8bit to avoid
  "quoted-printable".

Other claws users who send patches have Content-Transfer-Encoding set to 7bit

Thanks,

> ---
>  drivers/platform/x86/dell-laptop.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/dell-laptop.c
> b/drivers/platform/x86/dell-laptop.c index f1fa8612db40..06978c14c83b
> 100644 --- a/drivers/platform/x86/dell-laptop.c
> +++ b/drivers/platform/x86/dell-laptop.c
> @@ -2185,7 +2185,7 @@ static int __init dell_init(void)
>  		dell_fill_request(&buffer, token->location, 0, 0, 0);
>  		ret = dell_send_request(&buffer,
>  					CLASS_TOKEN_READ,
> SELECT_TOKEN_AC);
> -		if (ret)
> +		if (ret == 0)
>  			max_intensity = buffer.output[3];
>  	}
>  
> -- 
> 2.17.1
> 

-- 
Darren Hart
VMware Open Source Technology Center

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

end of thread, other threads:[~2018-07-09 21:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-08 15:02 [PATCH] dell-laptop: Fix backlight detection Damien Thébault
2018-07-08 15:09 ` Pali Rohár
2018-07-09  4:14   ` Mario.Limonciello
2018-07-09 21:57 ` Darren Hart

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).