Linux ACPI
 help / color / mirror / Atom feed
* [patch 3/9] fujitsu-laptop: fix tests of acpi_evaluate_integer() return
@ 2009-12-22  0:20 akpm
  2009-12-22 20:28 ` Len Brown
  0 siblings, 1 reply; 3+ messages in thread
From: akpm @ 2009-12-22  0:20 UTC (permalink / raw)
  To: lenb; +Cc: linux-acpi, akpm, roel.kluin, jwoithe

From: Roel Kluin <roel.kluin@gmail.com>

The wrong test was used acpi_status status is unsigned.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Acked-by: Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Cc: Len Brown <lenb@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/platform/x86/fujitsu-laptop.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff -puN drivers/platform/x86/fujitsu-laptop.c~fujitsu-laptop-fix-tests-of-acpi_evaluate_integer-return drivers/platform/x86/fujitsu-laptop.c
--- a/drivers/platform/x86/fujitsu-laptop.c~fujitsu-laptop-fix-tests-of-acpi_evaluate_integer-return
+++ a/drivers/platform/x86/fujitsu-laptop.c
@@ -376,7 +376,7 @@ static int get_lcd_level(void)
 
 	status =
 	    acpi_evaluate_integer(fujitsu->acpi_handle, "GBLL", NULL, &state);
-	if (status < 0)
+	if (ACPI_FAILURE(status))
 		return status;
 
 	fujitsu->brightness_level = state & 0x0fffffff;
@@ -398,7 +398,7 @@ static int get_max_brightness(void)
 
 	status =
 	    acpi_evaluate_integer(fujitsu->acpi_handle, "RBLL", NULL, &state);
-	if (status < 0)
+	if (ACPI_FAILURE(status))
 		return status;
 
 	fujitsu->max_brightness = state;
_

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

* Re: [patch 3/9] fujitsu-laptop: fix tests of acpi_evaluate_integer() return
  2009-12-22  0:20 [patch 3/9] fujitsu-laptop: fix tests of acpi_evaluate_integer() return akpm
@ 2009-12-22 20:28 ` Len Brown
  2009-12-22 22:45   ` [patch 3/9] fujitsu-laptop: fix tests of acpi_evaluate_integer() Jonathan Woithe
  0 siblings, 1 reply; 3+ messages in thread
From: Len Brown @ 2009-12-22 20:28 UTC (permalink / raw)
  To: akpm; +Cc: linux-acpi, roel.kluin, jwoithe

NAK, this patch is incorrect

On Mon, 21 Dec 2009, akpm@linux-foundation.org wrote:

> From: Roel Kluin <roel.kluin@gmail.com>
> 
> The wrong test was used acpi_status status is unsigned.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> Acked-by: Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
> Cc: Len Brown <lenb@kernel.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  drivers/platform/x86/fujitsu-laptop.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff -puN drivers/platform/x86/fujitsu-laptop.c~fujitsu-laptop-fix-tests-of-acpi_evaluate_integer-return drivers/platform/x86/fujitsu-laptop.c
> --- a/drivers/platform/x86/fujitsu-laptop.c~fujitsu-laptop-fix-tests-of-acpi_evaluate_integer-return
> +++ a/drivers/platform/x86/fujitsu-laptop.c
> @@ -376,7 +376,7 @@ static int get_lcd_level(void)
>  
>  	status =
>  	    acpi_evaluate_integer(fujitsu->acpi_handle, "GBLL", NULL, &state);
> -	if (status < 0)
> +	if (ACPI_FAILURE(status))
>  		return status;

backlight_show_actual_brightness() will stuff this return value in sysfs
no matter what you return.

I'm sure we don't want to return an acpi_status.

Looks like it should return 0 on failure, like thinkpad does.

>  
>  	fujitsu->brightness_level = state & 0x0fffffff;
> @@ -398,7 +398,7 @@ static int get_max_brightness(void)
>  
>  	status =
>  	    acpi_evaluate_integer(fujitsu->acpi_handle, "RBLL", NULL, &state);
> -	if (status < 0)
> +	if (ACPI_FAILURE(status))
>  		return status;

needs to be return -1, since show_max_brightness is testing for < 0.

>  
>  	fujitsu->max_brightness = state;
> _
> 

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

* Re: [patch 3/9] fujitsu-laptop: fix tests of acpi_evaluate_integer()
  2009-12-22 20:28 ` Len Brown
@ 2009-12-22 22:45   ` Jonathan Woithe
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Woithe @ 2009-12-22 22:45 UTC (permalink / raw)
  To: Len Brown; +Cc: akpm, linux-acpi, roel.kluin, jwoithe

> NAK, this patch is incorrect
> 
> On Mon, 21 Dec 2009, akpm@linux-foundation.org wrote:
> 
> > From: Roel Kluin <roel.kluin@gmail.com>
> > 
> > The wrong test was used acpi_status status is unsigned.
> > 
> > Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> > Acked-by: Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
> > Cc: Len Brown <lenb@kernel.org>
> > Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> > ---
> > 
> >  drivers/platform/x86/fujitsu-laptop.c |    4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff -puN drivers/platform/x86/fujitsu-laptop.c~fujitsu-laptop-fix-tests-of-acpi_evaluate_integer-return drivers/platform/x86/fujitsu-laptop.c
> > --- a/drivers/platform/x86/fujitsu-laptop.c~fujitsu-laptop-fix-tests-of-acpi_evaluate_integer-return
> > +++ a/drivers/platform/x86/fujitsu-laptop.c
> > @@ -376,7 +376,7 @@ static int get_lcd_level(void)
> >  
> >  	status =
> >  	    acpi_evaluate_integer(fujitsu->acpi_handle, "GBLL", NULL, &state);
> > -	if (status < 0)
> > +	if (ACPI_FAILURE(status))
> >  		return status;
> 
> backlight_show_actual_brightness() will stuff this return value in sysfs
> no matter what you return.
> 
> I'm sure we don't want to return an acpi_status.
> 
> Looks like it should return 0 on failure, like thinkpad does.

Fair enough.  At the time this patch was first proposed there was some
confusion as to what the return value should be.  We ended up taking a punt
and got it wrong.

> >  	fujitsu->brightness_level = state & 0x0fffffff;
> > @@ -398,7 +398,7 @@ static int get_max_brightness(void)
> >  
> >  	status =
> >  	    acpi_evaluate_integer(fujitsu->acpi_handle, "RBLL", NULL, &state);
> > -	if (status < 0)
> > +	if (ACPI_FAILURE(status))
> >  		return status;
> 
> needs to be return -1, since show_max_brightness is testing for < 0.

Same here.

Thanks for the feedback; I'll do up a revised patch in a sec.

Regards
  jonathan

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

end of thread, other threads:[~2009-12-22 22:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-22  0:20 [patch 3/9] fujitsu-laptop: fix tests of acpi_evaluate_integer() return akpm
2009-12-22 20:28 ` Len Brown
2009-12-22 22:45   ` [patch 3/9] fujitsu-laptop: fix tests of acpi_evaluate_integer() Jonathan Woithe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox