2013-06-25 05:18:23

by Jonghwa Lee

[permalink] [raw]
Subject: [PATCH v2] power: charger-manager: regulator_get() never returns NULL.

This patch fixes return value checking of regulator_get() in charger-manager
driver. The API, regulator_get(), returns ERR_PTR() when it fails to get
regulator with given name, not NULL.

Signed-off-by: Jonghwa Lee <[email protected]>
Signed-off-by: Myungjoo Ham <[email protected]>
---
v2:
- Fix return value to use API's directly with PTR_ERR().

drivers/power/charger-manager.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
index ba42029..0a4cce3 100644
--- a/drivers/power/charger-manager.c
+++ b/drivers/power/charger-manager.c
@@ -1239,11 +1239,10 @@ static int charger_manager_register_extcon(struct charger_manager *cm)

charger->consumer = regulator_get(cm->dev,
charger->regulator_name);
- if (charger->consumer == NULL) {
+ if (IS_ERR(charger->consumer)) {
dev_err(cm->dev, "Cannot find charger(%s)\n",
charger->regulator_name);
- ret = -EINVAL;
- goto err;
+ return PTR_ERR(charger->consumer);
}
charger->cm = cm;

--
1.7.9.5


2013-06-29 01:44:08

by Anton Vorontsov

[permalink] [raw]
Subject: Re: [PATCH v2] power: charger-manager: regulator_get() never returns NULL.

On Tue, Jun 25, 2013 at 02:54:17PM +0900, Chanwoo Choi wrote:
> Acked-by: Chanwoo Choi <[email protected]>
>
> > This patch fixes return value checking of regulator_get() in
> > charger-manager
> > driver. The API, regulator_get(), returns ERR_PTR() when it fails to get
> > regulator with given name, not NULL.
> >
> > Signed-off-by: Jonghwa Lee <[email protected]>
> > Signed-off-by: Myungjoo Ham <[email protected]>

1/2 v2 and 2/2 applied.

Thanks!

Anton