2014-02-19 05:21:47

by Nenghua Cao

[permalink] [raw]
Subject: [PATCH 1/2] driver: regmap: add regmap_parse_val api

From: Nenghua Cao <[email protected]>

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 <[email protected]>
---
drivers/base/regmap/regmap.c | 12 ++++++++++++
include/linux/regmap.h | 9 +++++++++
2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 6a19515..4b2ed0c 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -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();
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 4149f1a..3e1a2e4 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -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)
@@ -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)
{
--
1.7.0.4


2014-02-19 05:30:13

by Nenghua Cao

[permalink] [raw]
Subject: Re: [PATCH 1/2] driver: regmap: add regmap_parse_val api

Update Liam and Mark's mail.

On 02/19/2014 01:19 PM, Nenghua Cao wrote:
> From: Nenghua Cao <[email protected]>
>
> 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 <[email protected]>
> ---
> drivers/base/regmap/regmap.c | 12 ++++++++++++
> include/linux/regmap.h | 9 +++++++++
> 2 files changed, 21 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
> index 6a19515..4b2ed0c 100644
> --- a/drivers/base/regmap/regmap.c
> +++ b/drivers/base/regmap/regmap.c
> @@ -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();
> diff --git a/include/linux/regmap.h b/include/linux/regmap.h
> index 4149f1a..3e1a2e4 100644
> --- a/include/linux/regmap.h
> +++ b/include/linux/regmap.h
> @@ -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)
> @@ -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)
> {
>

2014-02-19 07:50:53

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 1/2] driver: regmap: add regmap_parse_val api

On Wed, Feb 19, 2014 at 01:28:43PM +0800, Nenghua Cao wrote:
> Update Liam and Mark's mail.

I can't do anything useful with patches that are quoted, sorry. None of
the tools know how to strip out quotes.


Attachments:
(No filename) (209.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments

2014-02-19 10:52:05

by Nenghua Cao

[permalink] [raw]
Subject: Re: [PATCH 1/2] driver: regmap: add regmap_parse_val api

On 02/19/2014 03:50 PM, Mark Brown wrote:
> On Wed, Feb 19, 2014 at 01:28:43PM +0800, Nenghua Cao wrote:
>> Update Liam and Mark's mail.
>
> I can't do anything useful with patches that are quoted, sorry. None of
> the tools know how to strip out quotes.
>
Hi ,Mark

Sorry for giving you trouble. I also don't know how to remove
the quotes. So i just submit the patches again. Thanks!

BR
Nenghua