Skip to content

Commit 7ed310b

Browse files
Fabio Estevambroonie
authored andcommitted
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>
1 parent f91b1e7 commit 7ed310b

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎include/uapi/sound/asound.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ typedef int __bitwise snd_pcm_format_t;
242242
#define SNDRV_PCM_FORMAT_DSD_U16_BE ((__force snd_pcm_format_t) 51) /* DSD, 2-byte samples DSD (x16), big endian */
243243
#define SNDRV_PCM_FORMAT_DSD_U32_BE ((__force snd_pcm_format_t) 52) /* DSD, 4-byte samples DSD (x32), big endian */
244244
#define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_DSD_U32_BE
245+
#define SNDRV_PCM_FORMAT_FIRST SNDRV_PCM_FORMAT_S8
245246

246247
#ifdef SNDRV_LITTLE_ENDIAN
247248
#define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_LE

‎sound/soc/soc-generic-dmaengine-pcm.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea
132132
u32 addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) |
133133
BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) |
134134
BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
135-
int i, ret;
135+
snd_pcm_format_t i;
136+
int ret;
136137

137138
if (pcm->config && pcm->config->pcm_hardware)
138139
return snd_soc_set_runtime_hwparams(substream,
@@ -182,7 +183,7 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea
182183
* default assumption is that it supports 1, 2 and 4 bytes
183184
* widths.
184185
*/
185-
for (i = 0; i <= SNDRV_PCM_FORMAT_LAST; i++) {
186+
for (i = SNDRV_PCM_FORMAT_FIRST; i <= SNDRV_PCM_FORMAT_LAST; i++) {
186187
int bits = snd_pcm_format_physical_width(i);
187188

188189
/*

0 commit comments

Comments
 (0)