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

ASoC: soc-generic-dmaengine-pcm: Fix sparse warnings

Currently the following sparse warnings are observed:

sound/soc/soc-generic-dmaengine-pcm.c:185:34: warning: restricted snd_pcm_format_t degrades to integer
sound/soc/soc-generic-dmaengine-pcm.c:186:66: warning: incorrect type in argument 1 (different base types)
sound/soc/soc-generic-dmaengine-pcm.c:186:66: expected restricted snd_pcm_format_t [usertype] format
sound/soc/soc-generic-dmaengine-pcm.c:186:66: got int [signed] [assigned] i

Fix it by changing the loop variable to be of 'snd_pcm_format_t'.

Also introduce a SNDRV_PCM_FORMAT_FIRST label, which corresponds to the
first member (index 0) of the snd_pcm_format_t formats.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Fabio Estevam and committed by
Mark Brown
7ed310bd f91b1e73

+4 -2
+1
include/uapi/sound/asound.h
··· 242 242 #define SNDRV_PCM_FORMAT_DSD_U16_BE ((__force snd_pcm_format_t) 51) /* DSD, 2-byte samples DSD (x16), big endian */ 243 243 #define SNDRV_PCM_FORMAT_DSD_U32_BE ((__force snd_pcm_format_t) 52) /* DSD, 4-byte samples DSD (x32), big endian */ 244 244 #define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_DSD_U32_BE 245 + #define SNDRV_PCM_FORMAT_FIRST SNDRV_PCM_FORMAT_S8 245 246 246 247 #ifdef SNDRV_LITTLE_ENDIAN 247 248 #define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_LE
+3 -2
sound/soc/soc-generic-dmaengine-pcm.c
··· 132 132 u32 addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | 133 133 BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | 134 134 BIT(DMA_SLAVE_BUSWIDTH_4_BYTES); 135 - int i, ret; 135 + snd_pcm_format_t i; 136 + int ret; 136 137 137 138 if (pcm->config && pcm->config->pcm_hardware) 138 139 return snd_soc_set_runtime_hwparams(substream, ··· 183 182 * default assumption is that it supports 1, 2 and 4 bytes 184 183 * widths. 185 184 */ 186 - for (i = 0; i <= SNDRV_PCM_FORMAT_LAST; i++) { 185 + for (i = SNDRV_PCM_FORMAT_FIRST; i <= SNDRV_PCM_FORMAT_LAST; i++) { 187 186 int bits = snd_pcm_format_physical_width(i); 188 187 189 188 /*