asus-laptop: correct error handling in asus_read_brightness()
PATCH 1/1 asus-laptop: correct error handling in asus_read_brightness()
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.
--- drivers/platform/x86/asus-laptop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/platform/x86/asus-laptop.c +3 -1
@@ -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; }
Signature · 1 line
2.8.0
Quoted 15 lines · Giedrius Statkevičius
It is possible that
acpi_evaluate_integermight 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 <[email protected]>--- drivers/platform/x86/asus-laptop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/platform/x86/asus-laptop.c +0
-0
drivers/platform/x86/asus-laptop.c static int asus_read_brightness(struct backlight_device *bd) · line 781
Quoted 8 lines
drivers/platform/x86/asus-laptop.c +3
-1@@ -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 ; + }
This looks like a workaround.
I suppose the real fix is to return here an error code and fix all callers, like drivers/video/backlight/backlight.c.
Quoted 6 lines
drivers/platform/x86/asus-laptop.c +0
-1return value; } --2.8.0
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 18 lines · Andy Shevchenko
Quoted 16 lines · Giedrius Statkevičius
It is possible that
acpi_evaluate_integermight 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 <[email protected]>--- drivers/platform/x86/asus-laptop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/platform/x86/asus-laptop.c +0
-0@@ -775,8 +775,10 @@ static int asus_read_brightness(struct backlight_device *bd)
Quoted 12 lines
drivers/platform/x86/asus-laptop.c static int asus_read_brightness(struct backlight_device *bd) · line 781
Quoted 7 lines
drivers/platform/x86/asus-laptop.c +3
-1rv =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 ; + }This looks like a workaround.
I suppose the real fix is to return here an error code and fix all callers, likedrivers/video/backlight/backlight.c.
It just fixes the behaviour according to the current code in that file. I suppose that would be nice but I don't think it would make any difference because the backlight core code still prints out ->props.brightness in case ops->get_brightness fails. Just the difference would be that now actual error messages are printed in the drivers themselves instead of generic messages from the backlight core. Anyway, I think the current behaviour is more useful because the drivers know better about what has failed.
Quoted 32 lines · Giedrius Statkevičius
Quoted 18 lines · Andy Shevchenko
Quoted 16 lines · Giedrius Statkevičius
It is possible that
acpi_evaluate_integermight 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 <[email protected]>--- drivers/platform/x86/asus-laptop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/platform/x86/asus-laptop.c +0
-0@@ -775,8 +775,10 @@ static int asus_read_brightness(struct backlight_device *bd)Quoted 12 lines
drivers/platform/x86/asus-laptop.c static int asus_read_brightness(struct backlight_device *bd) · line 781
Quoted 7 lines
drivers/platform/x86/asus-laptop.c +3
-1rv =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 ; + }This looks like a workaround.
I suppose the real fix is to return here an error code and fix all callers, likedrivers/video/backlight/backlight.c.
Quoted 8 lines
It just fixes the behaviour according to the current code in that file. I suppose that would be nice but I don't think it would make any difference because the backlight core code still prints out ->props.brightness in case
ops->get_brightnessfails. Just the difference would be that now actual error messages are printed in the drivers themselves instead of generic messages from the backlight core. Anyway, I think the current behaviour is more useful because the drivers know better about what has failed.
As a matter of practice, based on feedback from the previous pdx86 maintainers, I prefer to accept patches which fix an immediate issue and leave the rework or broader work as a follow-on, or a TODO item.
We should look for a good place to document these TODOs.
Queued for 4.7.
Thanks,
Signature · 2 lines
Darren Hart Intel Open Source Technology Center