linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: Re: [PATCH] gpiolib: devres: shrink devm_gpiochip_add_data_with_key()
Date: Thu, 12 Nov 2020 09:58:36 +0100	[thread overview]
Message-ID: <CAMRc=Mcjbp_u0747F3P61R2a31_LMgMry7bNoxvFhvFKvE7AGw@mail.gmail.com> (raw)
In-Reply-To: <CAHp75VdoptjHM8aSiiQ7BHpYE0Zf2-Ojy55H5hTv4c_68cS1vg@mail.gmail.com>

On Wed, Nov 11, 2020 at 4:04 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Wed, Nov 11, 2020 at 5:02 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> >
> > On Tue, Nov 10, 2020 at 11:42 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> > >
> > > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > >
> > > If all we want to manage is a single pointer, there's no need to
> > > manually allocate and add a new devres. We can simply use
> > > devm_add_action_or_reset() and shrink the code by a good bit.
> >
> > Yes, it is possible to convert all one-function-based devm_*()
> > wrappers to use this approach.
> >
> > The problem is, it will call the release() function on error which is
> > new (and probably undesired) behaviour.
> > I suppose you meant devm_add_action() here.
>
> Ah, now it seems I got it. You need to release the chip in case if
> devm_add_action() fail.
> Dunno if devm_add_action() can somehow change the logic to be clearer here...
>

devm_add_action_or_reset() is correct here - it undos the previous
chip registration on error.

Bartosz

      reply	other threads:[~2020-11-12  8:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-10  9:39 [PATCH] gpiolib: devres: shrink devm_gpiochip_add_data_with_key() Bartosz Golaszewski
2020-11-11 14:56 ` Linus Walleij
2020-11-11 15:02 ` Andy Shevchenko
2020-11-11 15:05   ` Andy Shevchenko
2020-11-12  8:58     ` Bartosz Golaszewski [this message]

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='CAMRc=Mcjbp_u0747F3P61R2a31_LMgMry7bNoxvFhvFKvE7AGw@mail.gmail.com' \
    --to=brgl@bgdev.pl \
    --cc=andy.shevchenko@gmail.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).