Re: [patch 05/12] fujitsu-laptop: fix tests of acpi_evaluate_integer()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> > From: Roel Kluin <roel.kluin@xxxxxxxxx>
> > 
> > The wrong test was used acpi_status status is unsigned.
> > 
> > Signed-off-by: Roel Kluin <roel.kluin@xxxxxxxxx>
> > Acked-by: Jonathan Woithe <jwoithe@xxxxxxxxxxxxxxxxxxxxxxx>
> > Cc: Len Brown <lenb@xxxxxxxxxx>
> > Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> > ---
> > 
> >  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;
> 
> as status is a positive number, shouldn't we be returning something like 
> -1 here on failure, rather than status?

These functions are called via the backlight_ops structure by the standard
backlight class framework and it seems, from a real quick look, that the API
treats numbers >=0 as valid data.  So something like this (untested, off the
top of my head) might be more appropriate:

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)
-		return status;
+	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)
-		return status;
+	if (ACPI_FAILURE(status))
+		return -status;
 
 	fujitsu->max_brightness = state;


Otherwise "return -1;" would be fine by me.  My only reason for going with
"-status" is that it might give some clue as to what went wrong.  Thoughts?

Signed-off-by: Jonathan Woithe <jwoithe@xxxxxxxxxxxxxxxxxxxxxxx>

Regards
  jonathan
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux