All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] power: supply: lp8788: Fix an error handling path in 'lp8788_charger_probe()'
@ 2020-05-08  7:11 ` Christophe JAILLET
  0 siblings, 0 replies; 6+ messages in thread
From: Christophe JAILLET @ 2020-05-08  7:11 UTC (permalink / raw)
  To: milo.kim, sre, anton.vorontsov
  Cc: linux-pm, linux-kernel, kernel-janitors, Christophe JAILLET

In case of error, resources allocated in 'lp8788_setup_adc_channel()' must
be released.

Add a call to 'lp8788_release_adc_channel()' as already done in the remove
function.

Fixes: 98a276649358 ("power_supply: Add new lp8788 charger driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/power/supply/lp8788-charger.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/lp8788-charger.c b/drivers/power/supply/lp8788-charger.c
index 84a206f42a8e..641815eb24bc 100644
--- a/drivers/power/supply/lp8788-charger.c
+++ b/drivers/power/supply/lp8788-charger.c
@@ -719,13 +719,17 @@ static int lp8788_charger_probe(struct platform_device *pdev)
 
 	ret = lp8788_psy_register(pdev, pchg);
 	if (ret)
-		return ret;
+		goto err_release_adc_channel;
 
 	ret = lp8788_irq_register(pdev, pchg);
 	if (ret)
 		dev_warn(dev, "failed to register charger irq: %d\n", ret);
 
 	return 0;
+
+err_release_adc_channel:
+	lp8788_release_adc_channel(pchg);
+	return ret;
 }
 
 static int lp8788_charger_remove(struct platform_device *pdev)
-- 
2.25.1


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

* [PATCH] power: supply: lp8788: Fix an error handling path in 'lp8788_charger_probe()'
@ 2020-05-08  7:11 ` Christophe JAILLET
  0 siblings, 0 replies; 6+ messages in thread
From: Christophe JAILLET @ 2020-05-08  7:11 UTC (permalink / raw)
  To: milo.kim, sre, anton.vorontsov
  Cc: linux-pm, linux-kernel, kernel-janitors, Christophe JAILLET

In case of error, resources allocated in 'lp8788_setup_adc_channel()' must
be released.

Add a call to 'lp8788_release_adc_channel()' as already done in the remove
function.

Fixes: 98a276649358 ("power_supply: Add new lp8788 charger driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/power/supply/lp8788-charger.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/lp8788-charger.c b/drivers/power/supply/lp8788-charger.c
index 84a206f42a8e..641815eb24bc 100644
--- a/drivers/power/supply/lp8788-charger.c
+++ b/drivers/power/supply/lp8788-charger.c
@@ -719,13 +719,17 @@ static int lp8788_charger_probe(struct platform_device *pdev)
 
 	ret = lp8788_psy_register(pdev, pchg);
 	if (ret)
-		return ret;
+		goto err_release_adc_channel;
 
 	ret = lp8788_irq_register(pdev, pchg);
 	if (ret)
 		dev_warn(dev, "failed to register charger irq: %d\n", ret);
 
 	return 0;
+
+err_release_adc_channel:
+	lp8788_release_adc_channel(pchg);
+	return ret;
 }
 
 static int lp8788_charger_remove(struct platform_device *pdev)
-- 
2.25.1

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

* Re: [PATCH] power: supply: lp8788: Fix an error handling path in lp8788_charger_probe()
  2020-05-08  7:11 ` Christophe JAILLET
@ 2020-05-08 11:25 ` Markus Elfring
  -1 siblings, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2020-05-08 11:25 UTC (permalink / raw)
  To: Christophe Jaillet, linux-pm
  Cc: kernel-janitors, linux-kernel, Anton Vorontsov, Milo Kim,
	Sebastian Reichel

> In case of error, resources allocated in 'lp8788_setup_adc_channel()' must
> be released.
>
> Add a call to 'lp8788_release_adc_channel()' as already done in the remove
> function.

I suggest to omit apostrophes from this commit message.


…
> +++ b/drivers/power/supply/lp8788-charger.c
> @@ -719,13 +719,17 @@  static int lp8788_charger_probe(struct platform_device *pdev)
>
>  	ret = lp8788_psy_register(pdev, pchg);
>  	if (ret)
> -		return ret;
> +		goto err_release_adc_channel;
>
>  	ret = lp8788_irq_register(pdev, pchg);
…

You propose to perform another channel release only once for this
function implementation.
Thus I find nicer to specify the desired exception handling in
this if branch directly.

Regards,
Markus

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

