kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: adc128s052: Fix the error handling path of 'adc128_probe()'
@ 2021-08-21 10:37 Christophe JAILLET
  2021-08-23  6:42 ` Alexandru Ardelean
  0 siblings, 1 reply; 4+ messages in thread
From: Christophe JAILLET @ 2021-08-21 10:37 UTC (permalink / raw)
  To: jic23, lars, andy.shevchenko, angelo.compagnucci
  Cc: linux-iio, linux-kernel, kernel-janitors, Christophe JAILLET

A successful 'regulator_enable()' call should be balanced by a
corresponding 'regulator_disable()' call in the error handling path of the
probe, as already done in the remove function.

Update the error handling path accordingly.

Fixes: 913b86468674 ("iio: adc: Add TI ADC128S052")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/iio/adc/ti-adc128s052.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
index 3143f35a6509..83c1ae07b3e9 100644
--- a/drivers/iio/adc/ti-adc128s052.c
+++ b/drivers/iio/adc/ti-adc128s052.c
@@ -171,7 +171,13 @@ static int adc128_probe(struct spi_device *spi)
 	mutex_init(&adc->lock);
 
 	ret = iio_device_register(indio_dev);
+	if (ret)
+		goto err_disable_regulator;
 
+	return 0;
+
+err_disable_regulator:
+	regulator_disable(adc->reg);
 	return ret;
 }
 
-- 
2.30.2


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

* Re: [PATCH] iio: adc128s052: Fix the error handling path of 'adc128_probe()'
  2021-08-21 10:37 [PATCH] iio: adc128s052: Fix the error handling path of 'adc128_probe()' Christophe JAILLET
@ 2021-08-23  6:42 ` Alexandru Ardelean
  2021-08-24 19:45   ` Christophe JAILLET
  0 siblings, 1 reply; 4+ messages in thread
From: Alexandru Ardelean @ 2021-08-23  6:42 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Jonathan Cameron, Lars-Peter Clausen, Andy Shevchenko,
	angelo.compagnucci, linux-iio, LKML, kernel-janitors

On Sat, Aug 21, 2021 at 1:43 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> A successful 'regulator_enable()' call should be balanced by a
> corresponding 'regulator_disable()' call in the error handling path of the
> probe, as already done in the remove function.
>
> Update the error handling path accordingly.

Good catch.
For the fix:

Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>

If you want, you can also send a conversion to
devm_iio_device_register() for this driver.
And also move the regulator_disable() on a devm_add_action_or_reset() callback.
Maybe, that's already part of your plan. If so, apologies for the noise :)


>
> Fixes: 913b86468674 ("iio: adc: Add TI ADC128S052")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/iio/adc/ti-adc128s052.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
> index 3143f35a6509..83c1ae07b3e9 100644
> --- a/drivers/iio/adc/ti-adc128s052.c
> +++ b/drivers/iio/adc/ti-adc128s052.c
> @@ -171,7 +171,13 @@ static int adc128_probe(struct spi_device *spi)
>         mutex_init(&adc->lock);
>
>         ret = iio_device_register(indio_dev);
> +       if (ret)
> +               goto err_disable_regulator;
>
> +       return 0;
> +
> +err_disable_regulator:
> +       regulator_disable(adc->reg);
>         return ret;
>  }
>
> --
> 2.30.2
>

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

* Re: [PATCH] iio: adc128s052: Fix the error handling path of 'adc128_probe()'
  2021-08-23  6:42 ` Alexandru Ardelean
@ 2021-08-24 19:45   ` Christophe JAILLET
  2021-08-29 17:14     ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Christophe JAILLET @ 2021-08-24 19:45 UTC (permalink / raw)
  To: Alexandru Ardelean
  Cc: Jonathan Cameron, Lars-Peter Clausen, Andy Shevchenko,
	angelo.compagnucci, linux-iio, LKML, kernel-janitors

Le 23/08/2021 à 08:42, Alexandru Ardelean a écrit :
> On Sat, Aug 21, 2021 at 1:43 PM Christophe JAILLET
> <christophe.jaillet@wanadoo.fr> wrote:
>>
>> A successful 'regulator_enable()' call should be balanced by a
>> corresponding 'regulator_disable()' call in the error handling path of the
>> probe, as already done in the remove function.
>>
>> Update the error handling path accordingly.
> 
> Good catch.
> For the fix:
> 
> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
> 
> If you want, you can also send a conversion to
> devm_iio_device_register() for this driver.
> And also move the regulator_disable() on a devm_add_action_or_reset() callback.
> Maybe, that's already part of your plan. If so, apologies for the noise :)
> 

Hi,

I hadn't planned another step but I can send a follow-up patch for that.

CJ

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

* Re: [PATCH] iio: adc128s052: Fix the error handling path of 'adc128_probe()'
  2021-08-24 19:45   ` Christophe JAILLET
@ 2021-08-29 17:14     ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2021-08-29 17:14 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Alexandru Ardelean, Lars-Peter Clausen, Andy Shevchenko,
	angelo.compagnucci, linux-iio, LKML, kernel-janitors

On Tue, 24 Aug 2021 21:45:38 +0200
Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:

> Le 23/08/2021 à 08:42, Alexandru Ardelean a écrit :
> > On Sat, Aug 21, 2021 at 1:43 PM Christophe JAILLET
> > <christophe.jaillet@wanadoo.fr> wrote:  
> >>
> >> A successful 'regulator_enable()' call should be balanced by a
> >> corresponding 'regulator_disable()' call in the error handling path of the
> >> probe, as already done in the remove function.
> >>
> >> Update the error handling path accordingly.  
> > 
> > Good catch.
> > For the fix:
> > 
> > Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>

Applied and marked for stable.

Thanks,
> > 
> > If you want, you can also send a conversion to
> > devm_iio_device_register() for this driver.
> > And also move the regulator_disable() on a devm_add_action_or_reset() callback.
> > Maybe, that's already part of your plan. If so, apologies for the noise :)
> >   
> 
> Hi,
> 
> I hadn't planned another step but I can send a follow-up patch for that.
> 
> CJ

Note I'll have to sit on that one until this patch is upstream which will be a few weeks
(perhaps a month) given timing.

Jonathan

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

end of thread, other threads:[~2021-08-29 17:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-21 10:37 [PATCH] iio: adc128s052: Fix the error handling path of 'adc128_probe()' Christophe JAILLET
2021-08-23  6:42 ` Alexandru Ardelean
2021-08-24 19:45   ` Christophe JAILLET
2021-08-29 17:14     ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).