From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Kent Gibson <warthog618@gmail.com>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH v3] gpio: sim: simplify code with cleanup helpers
Date: Thu, 17 Aug 2023 14:15:41 +0200 [thread overview]
Message-ID: <CAMRc=MeNvd7_g0ZpCDt5pceLFm7bbsyx4G9XQ5GzP8qUR+vAwA@mail.gmail.com> (raw)
In-Reply-To: <ZN3ncVjDn9ZXHOS5@smile.fi.intel.com>
On Thu, Aug 17, 2023 at 11:25 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Tue, Aug 15, 2023 at 09:09:55PM +0200, Bartosz Golaszewski wrote:
> > On Tue, Aug 15, 2023 at 12:31 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
> > > On Sat, Aug 12, 2023 at 08:36:35PM +0200, Bartosz Golaszewski wrote:
>
> ...
>
> > > > - mutex_lock(&chip->lock);
> > > > - __assign_bit(offset, chip->value_map, value);
> > > > - mutex_unlock(&chip->lock);
> > > > + scoped_guard(mutex, &chip->lock)
> > > > + __assign_bit(offset, chip->value_map, value);
> > >
> > > But this can also be guarded.
> > >
> > > guard(mutex)(&chip->lock);
> > >
> > > __assign_bit(offset, chip->value_map, value);
> >
> > Come on, this is total bikeshedding! I could produce ten arguments in
> > favor of the scoped variant.
> >
> > Linus acked even the previous version and Peter says it looks right. I
> > will queue it unless some *real* issues come up.
>
> I still think this will be, besides being shorter and nicer to read,
> more consistent with other simple use of "guard(); return ..." cases.
>
Scoped guards have the advantage of making it very obvious where the
critical section ends. It's really down to personal preference,
there's nothing wrong with either option.
Bart
next prev parent reply other threads:[~2023-08-17 12:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-12 18:36 [PATCH v3] gpio: sim: simplify code with cleanup helpers Bartosz Golaszewski
2023-08-15 10:30 ` Andy Shevchenko
2023-08-15 19:09 ` Bartosz Golaszewski
2023-08-17 9:25 ` Andy Shevchenko
2023-08-17 12:15 ` Bartosz Golaszewski [this message]
2023-08-18 7:50 ` Bartosz Golaszewski
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=MeNvd7_g0ZpCDt5pceLFm7bbsyx4G9XQ5GzP8qUR+vAwA@mail.gmail.com' \
--to=brgl@bgdev.pl \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bartosz.golaszewski@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=warthog618@gmail.com \
/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).