Re: [PATCH 3/3] leds: leds-lp55xx: Convert mutex lock/unlock to guard API

Lee Jones
2024-06-27T07:08:38Z

On Thu, 27 Jun 2024, Markus Elfring wrote:

> > Convert any entry of mutex lock/unlock to guard API and simplify code.
>
> Thanks that you would like to support another bit of collateral evolution.
>
> * Would you get into the mood to benefit any more from applications
> of scope-based resource management?
>
> * Will development interests accordingly grow to adjust further source code places
> according to known pairs of function calls?
>
>
> > With the use of guard API, handling for selttest functions can be
>
> selftest?
>
>
> > greatly simplified.
>
> I find cover letters helpful for patch series.
>
>
> …
> > +++ b/drivers/leds/leds-lp5521.c
> > @@ -9,6 +9,7 @@
> > * Milo(Woogyom) Kim <milo.kim@ti.com>
> > */
> >
> > +#include <linux/cleanup.h>
> > #include <linux/delay.h>
> > #include <linux/firmware.h>
> …
>
> I guess that this proposed addition is not directly needed here (and related places)
> because the header file is included for the macro call “DEFINE_GUARD(mutex, …)” already.
> https://elixir.bootlin.com/linux/v6.10-rc5/source/include/linux/mutex.h#L22
>
>
> …
> > @@ -185,9 +186,9 @@ static ssize_t lp5521_selftest(struct device *dev,
> > struct lp55xx_chip *chip = led->chip;
> > int ret;
> >
> > - mutex_lock(&chip->lock);
> > + guard(mutex, &chip->lock);
> > +
> > ret = lp5521_run_selftest(chip, buf);
> > - mutex_unlock(&chip->lock);
> >
> > return sysfs_emit(buf, "%s\n", ret ? "FAIL" : "OK");
> > }
> …
>
> How do you think about to omit any blank lines (also at similar places)?

Please do not omit the blank lines.

--
Lee Jones [李琼斯]