* [PATCH 2/2] asoc: soc-core: use regmap's parse_val to do endian translation
@ 2014-02-19 10:44 Nenghua Cao
2014-03-06 9:46 ` Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: Nenghua Cao @ 2014-02-19 10:44 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Greg Kroah-Hartman, linux-kernel; +Cc: Nenghua Cao
From: Nenghua Cao <nhcao@marvell.com>
In snd_soc_bytes_put function, it forces cpu to do cpu_to_be translation,
but for mmio bus which uses REGMAP_ENDIAN_NATIVE, it doesn't need to do
endian translation. So it is better to use regmap's api which can decide
if this translation is needed according to bus configuration.
Signed-off-by: Nenghua Cao <nhcao@marvell.com>
---
sound/soc/soc-core.c | 34 +++++++++++++++++++++++++++++-----
1 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index fe1df50..fb598cb 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3234,7 +3234,7 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
struct soc_bytes *params = (void *)kcontrol->private_value;
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
int ret, len;
- unsigned int val;
+ unsigned int val, mask;
void *data;
if (!codec->using_regmap)
@@ -3264,12 +3264,36 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
((u8 *)data)[0] |= val;
break;
case 2:
- ((u16 *)data)[0] &= cpu_to_be16(~params->mask);
- ((u16 *)data)[0] |= cpu_to_be16(val);
+ mask = ~params->mask;
+ ret = regmap_parse_val(codec->control_data,
+ &mask, &mask);
+ if (ret != 0)
+ goto out;
+
+ ((u16 *)data)[0] &= mask;
+
+ ret = regmap_parse_val(codec->control_data,
+ &val, &val);
+ if (ret != 0)
+ goto out;
+
+ ((u16 *)data)[0] |= val;
break;
case 4:
- ((u32 *)data)[0] &= cpu_to_be32(~params->mask);
- ((u32 *)data)[0] |= cpu_to_be32(val);
+ mask = ~params->mask;
+ ret = regmap_parse_val(codec->control_data,
+ &mask, &mask);
+ if (ret != 0)
+ goto out;
+
+ ((u32 *)data)[0] &= mask;
+
+ ret = regmap_parse_val(codec->control_data,
+ &val, &val);
+ if (ret != 0)
+ goto out;
+
+ ((u32 *)data)[0] |= val;
break;
default:
ret = -EINVAL;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] asoc: soc-core: use regmap's parse_val to do endian translation
2014-02-19 10:44 [PATCH 2/2] asoc: soc-core: use regmap's parse_val to do endian translation Nenghua Cao
@ 2014-03-06 9:46 ` Mark Brown
0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2014-03-06 9:46 UTC (permalink / raw)
To: Nenghua Cao; +Cc: Liam Girdwood, Greg Kroah-Hartman, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 424 bytes --]
On Wed, Feb 19, 2014 at 06:44:58PM +0800, Nenghua Cao wrote:
> From: Nenghua Cao <nhcao@marvell.com>
>
> In snd_soc_bytes_put function, it forces cpu to do cpu_to_be translation,
> but for mmio bus which uses REGMAP_ENDIAN_NATIVE, it doesn't need to do
> endian translation. So it is better to use regmap's api which can decide
> if this translation is needed according to bus configuration.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] asoc: soc-core: use regmap's parse_val to do endian translation
2014-02-19 5:20 Nenghua Cao
@ 2014-02-19 5:28 ` Nenghua Cao
0 siblings, 0 replies; 4+ messages in thread
From: Nenghua Cao @ 2014-02-19 5:28 UTC (permalink / raw)
To: Nenghua Cao; +Cc: Liam Girdwood, Mark Brown, Greg Kroah-Hartman, linux-kernel
Update Liam and Mark's mail.
On 02/19/2014 01:20 PM, Nenghua Cao wrote:
> From: Nenghua Cao <nhcao@marvell.com>
>
> In snd_soc_bytes_put function, it forces cpu to do cpu_to_be translation,
> but for mmio bus which uses REGMAP_ENDIAN_NATIVE, it doesn't need to do
> endian translation. So it is better to use regmap's api which can decide
> if this translation is needed according to bus configuration.
>
> Signed-off-by: Nenghua Cao <nhcao@marvell.com>
> ---
> sound/soc/soc-core.c | 34 +++++++++++++++++++++++++++++-----
> 1 files changed, 29 insertions(+), 5 deletions(-)
>
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index fe1df50..fb598cb 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -3234,7 +3234,7 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
> struct soc_bytes *params = (void *)kcontrol->private_value;
> struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
> int ret, len;
> - unsigned int val;
> + unsigned int val, mask;
> void *data;
>
> if (!codec->using_regmap)
> @@ -3264,12 +3264,36 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
> ((u8 *)data)[0] |= val;
> break;
> case 2:
> - ((u16 *)data)[0] &= cpu_to_be16(~params->mask);
> - ((u16 *)data)[0] |= cpu_to_be16(val);
> + mask = ~params->mask;
> + ret = regmap_parse_val(codec->control_data,
> + &mask, &mask);
> + if (ret != 0)
> + goto out;
> +
> + ((u16 *)data)[0] &= mask;
> +
> + ret = regmap_parse_val(codec->control_data,
> + &val, &val);
> + if (ret != 0)
> + goto out;
> +
> + ((u16 *)data)[0] |= val;
> break;
> case 4:
> - ((u32 *)data)[0] &= cpu_to_be32(~params->mask);
> - ((u32 *)data)[0] |= cpu_to_be32(val);
> + mask = ~params->mask;
> + ret = regmap_parse_val(codec->control_data,
> + &mask, &mask);
> + if (ret != 0)
> + goto out;
> +
> + ((u32 *)data)[0] &= mask;
> +
> + ret = regmap_parse_val(codec->control_data,
> + &val, &val);
> + if (ret != 0)
> + goto out;
> +
> + ((u32 *)data)[0] |= val;
> break;
> default:
> ret = -EINVAL;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] asoc: soc-core: use regmap's parse_val to do endian translation
@ 2014-02-19 5:20 Nenghua Cao
2014-02-19 5:28 ` Nenghua Cao
0 siblings, 1 reply; 4+ messages in thread
From: Nenghua Cao @ 2014-02-19 5:20 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Greg Kroah-Hartman, linux-kernel; +Cc: Nenghua Cao
From: Nenghua Cao <nhcao@marvell.com>
In snd_soc_bytes_put function, it forces cpu to do cpu_to_be translation,
but for mmio bus which uses REGMAP_ENDIAN_NATIVE, it doesn't need to do
endian translation. So it is better to use regmap's api which can decide
if this translation is needed according to bus configuration.
Signed-off-by: Nenghua Cao <nhcao@marvell.com>
---
sound/soc/soc-core.c | 34 +++++++++++++++++++++++++++++-----
1 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index fe1df50..fb598cb 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3234,7 +3234,7 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
struct soc_bytes *params = (void *)kcontrol->private_value;
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
int ret, len;
- unsigned int val;
+ unsigned int val, mask;
void *data;
if (!codec->using_regmap)
@@ -3264,12 +3264,36 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
((u8 *)data)[0] |= val;
break;
case 2:
- ((u16 *)data)[0] &= cpu_to_be16(~params->mask);
- ((u16 *)data)[0] |= cpu_to_be16(val);
+ mask = ~params->mask;
+ ret = regmap_parse_val(codec->control_data,
+ &mask, &mask);
+ if (ret != 0)
+ goto out;
+
+ ((u16 *)data)[0] &= mask;
+
+ ret = regmap_parse_val(codec->control_data,
+ &val, &val);
+ if (ret != 0)
+ goto out;
+
+ ((u16 *)data)[0] |= val;
break;
case 4:
- ((u32 *)data)[0] &= cpu_to_be32(~params->mask);
- ((u32 *)data)[0] |= cpu_to_be32(val);
+ mask = ~params->mask;
+ ret = regmap_parse_val(codec->control_data,
+ &mask, &mask);
+ if (ret != 0)
+ goto out;
+
+ ((u32 *)data)[0] &= mask;
+
+ ret = regmap_parse_val(codec->control_data,
+ &val, &val);
+ if (ret != 0)
+ goto out;
+
+ ((u32 *)data)[0] |= val;
break;
default:
ret = -EINVAL;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-03-07 1:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-19 10:44 [PATCH 2/2] asoc: soc-core: use regmap's parse_val to do endian translation Nenghua Cao
2014-03-06 9:46 ` Mark Brown
-- strict thread matches above, loose matches on Subject: below --
2014-02-19 5:20 Nenghua Cao
2014-02-19 5:28 ` Nenghua Cao
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.