Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: nau8810: Fix incorrect type in assignment and cast to restricted __be16

This issue is reproduced when W=1 build in compiler gcc-12.
The following are sparse warnings:

sound/soc/codecs/nau8810.c:183:25: sparse: warning: incorrect type in assignment
sound/soc/codecs/nau8810.c:183:25: sparse: expected int
sound/soc/codecs/nau8810.c:183:25: sparse: got restricted __be16
sound/soc/codecs/nau8810.c:219:25: sparse: warning: cast to restricted __be16
sound/soc/codecs/nau8810.c:219:25: sparse: warning: cast to restricted __be16
sound/soc/codecs/nau8810.c:219:25: sparse: warning: cast to restricted __be16
sound/soc/codecs/nau8810.c:219:25: sparse: warning: cast to restricted __be16

This issue is not still actively checked by kernel test robot.
Actually, it is same with nau8822's sparse warnings issue.

Signed-off-by: David Lin <CTLIN0@nuvoton.com>
Link: https://lore.kernel.org/r/20231120084227.1766633-1-CTLIN0@nuvoton.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

David Lin and committed by
Mark Brown
af524e9d cac15dc2

+6 -3
+6 -3
sound/soc/codecs/nau8810.c
··· 169 169 struct soc_bytes_ext *params = (void *)kcontrol->private_value; 170 170 int i, reg, reg_val; 171 171 u16 *val; 172 + __be16 tmp; 172 173 173 174 val = (u16 *)ucontrol->value.bytes.data; 174 175 reg = NAU8810_REG_EQ1; ··· 178 177 /* conversion of 16-bit integers between native CPU format 179 178 * and big endian format 180 179 */ 181 - reg_val = cpu_to_be16(reg_val); 182 - memcpy(val + i, &reg_val, sizeof(reg_val)); 180 + tmp = cpu_to_be16(reg_val); 181 + memcpy(val + i, &tmp, sizeof(tmp)); 183 182 } 184 183 185 184 return 0; ··· 202 201 void *data; 203 202 u16 *val, value; 204 203 int i, reg, ret; 204 + __be16 *tmp; 205 205 206 206 data = kmemdup(ucontrol->value.bytes.data, 207 207 params->max, GFP_KERNEL | GFP_DMA); ··· 215 213 /* conversion of 16-bit integers between native CPU format 216 214 * and big endian format 217 215 */ 218 - value = be16_to_cpu(*(val + i)); 216 + tmp = (__be16 *)(val + i); 217 + value = be16_to_cpup(tmp); 219 218 ret = regmap_write(nau8810->regmap, reg + i, value); 220 219 if (ret) { 221 220 dev_err(component->dev, "EQ configuration fail, register: %x ret: %d\n",