Skip to content

Commit 710894c

Browse files
PatrickRudolphlinusw
authored andcommitted
pinctrl: cy8c95x0: Use cleanup.h
Use the guard mutex from cleanup.h to make the code more readable. Signed-off-by: Patrick Rudolph <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 0608235 commit 710894c

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

drivers/pinctrl/pinctrl-cy8c95x0.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <linux/acpi.h>
1111
#include <linux/bitmap.h>
12+
#include <linux/cleanup.h>
1213
#include <linux/dmi.h>
1314
#include <linux/gpio/driver.h>
1415
#include <linux/gpio/consumer.h>
@@ -480,8 +481,6 @@ static inline int cy8c95x0_regmap_update_bits_base(struct cy8c95x0_pinctrl *chip
480481
if (reg == CY8C95X0_PORTSEL)
481482
return -EINVAL;
482483

483-
mutex_lock(&chip->i2c_lock);
484-
485484
/* Registers behind the PORTSEL mux have their own range in regmap */
486485
if (cy8c95x0_muxed_register(reg)) {
487486
off = CY8C95X0_MUX_REGMAP_TO_OFFSET(reg, port);
@@ -492,10 +491,11 @@ static inline int cy8c95x0_regmap_update_bits_base(struct cy8c95x0_pinctrl *chip
492491
else
493492
off = reg;
494493
}
494+
guard(mutex)(&chip->i2c_lock);
495495

496496
ret = regmap_update_bits_base(chip->regmap, off, mask, val, change, async, force);
497497
if (ret < 0)
498-
goto out;
498+
return ret;
499499

500500
/* Update the cache when a WC bit is written */
501501
if (cy8c95x0_wc_register(reg) && (mask & val)) {
@@ -516,8 +516,6 @@ static inline int cy8c95x0_regmap_update_bits_base(struct cy8c95x0_pinctrl *chip
516516
regcache_cache_only(chip->regmap, false);
517517
}
518518
}
519-
out:
520-
mutex_unlock(&chip->i2c_lock);
521519

522520
return ret;
523521
}
@@ -591,8 +589,6 @@ static int cy8c95x0_regmap_read(struct cy8c95x0_pinctrl *chip, unsigned int reg,
591589
{
592590
int off, ret;
593591

594-
mutex_lock(&chip->i2c_lock);
595-
596592
/* Registers behind the PORTSEL mux have their own range in regmap */
597593
if (cy8c95x0_muxed_register(reg)) {
598594
off = CY8C95X0_MUX_REGMAP_TO_OFFSET(reg, port);
@@ -603,11 +599,10 @@ static int cy8c95x0_regmap_read(struct cy8c95x0_pinctrl *chip, unsigned int reg,
603599
else
604600
off = reg;
605601
}
602+
guard(mutex)(&chip->i2c_lock);
606603

607604
ret = regmap_read(chip->regmap, off, read_val);
608605

609-
mutex_unlock(&chip->i2c_lock);
610-
611606
return ret;
612607
}
613608

0 commit comments

Comments
 (0)