Skip to contentSkip to conversation

platform/x86: dell-laptop: Handle return error form dell_get_intensity.

PATCH Superseded Arvind Yadav 2 participants 3 messages Mar 8, 2017 – Mar 9, 2017 x86 platform drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: dell-laptop: Handle return error form dell_get_intensity.

Here, dell_get_intensity can return an error. So we can assgine props.brightness as max_brightness.

This change is done using Coccinelle.

---
 drivers/platform/x86/dell-laptop.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/platform/x86/dell-laptop.c +3 -0
index f57dd28..0891de3 100644
@@ -2053,6 +2053,9 @@ static int __init dell_init(void)
 
 		dell_backlight_device->props.brightness =
 			dell_get_intensity(dell_backlight_device);
+		if (dell_backlight_device->props.brightness < 0) {
+			dell_backlight_device->props.brightness = props.max_brightness;
+		}
 		backlight_update_status(dell_backlight_device);
 	}
 
Signature · 1 line
1.9.1
#1 lore raw

Hi!

Quoted 1 line · On Wednesday 08 March 2017 17:52:27 Arvind Yadav wrote:

Here, dell_get_intensity can return an error.

Right. That is truth and we should check for errors.

Quoted 1 line

So we can assgine props.brightness as max_brightness.

But why to max_brightness? Seems that this is incorrect handling of error too...

Quoted 21 lines

This change is done using Coccinelle.

---
 drivers/platform/x86/dell-laptop.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/platform/x86/dell-laptop.c +3 -0
index f57dd28..0891de3 100644
@@ -2053,6 +2053,9 @@ static int __init dell_init(void)
 
 		dell_backlight_device->props.brightness =
 			dell_get_intensity(dell_backlight_device);
+		if (dell_backlight_device->props.brightness < 0) {
+			dell_backlight_device->props.brightness = props.max_brightness;
+		}
 		backlight_update_status(dell_backlight_device);
 	}
 
Signature · 2 lines
Pali Rohár
[email protected]
#2 lore raw

Hi,
Yes, you are right. I will handle return error correctly.

Thanks
-Arvind

Quoted 31 lines · Pali Rohár

Hi!

Quoted 1 line · On Wednesday 08 March 2017 17:52:27 Arvind Yadav wrote:

Here, dell_get_intensity can return an error.

Right. That is truth and we should check for errors.

Quoted 1 line

So we can assgine props.brightness as max_brightness.

But why to max_brightness? Seems that this is incorrect handling of error too...

Quoted 21 lines

This change is done using Coccinelle.

---
  drivers/platform/x86/dell-laptop.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/platform/x86/dell-laptop.c +3 -0
index f57dd28..0891de3 100644
@@ -2053,6 +2053,9 @@ static int __init dell_init(void)
 
  		dell_backlight_device->props.brightness =
  			dell_get_intensity(dell_backlight_device);
+		if (dell_backlight_device->props.brightness < 0) {
+			dell_backlight_device->props.brightness = props.max_brightness;
+		}
  		backlight_update_status(dell_backlight_device);
  	}