Skip to content

Commit

Permalink
regmap: add regmap_might_sleep()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Walle authored and Mark Brown committed Nov 22, 2022
1 parent 9abf231 commit a6d9902
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions drivers/base/regmap/regmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -3486,6 +3486,19 @@ int regmap_get_reg_stride(struct regmap *map)
}
EXPORT_SYMBOL_GPL(regmap_get_reg_stride);

/**
* regmap_might_sleep() - Returns whether a regmap access might sleep.
*
* @map: Register map to operate on.
*
* Returns true if an access to the register might sleep, else false.
*/
bool regmap_might_sleep(struct regmap *map)
{
return map->can_sleep;
}
EXPORT_SYMBOL_GPL(regmap_might_sleep);

int regmap_parse_val(struct regmap *map, const void *buf,
unsigned int *val)
{
Expand Down
7 changes: 7 additions & 0 deletions include/linux/regmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,7 @@ static inline int regmap_write_bits(struct regmap *map, unsigned int reg,
int regmap_get_val_bytes(struct regmap *map);
int regmap_get_max_register(struct regmap *map);
int regmap_get_reg_stride(struct regmap *map);
bool regmap_might_sleep(struct regmap *map);
int regmap_async_complete(struct regmap *map);
bool regmap_can_raw_write(struct regmap *map);
size_t regmap_get_raw_read_max(struct regmap *map);
Expand Down Expand Up @@ -1905,6 +1906,12 @@ static inline int regmap_get_reg_stride(struct regmap *map)
return -EINVAL;
}

static inline bool regmap_might_sleep(struct regmap *map)
{
WARN_ONCE(1, "regmap API is disabled");
return true;
}

static inline int regcache_sync(struct regmap *map)
{
WARN_ONCE(1, "regmap API is disabled");
Expand Down

0 comments on commit a6d9902

Please sign in to comment.