Skip to contentSkip to conversation

ASoC: core: Use consistent byte ordering in snd_soc_bytes_get

PATCH Applied Charles Keepax 2 participants 2 messages Nov 29, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: core: Use consistent byte ordering in snd_soc_bytes_get

snd_soc_bytes_put treats the data in the binary control as big endian words, however snd_soc_bytes_get uses the endian of the host machine. This causes the two functions to be inconsistant with how the mask is applied on little endian machines.

This patch applies the big_endian format used in snd_soc_bytes_put to snd_soc_bytes_get.

---
 sound/soc/soc-core.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
sound/soc/soc-core.c +2 -2
index 4e53d87..a66783e 100644
@@ -3212,11 +3212,11 @@ int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
 			break;
 		case 2:
 			((u16 *)(&ucontrol->value.bytes.data))[0]
-				&= ~params->mask;
+				&= cpu_to_be16(~params->mask);
 			break;
 		case 4:
 			((u32 *)(&ucontrol->value.bytes.data))[0]
-				&= ~params->mask;
+				&= cpu_to_be32(~params->mask);
 			break;
 		default:
 			return -EINVAL;
Signature · 1 line
1.7.2.5
maintainer Applied
#1 lore raw
Quoted 4 lines · Charles Keepax

snd_soc_bytes_put treats the data in the binary control as big endian words, however snd_soc_bytes_get uses the endian of the host machine. This causes the two functions to be inconsistant with how the mask is applied on little endian machines.

Applied, thanks.