[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMRc=Mcjbp_u0747F3P61R2a31_LMgMry7bNoxvFhvFKvE7AGw@mail.gmail.com>
Date: Thu, 12 Nov 2020 09:58:36 +0100
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Linus Walleij <linus.walleij@...aro.org>,
"open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Bartosz Golaszewski <bgolaszewski@...libre.com>
Subject: Re: [PATCH] gpiolib: devres: shrink devm_gpiochip_add_data_with_key()
On Wed, Nov 11, 2020 at 4:04 PM Andy Shevchenko
<andy.shevchenko@...il.com> wrote:
>
> On Wed, Nov 11, 2020 at 5:02 PM Andy Shevchenko
> <andy.shevchenko@...il.com> wrote:
> >
> > On Tue, Nov 10, 2020 at 11:42 AM Bartosz Golaszewski <brgl@...ev.pl> wrote:
> > >
> > > From: Bartosz Golaszewski <bgolaszewski@...libre.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
Powered by blists - more mailing lists