aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEldad Zack <eldad@fogrefinery.com>2013-04-22 19:00:41 -0400
committerTakashi Iwai <tiwai@suse.de>2013-04-29 07:36:15 -0400
commit74c34ca1cc12884703c70d34ed333517d978c2e7 (patch)
tree6d06b76a9fbe829f2427899aa708d682167420c0
parent754813473c1a8b7711802313125f0fafc60141f8 (diff)
ALSA: pcm_format_to_bits strong-typed conversion
Add a function to handle conversion from snd_pcm_format_t to bitwise with proper typing. Change such conversions to use this function and silence sparse warnings. Signed-off-by: Eldad Zack <eldad@fogrefinery.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--include/sound/pcm.h6
-rw-r--r--sound/aoa/soundbus/i2sbus/pcm.c2
-rw-r--r--sound/atmel/ac97c.c4
-rw-r--r--sound/drivers/aloop.c2
-rw-r--r--sound/pci/asihpi/asihpi.c4
-rw-r--r--sound/usb/format.c5
-rw-r--r--sound/usb/pcm.c4
-rw-r--r--sound/usb/proc.c2
8 files changed, 18 insertions, 11 deletions
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 1b0c6484e71a..5357ecbecc48 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -1133,4 +1133,10 @@ int snd_pcm_add_chmap_ctls(struct snd_pcm *pcm, int stream,
1133 unsigned long private_value, 1133 unsigned long private_value,
1134 struct snd_pcm_chmap **info_ret); 1134 struct snd_pcm_chmap **info_ret);
1135 1135
1136/* Strong-typed conversion of pcm_format to bitwise */
1137static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format)
1138{
1139 return 1ULL << (__force int) pcm_format;
1140}
1141
1136#endif /* __SOUND_PCM_H */ 1142#endif /* __SOUND_PCM_H */
diff --git a/sound/aoa/soundbus/i2sbus/pcm.c b/sound/aoa/soundbus/i2sbus/pcm.c
index 19491ed9292f..7b74a4ba75f8 100644
--- a/sound/aoa/soundbus/i2sbus/pcm.c
+++ b/sound/aoa/soundbus/i2sbus/pcm.c
@@ -179,7 +179,7 @@ static int i2sbus_pcm_open(struct i2sbus_dev *i2sdev, int in)
179 */ 179 */
180 if (other->active) { 180 if (other->active) {
181 /* FIXME: is this guaranteed by the alsa api? */ 181 /* FIXME: is this guaranteed by the alsa api? */
182 hw->formats &= (1ULL << i2sdev->format); 182 hw->formats &= pcm_format_to_bits(i2sdev->format);
183 /* see above, restrict rates to the one we already have */ 183 /* see above, restrict rates to the one we already have */
184 hw->rate_min = i2sdev->rate; 184 hw->rate_min = i2sdev->rate;
185 hw->rate_max = i2sdev->rate; 185 hw->rate_max = i2sdev->rate;
diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
index 79d6bda58753..6b7e2b5a72de 100644
--- a/sound/atmel/ac97c.c
+++ b/sound/atmel/ac97c.c
@@ -182,7 +182,7 @@ static int atmel_ac97c_playback_open(struct snd_pcm_substream *substream)
182 runtime->hw.rate_max = chip->cur_rate; 182 runtime->hw.rate_max = chip->cur_rate;
183 } 183 }
184 if (chip->cur_format) 184 if (chip->cur_format)
185 runtime->hw.formats = (1ULL << chip->cur_format); 185 runtime->hw.formats = pcm_format_to_bits(chip->cur_format);
186 mutex_unlock(&opened_mutex); 186 mutex_unlock(&opened_mutex);
187 chip->playback_substream = substream; 187 chip->playback_substream = substream;
188 return 0; 188 return 0;
@@ -201,7 +201,7 @@ static int atmel_ac97c_capture_open(struct snd_pcm_substream *substream)
201 runtime->hw.rate_max = chip->cur_rate; 201 runtime->hw.rate_max = chip->cur_rate;
202 } 202 }
203 if (chip->cur_format) 203 if (chip->cur_format)
204 runtime->hw.formats = (1ULL << chip->cur_format); 204 runtime->hw.formats = pcm_format_to_bits(chip->cur_format);
205 mutex_unlock(&opened_mutex); 205 mutex_unlock(&opened_mutex);
206 chip->capture_substream = substream; 206 chip->capture_substream = substream;
207 return 0; 207 return 0;
diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c
index 64d534710b51..6f78de9c6fb6 100644
--- a/sound/drivers/aloop.c
+++ b/sound/drivers/aloop.c
@@ -325,7 +325,7 @@ static void params_change(struct snd_pcm_substream *substream)
325 struct loopback_pcm *dpcm = runtime->private_data; 325 struct loopback_pcm *dpcm = runtime->private_data;
326 struct loopback_cable *cable = dpcm->cable; 326 struct loopback_cable *cable = dpcm->cable;
327 327
328 cable->hw.formats = (1ULL << runtime->format); 328 cable->hw.formats = pcm_format_to_bits(runtime->format);
329 cable->hw.rate_min = runtime->rate; 329 cable->hw.rate_min = runtime->rate;
330 cable->hw.rate_max = runtime->rate; 330 cable->hw.rate_max = runtime->rate;
331 cable->hw.channels_min = runtime->channels; 331 cable->hw.channels_min = runtime->channels;
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c
index 0aabfedeecba..160cf830d327 100644
--- a/sound/pci/asihpi/asihpi.c
+++ b/sound/pci/asihpi/asihpi.c
@@ -966,7 +966,7 @@ static u64 snd_card_asihpi_playback_formats(struct snd_card_asihpi *asihpi,
966 if (!err) 966 if (!err)
967 err = hpi_outstream_query_format(h_stream, &hpi_format); 967 err = hpi_outstream_query_format(h_stream, &hpi_format);
968 if (!err && (hpi_to_alsa_formats[format] != -1)) 968 if (!err && (hpi_to_alsa_formats[format] != -1))
969 formats |= (1ULL << hpi_to_alsa_formats[format]); 969 formats |= pcm_format_to_bits(hpi_to_alsa_formats[format]);
970 } 970 }
971 return formats; 971 return formats;
972} 972}
@@ -1142,7 +1142,7 @@ static u64 snd_card_asihpi_capture_formats(struct snd_card_asihpi *asihpi,
1142 if (!err) 1142 if (!err)
1143 err = hpi_instream_query_format(h_stream, &hpi_format); 1143 err = hpi_instream_query_format(h_stream, &hpi_format);
1144 if (!err) 1144 if (!err)
1145 formats |= (1ULL << hpi_to_alsa_formats[format]); 1145 formats |= pcm_format_to_bits(hpi_to_alsa_formats[format]);
1146 } 1146 }
1147 return formats; 1147 return formats;
1148} 1148}
diff --git a/sound/usb/format.c b/sound/usb/format.c
index 020ede0259eb..99299ffb33ac 100644
--- a/sound/usb/format.c
+++ b/sound/usb/format.c
@@ -365,7 +365,8 @@ static int parse_audio_format_i(struct snd_usb_audio *chip,
365{ 365{
366 struct usb_interface_descriptor *altsd = get_iface_desc(iface); 366 struct usb_interface_descriptor *altsd = get_iface_desc(iface);
367 int protocol = altsd->bInterfaceProtocol; 367 int protocol = altsd->bInterfaceProtocol;
368 int pcm_format, ret; 368 snd_pcm_format_t pcm_format;
369 int ret;
369 370
370 if (fmt->bFormatType == UAC_FORMAT_TYPE_III) { 371 if (fmt->bFormatType == UAC_FORMAT_TYPE_III) {
371 /* FIXME: the format type is really IECxxx 372 /* FIXME: the format type is really IECxxx
@@ -384,7 +385,7 @@ static int parse_audio_format_i(struct snd_usb_audio *chip,
384 default: 385 default:
385 pcm_format = SNDRV_PCM_FORMAT_S16_LE; 386 pcm_format = SNDRV_PCM_FORMAT_S16_LE;
386 } 387 }
387 fp->formats = 1uLL << pcm_format; 388 fp->formats = pcm_format_to_bits(pcm_format);
388 } else { 389 } else {
389 fp->formats = parse_audio_format_i_type(chip, fp, format, 390 fp->formats = parse_audio_format_i_type(chip, fp, format,
390 fmt, protocol); 391 fmt, protocol);
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 9723f3ceb155..93b6e32cfead 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -100,7 +100,7 @@ static struct audioformat *find_format(struct snd_usb_substream *subs)
100 int cur_attr = 0, attr; 100 int cur_attr = 0, attr;
101 101
102 list_for_each_entry(fp, &subs->fmt_list, list) { 102 list_for_each_entry(fp, &subs->fmt_list, list) {
103 if (!(fp->formats & (1uLL << subs->pcm_format))) 103 if (!(fp->formats & pcm_format_to_bits(subs->pcm_format)))
104 continue; 104 continue;
105 if (fp->channels != subs->channels) 105 if (fp->channels != subs->channels)
106 continue; 106 continue;
@@ -478,7 +478,7 @@ static int match_endpoint_audioformats(struct audioformat *fp,
478 return 0; 478 return 0;
479 } 479 }
480 480
481 if (!(fp->formats & (1ULL << pcm_format))) { 481 if (!(fp->formats & pcm_format_to_bits(pcm_format))) {
482 snd_printdd("%s: (fmt @%p) no match for format %d\n", __func__, 482 snd_printdd("%s: (fmt @%p) no match for format %d\n", __func__,
483 fp, pcm_format); 483 fp, pcm_format);
484 return 0; 484 return 0;
diff --git a/sound/usb/proc.c b/sound/usb/proc.c
index 0182ef634d8b..135c76871063 100644
--- a/sound/usb/proc.c
+++ b/sound/usb/proc.c
@@ -85,7 +85,7 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s
85 snd_iprintf(buffer, " Altset %d\n", fp->altsetting); 85 snd_iprintf(buffer, " Altset %d\n", fp->altsetting);
86 snd_iprintf(buffer, " Format:"); 86 snd_iprintf(buffer, " Format:");
87 for (fmt = 0; fmt <= SNDRV_PCM_FORMAT_LAST; ++fmt) 87 for (fmt = 0; fmt <= SNDRV_PCM_FORMAT_LAST; ++fmt)
88 if (fp->formats & (1uLL << fmt)) 88 if (fp->formats & pcm_format_to_bits(fmt))
89 snd_iprintf(buffer, " %s", 89 snd_iprintf(buffer, " %s",
90 snd_pcm_format_name(fmt)); 90 snd_pcm_format_name(fmt));
91 snd_iprintf(buffer, "\n"); 91 snd_iprintf(buffer, "\n");