Skip to content

Commit a6d9902

Browse files
mwallebroonie
authored andcommitted
regmap: add regmap_might_sleep()
With the dawn of MMIO gpio-regmap users, it is desirable to let gpio-regmap ask the regmap if it might sleep during an access so it can pass that information to gpiochip. Add a new regmap_might_sleep() to query the regmap. Signed-off-by: Michael Walle <michael@walle.cc> Link: https://lore.kernel.org/r/20221121150843.1562603-1-michael@walle.cc Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 9abf231 commit a6d9902

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

drivers/base/regmap/regmap.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3486,6 +3486,19 @@ int regmap_get_reg_stride(struct regmap *map)
34863486
}
34873487
EXPORT_SYMBOL_GPL(regmap_get_reg_stride);
34883488

3489+
/**
3490+
* regmap_might_sleep() - Returns whether a regmap access might sleep.
3491+
*
3492+
* @map: Register map to operate on.
3493+
*
3494+
* Returns true if an access to the register might sleep, else false.
3495+
*/
3496+
bool regmap_might_sleep(struct regmap *map)
3497+
{
3498+
return map->can_sleep;
3499+
}
3500+
EXPORT_SYMBOL_GPL(regmap_might_sleep);
3501+
34893502
int regmap_parse_val(struct regmap *map, const void *buf,
34903503
unsigned int *val)
34913504
{

include/linux/regmap.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,7 @@ static inline int regmap_write_bits(struct regmap *map, unsigned int reg,
12191219
int regmap_get_val_bytes(struct regmap *map);
12201220
int regmap_get_max_register(struct regmap *map);
12211221
int regmap_get_reg_stride(struct regmap *map);
1222+
bool regmap_might_sleep(struct regmap *map);
12221223
int regmap_async_complete(struct regmap *map);
12231224
bool regmap_can_raw_write(struct regmap *map);
12241225
size_t regmap_get_raw_read_max(struct regmap *map);
@@ -1905,6 +1906,12 @@ static inline int regmap_get_reg_stride(struct regmap *map)
19051906
return -EINVAL;
19061907
}
19071908

1909+
static inline bool regmap_might_sleep(struct regmap *map)
1910+
{
1911+
WARN_ONCE(1, "regmap API is disabled");
1912+
return true;
1913+
}
1914+
19081915
static inline int regcache_sync(struct regmap *map)
19091916
{
19101917
WARN_ONCE(1, "regmap API is disabled");

0 commit comments

Comments
 (0)