Re: [PATCH] gpio: max732x: use guard(mutex) to simplify locking

From: Bartosz Golaszewski

Date: Wed Mar 11 2026 - 04:50:36 EST


On Wed, 11 Mar 2026 04:12:12 +0100, Richard Lyu <richard.lyu@xxxxxxxx> said:
> Convert the max732x driver to use the RAII-based guard(mutex) macro from
> <linux/cleanup.h>. This change replaces manual mutex_lock() and
> mutex_unlock() calls, allowing the chip lock to be managed automatically
> based on function scope.
>
> Refactor max732x_gpio_set_mask() and max732x_irq_update_mask() to
> improve code readability. This allows for direct returns and removes
> the redundant 'out' label in the set_mask function, resulting in
> cleaner and more maintainable code.
>
> Signed-off-by: Richard Lyu <richard.lyu@xxxxxxxx>
> ---
> drivers/gpio/gpio-max732x.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpio/gpio-max732x.c b/drivers/gpio/gpio-max732x.c
> index a61d670ceeda..8930f49576ed 100644
> --- a/drivers/gpio/gpio-max732x.c
> +++ b/drivers/gpio/gpio-max732x.c
> @@ -18,6 +18,7 @@
> #include <linux/interrupt.h>
> #include <linux/i2c.h>
> #include <linux/platform_data/max732x.h>
> +#include <linux/cleanup.h>
>

While touching this, could you please also order includes alphabetically and
add linux/mutex.h which seems to be missing?

Bart