Commit 3ad00f6a authored by Ben Dooks (Codethink)'s avatar Ben Dooks (Codethink) Committed by Mark Brown

ASoC: wm8958: use <asm/unaligned.h> to simplify code

Simplify the memcpy/be32_to_cpu() code by simply using
get_unaligned_be32() throughout and makes the code nicer
to look at.

This fixes the following warnings from sparse:

sound/soc/codecs/wm8958-dsp2.c:62:26: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:62:26: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:62:26: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:62:26: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:62:26: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:62:26: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:69:15: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:69:15: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:69:15: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:69:15: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:69:15: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:69:15: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:72:18: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:72:18: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:72:18: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:72:18: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:72:18: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:72:18: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:91:17: warning: cast to restricted __be64
sound/soc/codecs/wm8958-dsp2.c:91:17: warning: cast to restricted __be64
sound/soc/codecs/wm8958-dsp2.c:91:17: warning: cast to restricted __be64
sound/soc/codecs/wm8958-dsp2.c:91:17: warning: cast to restricted __be64
sound/soc/codecs/wm8958-dsp2.c:91:17: warning: cast to restricted __be64
sound/soc/codecs/wm8958-dsp2.c:91:17: warning: cast to restricted __be64
sound/soc/codecs/wm8958-dsp2.c:91:17: warning: cast to restricted __be64
sound/soc/codecs/wm8958-dsp2.c:91:17: warning: cast to restricted __be64
sound/soc/codecs/wm8958-dsp2.c:91:17: warning: cast to restricted __be64
sound/soc/codecs/wm8958-dsp2.c:91:17: warning: cast to restricted __be64
sound/soc/codecs/wm8958-dsp2.c:108:29: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:108:29: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:108:29: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:108:29: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:108:29: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:108:29: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:120:26: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:120:26: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:120:26: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:120:26: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:120:26: warning: cast to restricted __be32
sound/soc/codecs/wm8958-dsp2.c:120:26: warning: cast to restricted __be32
Signed-off-by: default avatarBen Dooks <ben.dooks@codethink.co.uk>
Acked-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20191016120149.5860-1-ben.dooks@codethink.co.ukSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 81bd644f
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include <linux/mfd/wm8994/pdata.h> #include <linux/mfd/wm8994/pdata.h>
#include <linux/mfd/wm8994/gpio.h> #include <linux/mfd/wm8994/gpio.h>
#include <asm/unaligned.h>
#include "wm8994.h" #include "wm8994.h"
#define WM_FW_BLOCK_INFO 0xff #define WM_FW_BLOCK_INFO 0xff
...@@ -58,18 +60,15 @@ static int wm8958_dsp2_fw(struct snd_soc_component *component, const char *name, ...@@ -58,18 +60,15 @@ static int wm8958_dsp2_fw(struct snd_soc_component *component, const char *name,
} }
if (memcmp(fw->data, "WMFW", 4) != 0) { if (memcmp(fw->data, "WMFW", 4) != 0) {
memcpy(&data32, fw->data, sizeof(data32)); data32 = get_unaligned_be32(fw->data);
data32 = be32_to_cpu(data32);
dev_err(component->dev, "%s: firmware has bad file magic %08x\n", dev_err(component->dev, "%s: firmware has bad file magic %08x\n",
name, data32); name, data32);
goto err; goto err;
} }
memcpy(&data32, fw->data + 4, sizeof(data32)); len = get_unaligned_be32(fw->data + 4);
len = be32_to_cpu(data32); data32 = get_unaligned_be32(fw->data + 8);
memcpy(&data32, fw->data + 8, sizeof(data32));
data32 = be32_to_cpu(data32);
if ((data32 >> 24) & 0xff) { if ((data32 >> 24) & 0xff) {
dev_err(component->dev, "%s: unsupported firmware version %d\n", dev_err(component->dev, "%s: unsupported firmware version %d\n",
name, (data32 >> 24) & 0xff); name, (data32 >> 24) & 0xff);
...@@ -87,9 +86,8 @@ static int wm8958_dsp2_fw(struct snd_soc_component *component, const char *name, ...@@ -87,9 +86,8 @@ static int wm8958_dsp2_fw(struct snd_soc_component *component, const char *name,
} }
if (check) { if (check) {
memcpy(&data64, fw->data + 24, sizeof(u64)); data64 = get_unaligned_be64(fw->data + 24);
dev_info(component->dev, "%s timestamp %llx\n", dev_info(component->dev, "%s timestamp %llx\n", name, data64);
name, be64_to_cpu(data64));
} else { } else {
snd_soc_component_write(component, 0x102, 0x2); snd_soc_component_write(component, 0x102, 0x2);
snd_soc_component_write(component, 0x900, 0x2); snd_soc_component_write(component, 0x900, 0x2);
...@@ -104,8 +102,7 @@ static int wm8958_dsp2_fw(struct snd_soc_component *component, const char *name, ...@@ -104,8 +102,7 @@ static int wm8958_dsp2_fw(struct snd_soc_component *component, const char *name,
goto err; goto err;
} }
memcpy(&data32, data + 4, sizeof(data32)); block_len = get_unaligned_be32(data + 4);
block_len = be32_to_cpu(data32);
if (block_len + 8 > len) { if (block_len + 8 > len) {
dev_err(component->dev, "%zd byte block longer than file\n", dev_err(component->dev, "%zd byte block longer than file\n",
block_len); block_len);
...@@ -116,8 +113,7 @@ static int wm8958_dsp2_fw(struct snd_soc_component *component, const char *name, ...@@ -116,8 +113,7 @@ static int wm8958_dsp2_fw(struct snd_soc_component *component, const char *name,
goto err; goto err;
} }
memcpy(&data32, data, sizeof(data32)); data32 = get_unaligned_be32(data);
data32 = be32_to_cpu(data32);
switch ((data32 >> 24) & 0xff) { switch ((data32 >> 24) & 0xff) {
case WM_FW_BLOCK_INFO: case WM_FW_BLOCK_INFO:
......
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