Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1380430

[PATCH] asus-laptop: correct error handling in asus_read_brightness()

From Giedrius Statkevičius <giedrius.statkevicius@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] asus-laptop: correct error handling in asus_read_brightness()
Date 2016-04-16 02:40 +0200
Message-ID <romrh-3hf-29@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 drivers/platform/x86/asus-laptop.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index 9a69734..15f1311 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -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;
 }
-- 
2.8.0

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] asus-laptop: correct error handling in asus_read_brightness() Giedrius Statkevičius   <giedrius.statkevicius@gmail.com> - 2016-04-16 02:40 +0200
  Re: [PATCH] asus-laptop: correct error handling in asus_read_brightness() Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-04-22 01:10 +0200
    Re: [PATCH] asus-laptop: correct error handling in  asus_read_brightness() Giedrius Statkevičius   <giedrius.statkevicius@gmail.com> - 2016-04-22 09:50 +0200
      Re: [PATCH] asus-laptop: correct error handling in  asus_read_brightness() Darren Hart <dvhart@infradead.org> - 2016-04-25 19:50 +0200

csiph-web