diff mbox

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

Message ID 1489038596-3765-1-git-send-email-arvind.yadav.cs@gmail.com (mailing list archive)
State Accepted, archived
Delegated to: Andy Shevchenko
Headers show

Commit Message

Arvind Yadav March 9, 2017, 5:49 a.m. UTC
Here, This patch is to handle a return error from dell_get_intensity.
This change is done using Coccinelle.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/platform/x86/dell-laptop.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Pali Rohár March 14, 2017, 9:28 a.m. UTC | #1
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.
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>

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

> ---
>  drivers/platform/x86/dell-laptop.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
> index f57dd28..7fcf680 100644
> --- a/drivers/platform/x86/dell-laptop.c
> +++ b/drivers/platform/x86/dell-laptop.c
> @@ -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:
diff mbox

Patch

diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index f57dd28..7fcf680 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -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: