9
9
10
10
#include <linux/acpi.h>
11
11
#include <linux/bitmap.h>
12
+ #include <linux/cleanup.h>
12
13
#include <linux/dmi.h>
13
14
#include <linux/gpio/driver.h>
14
15
#include <linux/gpio/consumer.h>
@@ -480,8 +481,6 @@ static inline int cy8c95x0_regmap_update_bits_base(struct cy8c95x0_pinctrl *chip
480
481
if (reg == CY8C95X0_PORTSEL )
481
482
return - EINVAL ;
482
483
483
- mutex_lock (& chip -> i2c_lock );
484
-
485
484
/* Registers behind the PORTSEL mux have their own range in regmap */
486
485
if (cy8c95x0_muxed_register (reg )) {
487
486
off = CY8C95X0_MUX_REGMAP_TO_OFFSET (reg , port );
@@ -492,10 +491,11 @@ static inline int cy8c95x0_regmap_update_bits_base(struct cy8c95x0_pinctrl *chip
492
491
else
493
492
off = reg ;
494
493
}
494
+ guard (mutex )(& chip -> i2c_lock );
495
495
496
496
ret = regmap_update_bits_base (chip -> regmap , off , mask , val , change , async , force );
497
497
if (ret < 0 )
498
- goto out ;
498
+ return ret ;
499
499
500
500
/* Update the cache when a WC bit is written */
501
501
if (cy8c95x0_wc_register (reg ) && (mask & val )) {
@@ -516,8 +516,6 @@ static inline int cy8c95x0_regmap_update_bits_base(struct cy8c95x0_pinctrl *chip
516
516
regcache_cache_only (chip -> regmap , false);
517
517
}
518
518
}
519
- out :
520
- mutex_unlock (& chip -> i2c_lock );
521
519
522
520
return ret ;
523
521
}
@@ -591,8 +589,6 @@ static int cy8c95x0_regmap_read(struct cy8c95x0_pinctrl *chip, unsigned int reg,
591
589
{
592
590
int off , ret ;
593
591
594
- mutex_lock (& chip -> i2c_lock );
595
-
596
592
/* Registers behind the PORTSEL mux have their own range in regmap */
597
593
if (cy8c95x0_muxed_register (reg )) {
598
594
off = CY8C95X0_MUX_REGMAP_TO_OFFSET (reg , port );
@@ -603,11 +599,10 @@ static int cy8c95x0_regmap_read(struct cy8c95x0_pinctrl *chip, unsigned int reg,
603
599
else
604
600
off = reg ;
605
601
}
602
+ guard (mutex )(& chip -> i2c_lock );
606
603
607
604
ret = regmap_read (chip -> regmap , off , read_val );
608
605
609
- mutex_unlock (& chip -> i2c_lock );
610
-
611
606
return ret ;
612
607
}
613
608
0 commit comments