public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH] charger-manager: Fix checking of wrong return type
@ 2014-03-27 11:56 Chanwoo Choi
  2014-03-27 16:52 ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 3+ messages in thread
From: Chanwoo Choi @ 2014-03-27 11:56 UTC (permalink / raw)
  To: dbaryshkov, dwmw2; +Cc: myungjoo.ham, kyungmin.park, linux-kernel, Chanwoo Choi

This patch fix minor issue about checking wrong return type.

The of_cm_parse_desc() return ERR_PTR(errnor number) when some error happen
in this function. But, charger_manager_probe() has only checked whether
desc is NULL or not. If of_cm_parse_desc() returns ERR_PTR(-ENOMEM), desc
isn't NULL but desc is (void *)(-ENOMEM). Althouhg some error happen for parsing
DT, charger_manager_probe() can't detect error of desc instance.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
---
 drivers/power/charger-manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
index 9e4dab4..a10fb57 100644
--- a/drivers/power/charger-manager.c
+++ b/drivers/power/charger-manager.c
@@ -1677,7 +1677,7 @@ static int charger_manager_probe(struct platform_device *pdev)
 		}
 	}
 
-	if (!desc) {
+	if (IS_ERR(desc)) {
 		dev_err(&pdev->dev, "No platform data (desc) found\n");
 		return -ENODEV;
 	}
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RESEND PATCH] charger-manager: Fix checking of wrong return type
  2014-03-27 11:56 [RESEND PATCH] charger-manager: Fix checking of wrong return type Chanwoo Choi
@ 2014-03-27 16:52 ` Bartlomiej Zolnierkiewicz
  2014-03-28  0:52   ` Chanwoo Choi
  0 siblings, 1 reply; 3+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2014-03-27 16:52 UTC (permalink / raw)
  To: Chanwoo Choi; +Cc: dbaryshkov, dwmw2, myungjoo.ham, kyungmin.park, linux-kernel


Hi,

On Thursday, March 27, 2014 08:56:55 PM Chanwoo Choi wrote:
> This patch fix minor issue about checking wrong return type.
> 
> The of_cm_parse_desc() return ERR_PTR(errnor number) when some error happen
> in this function. But, charger_manager_probe() has only checked whether
> desc is NULL or not. If of_cm_parse_desc() returns ERR_PTR(-ENOMEM), desc
> isn't NULL but desc is (void *)(-ENOMEM). Althouhg some error happen for parsing
> DT, charger_manager_probe() can't detect error of desc instance.
> 
> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
> ---
>  drivers/power/charger-manager.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
> index 9e4dab4..a10fb57 100644
> --- a/drivers/power/charger-manager.c
> +++ b/drivers/power/charger-manager.c
> @@ -1677,7 +1677,7 @@ static int charger_manager_probe(struct platform_device *pdev)
>  		}
>  	}
>  
> -	if (!desc) {
> +	if (IS_ERR(desc)) {
>  		dev_err(&pdev->dev, "No platform data (desc) found\n");
>  		return -ENODEV;

While you are at it you may also fix the code to return the proper error
code.  of_cm_parse_desc() currently returns -ENOMEM not -ENODEV but it
would be even better to decode the actual return code from desc by using
'return PTR_ERR(desc)' instead of 'return -ENODEV'.

>  	}

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RESEND PATCH] charger-manager: Fix checking of wrong return type
  2014-03-27 16:52 ` Bartlomiej Zolnierkiewicz
@ 2014-03-28  0:52   ` Chanwoo Choi
  0 siblings, 0 replies; 3+ messages in thread
From: Chanwoo Choi @ 2014-03-28  0:52 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz
  Cc: dbaryshkov, dwmw2, myungjoo.ham, kyungmin.park, linux-kernel

Hi,

On 03/28/2014 01:52 AM, Bartlomiej Zolnierkiewicz wrote:
> 
> Hi,
> 
> On Thursday, March 27, 2014 08:56:55 PM Chanwoo Choi wrote:
>> This patch fix minor issue about checking wrong return type.
>>
>> The of_cm_parse_desc() return ERR_PTR(errnor number) when some error happen
>> in this function. But, charger_manager_probe() has only checked whether
>> desc is NULL or not. If of_cm_parse_desc() returns ERR_PTR(-ENOMEM), desc
>> isn't NULL but desc is (void *)(-ENOMEM). Althouhg some error happen for parsing
>> DT, charger_manager_probe() can't detect error of desc instance.
>>
>> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
>> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
>> ---
>>  drivers/power/charger-manager.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
>> index 9e4dab4..a10fb57 100644
>> --- a/drivers/power/charger-manager.c
>> +++ b/drivers/power/charger-manager.c
>> @@ -1677,7 +1677,7 @@ static int charger_manager_probe(struct platform_device *pdev)
>>  		}
>>  	}
>>  
>> -	if (!desc) {
>> +	if (IS_ERR(desc)) {
>>  		dev_err(&pdev->dev, "No platform data (desc) found\n");
>>  		return -ENODEV;
> 
> While you are at it you may also fix the code to return the proper error
> code.  of_cm_parse_desc() currently returns -ENOMEM not -ENODEV but it
> would be even better to decode the actual return code from desc by using
> 'return PTR_ERR(desc)' instead of 'return -ENODEV'.

I'll resend this patch after fix it.

Thanks,
Chanwoo Choi



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-03-28  0:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-27 11:56 [RESEND PATCH] charger-manager: Fix checking of wrong return type Chanwoo Choi
2014-03-27 16:52 ` Bartlomiej Zolnierkiewicz
2014-03-28  0:52   ` Chanwoo Choi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox