Commit b5a8fe43 authored by Mark Brown's avatar Mark Brown

ASoC: core: Ensure SND_SOC_BYTES writes are from DMA safe memory

With some buses the transfers may DMAed, especially for larger blocks.
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 5d163336
...@@ -3097,9 +3097,12 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, ...@@ -3097,9 +3097,12 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
if (!codec->using_regmap) if (!codec->using_regmap)
return -EINVAL; return -EINVAL;
data = ucontrol->value.bytes.data;
len = params->num_regs * codec->val_bytes; len = params->num_regs * codec->val_bytes;
data = kmemdup(ucontrol->value.bytes.data, len, GFP_KERNEL | GFP_DMA);
if (!data)
return -ENOMEM;
/* /*
* If we've got a mask then we need to preserve the register * If we've got a mask then we need to preserve the register
* bits. We shouldn't modify the incoming data so take a * bits. We shouldn't modify the incoming data so take a
...@@ -3112,10 +3115,6 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, ...@@ -3112,10 +3115,6 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
val &= params->mask; val &= params->mask;
data = kmemdup(data, len, GFP_KERNEL);
if (!data)
return -ENOMEM;
switch (codec->val_bytes) { switch (codec->val_bytes) {
case 1: case 1:
((u8 *)data)[0] &= ~params->mask; ((u8 *)data)[0] &= ~params->mask;
...@@ -3137,7 +3136,6 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, ...@@ -3137,7 +3136,6 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
ret = regmap_raw_write(codec->control_data, params->base, ret = regmap_raw_write(codec->control_data, params->base,
data, len); data, len);
if (params->mask)
kfree(data); kfree(data);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment