public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Slawomir Stepien <sst@poczta.fm>
To: Jonathan Cameron <jic23@kernel.org>
Cc: lars@metafoo.de, Michael.Hennerich@analog.com, knaack.h@gmx.de,
	pmeerw@pmeerw.net, linux-iio@vger.kernel.org,
	gregkh@linuxfoundation.org
Subject: Re: [PATCH v4 1/1] staging: iio: adc: ad7280a: use devm_* APIs
Date: Sun, 4 Nov 2018 11:48:45 +0100	[thread overview]
Message-ID: <20181104104845.GA1600@x220.localdomain> (raw)
In-Reply-To: <20181103122108.6124f55a@archlinux>

On lis 03, 2018 12:21, Jonathan Cameron wrote:
> On Mon, 29 Oct 2018 17:52:41 +0100
> Slawomir Stepien <sst@poczta.fm> wrote:
> 
> > devm_* APIs are device managed and make code simpler.
> > 
> > Signed-off-by: Slawomir Stepien <sst@poczta.fm>
> Very nearly perfect (I think).
> 
> But there is one path where we don't quite manage to clean everything up.

Or maybe more than on. See below and in v5.

> > ---
> Also, I should be seeing a version log here to avoid me having to look back
> at previous versions (potentially) to remind me what needed changing.

I am so sorry about that. Will add the whole history in v5.

> > @@ -909,65 +917,41 @@ static int ad7280_probe(struct spi_device *spi)
> >  
> >  	ret = ad7280_attr_init(st);
> >  	if (ret < 0)
> > -		goto error_free_channels;
> > +		return ret;
> >  
> > -	ret = iio_device_register(indio_dev);
> > +	ret = devm_add_action(&spi->dev, ad7280_sw_power_down, st);
> >  	if (ret)
> What state are we left in if the devm_add_action fails?
> 
> Answer: Everything is unwound except the thing we were adding the action
> for.  So you need to call ad7280_sw_power_down in the error path here.

OK. I have also moved the devm_add_action call just after spi_setup in v5. So
the action will be also called for fail in: ad7280_chain_setup,
ad7280_channel_init and ad7280_attr_init. I think it is ok to do so if we are
calling this action also when devm_add_action fails.

> > -		goto error_free_attr;
> > +		return ret;

Thank you for review!

-- 
Slawomir Stepien

  reply	other threads:[~2018-11-04 20:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-29 16:52 [PATCH v4 1/1] staging: iio: adc: ad7280a: use devm_* APIs Slawomir Stepien
2018-11-03 12:21 ` Jonathan Cameron
2018-11-04 10:48   ` Slawomir Stepien [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-10-20 15:18 Slawomir Stepien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181104104845.GA1600@x220.localdomain \
    --to=sst@poczta.fm \
    --cc=Michael.Hennerich@analog.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox