1

pinctrl: cy8c95x0: Use cleanup.h

Use the guard mutex from cleanup.h to make the code more readable.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Link: https://lore.kernel.org/20240626084525.787298-1-patrick.rudolph@9elements.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Patrick Rudolph 2024-06-26 10:45:22 +02:00 committed by Linus Walleij
parent 0608235a2f
commit 710894c9d3

View File

@ -9,6 +9,7 @@
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/bitmap.h> #include <linux/bitmap.h>
#include <linux/cleanup.h>
#include <linux/dmi.h> #include <linux/dmi.h>
#include <linux/gpio/driver.h> #include <linux/gpio/driver.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
@ -480,8 +481,6 @@ static inline int cy8c95x0_regmap_update_bits_base(struct cy8c95x0_pinctrl *chip
if (reg == CY8C95X0_PORTSEL) if (reg == CY8C95X0_PORTSEL)
return -EINVAL; return -EINVAL;
mutex_lock(&chip->i2c_lock);
/* Registers behind the PORTSEL mux have their own range in regmap */ /* Registers behind the PORTSEL mux have their own range in regmap */
if (cy8c95x0_muxed_register(reg)) { if (cy8c95x0_muxed_register(reg)) {
off = CY8C95X0_MUX_REGMAP_TO_OFFSET(reg, port); off = CY8C95X0_MUX_REGMAP_TO_OFFSET(reg, port);
@ -492,10 +491,11 @@ static inline int cy8c95x0_regmap_update_bits_base(struct cy8c95x0_pinctrl *chip
else else
off = reg; off = reg;
} }
guard(mutex)(&chip->i2c_lock);
ret = regmap_update_bits_base(chip->regmap, off, mask, val, change, async, force); ret = regmap_update_bits_base(chip->regmap, off, mask, val, change, async, force);
if (ret < 0) if (ret < 0)
goto out; return ret;
/* Update the cache when a WC bit is written */ /* Update the cache when a WC bit is written */
if (cy8c95x0_wc_register(reg) && (mask & val)) { if (cy8c95x0_wc_register(reg) && (mask & val)) {
@ -516,8 +516,6 @@ static inline int cy8c95x0_regmap_update_bits_base(struct cy8c95x0_pinctrl *chip
regcache_cache_only(chip->regmap, false); regcache_cache_only(chip->regmap, false);
} }
} }
out:
mutex_unlock(&chip->i2c_lock);
return ret; return ret;
} }
@ -591,8 +589,6 @@ static int cy8c95x0_regmap_read(struct cy8c95x0_pinctrl *chip, unsigned int reg,
{ {
int off, ret; int off, ret;
mutex_lock(&chip->i2c_lock);
/* Registers behind the PORTSEL mux have their own range in regmap */ /* Registers behind the PORTSEL mux have their own range in regmap */
if (cy8c95x0_muxed_register(reg)) { if (cy8c95x0_muxed_register(reg)) {
off = CY8C95X0_MUX_REGMAP_TO_OFFSET(reg, port); off = CY8C95X0_MUX_REGMAP_TO_OFFSET(reg, port);
@ -603,11 +599,10 @@ static int cy8c95x0_regmap_read(struct cy8c95x0_pinctrl *chip, unsigned int reg,
else else
off = reg; off = reg;
} }
guard(mutex)(&chip->i2c_lock);
ret = regmap_read(chip->regmap, off, read_val); ret = regmap_read(chip->regmap, off, read_val);
mutex_unlock(&chip->i2c_lock);
return ret; return ret;
} }