Skip to content

Commit

Permalink
regmap: add regmap_parse_val api
Browse files Browse the repository at this point in the history
    In some cases, we need regmap's format parse_val function
to do be/le translation according to the bus configuration.
For example, snd_soc_bytes_put() uses regmap to write/read values,
and use cpu_to_be() directly to covert MASK into big endian. This
is a defect, and should use regmap's format function to do it according
to bus configuration.

Signed-off-by: Nenghua Cao <nhcao@marvell.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Nenghua Cao authored and Mark Brown committed Mar 6, 2014
1 parent 38dbfb5 commit 13ff50c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/base/regmap/regmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2240,6 +2240,18 @@ int regmap_get_val_bytes(struct regmap *map)
}
EXPORT_SYMBOL_GPL(regmap_get_val_bytes);

int regmap_parse_val(struct regmap *map, const void *buf,
unsigned int *val)
{
if (!map->format.parse_val)
return -EINVAL;

*val = map->format.parse_val(buf);

return 0;
}
EXPORT_SYMBOL_GPL(regmap_parse_val);

static int __init regmap_initcall(void)
{
regmap_debugfs_initcall();
Expand Down
9 changes: 9 additions & 0 deletions include/linux/regmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,8 @@ bool regmap_check_range_table(struct regmap *map, unsigned int reg,

int regmap_register_patch(struct regmap *map, const struct reg_default *regs,
int num_regs);
int regmap_parse_val(struct regmap *map, const void *buf,
unsigned int *val);

static inline bool regmap_reg_in_range(unsigned int reg,
const struct regmap_range *range)
Expand Down Expand Up @@ -695,6 +697,13 @@ static inline int regmap_register_patch(struct regmap *map,
return -EINVAL;
}

static inline int regmap_parse_val(struct regmap *map, const void *buf,
unsigned int *val)
{
WARN_ONCE(1, "regmap API is disabled");
return -EINVAL;
}

static inline struct regmap *dev_get_regmap(struct device *dev,
const char *name)
{
Expand Down

0 comments on commit 13ff50c

Please sign in to comment.