diff mbox

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

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

Commit Message

Arvind Yadav March 8, 2017, 12:22 p.m. UTC
Here, dell_get_intensity can return an error. So we can assgine
props.brightness as max_brightness.

This change is done using Coccinelle.

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

Comments

Pali Rohár March 8, 2017, 12:54 p.m. UTC | #1
Hi!

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.

> So we can assgine props.brightness as max_brightness.

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

> This change is done using Coccinelle.
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
>  drivers/platform/x86/dell-laptop.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
> index f57dd28..0891de3 100644
> --- a/drivers/platform/x86/dell-laptop.c
> +++ b/drivers/platform/x86/dell-laptop.c
> @@ -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);
>  	}
>
Arvind Yadav March 9, 2017, 5:43 a.m. UTC | #2
Hi,
Yes, you are right. I will handle return error correctly.

Thanks
-Arvind

On Wednesday 08 March 2017 06:24 PM, Pali Rohár wrote:
> Hi!
>
> 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.
>
>> So we can assgine props.brightness as max_brightness.
> But why to max_brightness? Seems that this is incorrect handling of
> error too...
>
>> This change is done using Coccinelle.
>>
>> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
>> ---
>>   drivers/platform/x86/dell-laptop.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
>> index f57dd28..0891de3 100644
>> --- a/drivers/platform/x86/dell-laptop.c
>> +++ b/drivers/platform/x86/dell-laptop.c
>> @@ -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);
>>   	}
>>
diff mbox

Patch

diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index f57dd28..0891de3 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -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);
 	}