Re: [PATCH 2/2] gpio: sim: simplify code with cleanup helpers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 15, 2023 at 10:04:32AM +0200, Linus Walleij wrote:
> On Wed, Aug 9, 2023 at 3:14 PM Bartosz Golaszewski <brgl@xxxxxxxx> wrote:
> 
> > From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
> >
> > Use macros defined in linux/cleanup.h to automate resource lifetime
> > control in the gpio-simulator.
> >
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
> (...)
> > -       mutex_lock(&chip->lock);
> > +       guard(mutex)(&chip->lock);
> (...)
> > -       mutex_lock(&chip->lock);
> > -       ret = !!test_bit(offset, chip->value_map);
> > -       mutex_unlock(&chip->lock);
> > +       scoped_guard(mutex, &chip->lock)
> > +               ret = !!test_bit(offset, chip->value_map);
> 
> This is really neat. When I grep:ed around in linux-next this seemed like
> the first user of the scoped guards, so maybe Peter Z want to take a look?

Looks about right.

> I bet there is other code using it coming for this next merge window as
> well, but this is really the first that will land in linux-next as it seems.

There's more people starting to use it indeed.

There should be some in tip/sched/core as well. I have more pending, but
got side-tracked a bit with other things :/





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux