Skip to contentSkip to conversation

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

PATCH In review Arvind Yadav 2 participants 2 messages Mar 9, 2017 – Mar 14, 2017 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

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

Here, This patch is to handle a return error from dell_get_intensity. This change is done using Coccinelle.

---
 drivers/platform/x86/dell-laptop.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/platform/x86/dell-laptop.c +6 -0
index f57dd28..7fcf680 100644
@@ -2053,11 +2053,17 @@ static int __init dell_init(void)
 
 		dell_backlight_device->props.brightness =
 			dell_get_intensity(dell_backlight_device);
+		if (dell_backlight_device->props.brightness < 0) {
+			ret = dell_backlight_device->props.brightness;
+			goto fail_get_brightness;
+		}
 		backlight_update_status(dell_backlight_device);
 	}
 
 	return 0;
 
+fail_get_brightness:
+	backlight_device_unregister(dell_backlight_device);
 fail_backlight:
 	dell_cleanup_rfkill();
 fail_rfkill:
Signature · 1 line
1.9.1
#1 lore raw
Quoted 4 lines · On Thursday 09 March 2017 11:19:56 Arvind Yadav wrote:

Here, This patch is to handle a return error from dell_get_intensity. This change is done using Coccinelle.

Ok, seems good. You can add my Acked-By.

Quoted 26 lines
---
 drivers/platform/x86/dell-laptop.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/platform/x86/dell-laptop.c +6 -0
index f57dd28..7fcf680 100644
@@ -2053,11 +2053,17 @@ static int __init dell_init(void)
 
 		dell_backlight_device->props.brightness =
 			dell_get_intensity(dell_backlight_device);
+		if (dell_backlight_device->props.brightness < 0) {
+			ret = dell_backlight_device->props.brightness;
+			goto fail_get_brightness;
+		}
 		backlight_update_status(dell_backlight_device);
 	}
 
 	return 0;
 
+fail_get_brightness:
+	backlight_device_unregister(dell_backlight_device);
 fail_backlight:
 	dell_cleanup_rfkill();
 fail_rfkill:
Signature · 2 lines
Pali Rohár
[email protected]