1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 19:21:53 +03:00

backlight: warn if kernel exposes backlight device with bogus max_brightness

We shouldn't silently tape over broken kernel drivers.
This commit is contained in:
Lennart Poettering 2014-04-23 06:55:54 +02:00
parent e30fa16e27
commit c7fdf44d08

View File

@ -205,14 +205,18 @@ static unsigned get_max_brightness(struct udev_device *device) {
max_brightness_str = udev_device_get_sysattr_value(device, "max_brightness"); max_brightness_str = udev_device_get_sysattr_value(device, "max_brightness");
if (!max_brightness_str) { if (!max_brightness_str) {
log_warning("Failed to read 'max_brightness' attribute"); log_warning("Failed to read 'max_brightness' attribute.");
return 0; return 0;
} }
r = safe_atou(max_brightness_str, &max_brightness); r = safe_atou(max_brightness_str, &max_brightness);
if (r < 0) { if (r < 0) {
log_warning("Failed to parse 'max_brightness' \"%s\": %s", log_warning("Failed to parse 'max_brightness' \"%s\": %s", max_brightness_str, strerror(-r));
max_brightness_str, strerror(-r)); return 0;
}
if (max_brightness <= 0) {
log_warning("Maximum brightness is 0, ignoring device.");
return 0; return 0;
} }