]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
asus-laptop: correct error handling in asus_read_brightness()
authorGiedrius Statkevičius <giedrius.statkevicius@gmail.com>
Sat, 16 Apr 2016 00:27:12 +0000 (03:27 +0300)
committerDarren Hart <dvhart@linux.intel.com>
Mon, 25 Apr 2016 17:39:58 +0000 (10:39 -0700)
It is possible that acpi_evaluate_integer might fail and value would not be
set to any value so correct this defect by returning 0 in case of an
error. This is also the correct thing to return because the backlight
subsystem will print the old value of brightness in this case.

Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
drivers/platform/x86/asus-laptop.c

index f2b5d0a8adf03a2bb5ac521aa62fa2046c06f438..a4cd78691ac934cdd5e3b285153f7ab8b9cf7caf 100644 (file)
@@ -775,8 +775,10 @@ static int asus_read_brightness(struct backlight_device *bd)
 
        rv = acpi_evaluate_integer(asus->handle, METHOD_BRIGHTNESS_GET,
                                   NULL, &value);
-       if (ACPI_FAILURE(rv))
+       if (ACPI_FAILURE(rv)) {
                pr_warn("Error reading brightness\n");
+               return 0;
+       }
 
        return value;
 }