summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-04-23 06:55:54 +0200
committerLennart Poettering <lennart@poettering.net>2014-04-23 19:06:38 +0200
commitc7fdf44d08e1217d40dc092fb90a65978a0f541f (patch)
tree90b829c2a5a21a190babc1b73a660523c3a765aa
parente30fa16e27cbd48f960113a1d72d9a15c3b2d67b (diff)
backlight: warn if kernel exposes backlight device with bogus max_brightness
We shouldn't silently tape over broken kernel drivers.
-rw-r--r--src/backlight/backlight.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c
index 754a646c3d..c708391612 100644
--- a/src/backlight/backlight.c
+++ b/src/backlight/backlight.c
@@ -205,14 +205,18 @@ static unsigned get_max_brightness(struct udev_device *device) {
max_brightness_str = udev_device_get_sysattr_value(device, "max_brightness");
if (!max_brightness_str) {
- log_warning("Failed to read 'max_brightness' attribute");
+ log_warning("Failed to read 'max_brightness' attribute.");
return 0;
}
r = safe_atou(max_brightness_str, &max_brightness);
if (r < 0) {
- log_warning("Failed to parse 'max_brightness' \"%s\": %s",
- max_brightness_str, strerror(-r));
+ log_warning("Failed to parse 'max_brightness' \"%s\": %s", max_brightness_str, strerror(-r));
+ return 0;
+ }
+
+ if (max_brightness <= 0) {
+ log_warning("Maximum brightness is 0, ignoring device.");
return 0;
}