* Re: [PATCH] power: supply: lp8788: Fix an error handling path in lp8788_charger_probe()
@ 2020-05-08 11:25 ` Markus Elfring
  0 siblings, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2020-05-08 11:25 UTC (permalink / raw)
  To: Christophe Jaillet, linux-pm
  Cc: kernel-janitors, linux-kernel, Anton Vorontsov, Milo Kim,
	Sebastian Reichel

> In case of error, resources allocated in 'lp8788_setup_adc_channel()' must
> be released.
>
> Add a call to 'lp8788_release_adc_channel()' as already done in the remove
> function.

I suggest to omit apostrophes from this commit message.


…
> +++ b/drivers/power/supply/lp8788-charger.c
> @@ -719,13 +719,17 @@  static int lp8788_charger_probe(struct platform_device *pdev)
>
>  	ret = lp8788_psy_register(pdev, pchg);
>  	if (ret)
> -		return ret;
> +		goto err_release_adc_channel;
>
>  	ret = lp8788_irq_register(pdev, pchg);
…

You propose to perform another channel release only once for this
function implementation.
Thus I find nicer to specify the desired exception handling in
this if branch directly.

Regards,
Markus

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

* Re: [PATCH] power: supply: lp8788: Fix an error handling path in 'lp8788_charger_probe()'
  2020-05-08  7:11 ` Christophe JAILLET
@ 2020-05-09  0:14   ` Sebastian Reichel
  -1 siblings, 0 replies; 6+ messages in thread
From: Sebastian Reichel @ 2020-05-09  0:14 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: milo.kim, anton.vorontsov, linux-pm, linux-kernel, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1454 bytes --]

Hi,

Please change the driver to call devm_iio_channel_get() instead of
iio_channel_get() and drop the lp8788_release_adc_channel() function.

-- Sebastian

On Fri, May 08, 2020 at 09:11:50AM +0200, Christophe JAILLET wrote:
> In case of error, resources allocated in 'lp8788_setup_adc_channel()' must
> be released.
> 
> Add a call to 'lp8788_release_adc_channel()' as already done in the remove
> function.
> 
> Fixes: 98a276649358 ("power_supply: Add new lp8788 charger driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/power/supply/lp8788-charger.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/lp8788-charger.c b/drivers/power/supply/lp8788-charger.c
> index 84a206f42a8e..641815eb24bc 100644
> --- a/drivers/power/supply/lp8788-charger.c
> +++ b/drivers/power/supply/lp8788-charger.c
> @@ -719,13 +719,17 @@ static int lp8788_charger_probe(struct platform_device *pdev)
>  
>  	ret = lp8788_psy_register(pdev, pchg);
>  	if (ret)
> -		return ret;
> +		goto err_release_adc_channel;
>  
>  	ret = lp8788_irq_register(pdev, pchg);
>  	if (ret)
>  		dev_warn(dev, "failed to register charger irq: %d\n", ret);
>  
>  	return 0;
> +
> +err_release_adc_channel:
> +	lp8788_release_adc_channel(pchg);
> +	return ret;
>  }
>  
>  static int lp8788_charger_remove(struct platform_device *pdev)
> -- 
> 2.25.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] power: supply: lp8788: Fix an error handling path in 'lp8788_charger_probe()'
@ 2020-05-09  0:14   ` Sebastian Reichel
  0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Reichel @ 2020-05-09  0:14 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: milo.kim, anton.vorontsov, linux-pm, linux-kernel, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1454 bytes --]

Hi,

Please change the driver to call devm_iio_channel_get() instead of
iio_channel_get() and drop the lp8788_release_adc_channel() function.

-- Sebastian

On Fri, May 08, 2020 at 09:11:50AM +0200, Christophe JAILLET wrote:
> In case of error, resources allocated in 'lp8788_setup_adc_channel()' must
> be released.
> 
> Add a call to 'lp8788_release_adc_channel()' as already done in the remove
> function.
> 
> Fixes: 98a276649358 ("power_supply: Add new lp8788 charger driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/power/supply/lp8788-charger.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/lp8788-charger.c b/drivers/power/supply/lp8788-charger.c
> index 84a206f42a8e..641815eb24bc 100644
> --- a/drivers/power/supply/lp8788-charger.c
> +++ b/drivers/power/supply/lp8788-charger.c
> @@ -719,13 +719,17 @@ static int lp8788_charger_probe(struct platform_device *pdev)
>  
>  	ret = lp8788_psy_register(pdev, pchg);
>  	if (ret)
> -		return ret;
> +		goto err_release_adc_channel;
>  
>  	ret = lp8788_irq_register(pdev, pchg);
>  	if (ret)
>  		dev_warn(dev, "failed to register charger irq: %d\n", ret);
>  
>  	return 0;
> +
> +err_release_adc_channel:
> +	lp8788_release_adc_channel(pchg);
> +	return ret;
>  }
>  
>  static int lp8788_charger_remove(struct platform_device *pdev)
> -- 
> 2.25.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2020-05-09  0:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-08  7:11 [PATCH] power: supply: lp8788: Fix an error handling path in 'lp8788_charger_probe()' Christophe JAILLET
2020-05-08  7:11 ` Christophe JAILLET
2020-05-09  0:14 ` Sebastian Reichel
2020-05-09  0:14   ` Sebastian Reichel
2020-05-08 11:25 [PATCH] power: supply: lp8788: Fix an error handling path in lp8788_charger_probe() Markus Elfring
2020-05-08 11:25 ` Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.