mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-24 06:44:23 +08:00
ALSA: pcm: Use standard macros for fixing PCM format cast
Simplify the code with the new macros for PCM format type iterations. This fixes the sparse warnings nicely: sound/core/pcm_native.c:2302:26: warning: restricted snd_pcm_format_t degrades to integer sound/core/pcm_native.c:2306:54: warning: incorrect type in argument 1 (different base types) sound/core/pcm_native.c:2306:54: expected restricted snd_pcm_format_t [usertype] format sound/core/pcm_native.c:2306:54: got unsigned int [assigned] k .... No functional changes, just sparse warning fixes. Link: https://lore.kernel.org/r/20200206163945.6797-6-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
c5f72ef15c
commit
ba71d227f4
@ -884,20 +884,17 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
|
||||
sformat = snd_pcm_plug_slave_format(format, sformat_mask);
|
||||
|
||||
if ((__force int)sformat < 0 ||
|
||||
!snd_mask_test(sformat_mask, (__force int)sformat)) {
|
||||
for (sformat = (__force snd_pcm_format_t)0;
|
||||
(__force int)sformat <= (__force int)SNDRV_PCM_FORMAT_LAST;
|
||||
sformat = (__force snd_pcm_format_t)((__force int)sformat + 1)) {
|
||||
if (snd_mask_test(sformat_mask, (__force int)sformat) &&
|
||||
!snd_mask_test_format(sformat_mask, sformat)) {
|
||||
pcm_for_each_format(sformat) {
|
||||
if (snd_mask_test_format(sformat_mask, sformat) &&
|
||||
snd_pcm_oss_format_to(sformat) >= 0)
|
||||
break;
|
||||
}
|
||||
if ((__force int)sformat > (__force int)SNDRV_PCM_FORMAT_LAST) {
|
||||
pcm_dbg(substream->pcm, "Cannot find a format!!!\n");
|
||||
err = -EINVAL;
|
||||
goto failure;
|
||||
goto format_found;
|
||||
}
|
||||
pcm_dbg(substream->pcm, "Cannot find a format!!!\n");
|
||||
err = -EINVAL;
|
||||
goto failure;
|
||||
}
|
||||
format_found:
|
||||
err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, (__force int)sformat, 0);
|
||||
if (err < 0)
|
||||
goto failure;
|
||||
|
@ -2293,21 +2293,21 @@ static int snd_pcm_hw_rule_mulkdiv(struct snd_pcm_hw_params *params,
|
||||
static int snd_pcm_hw_rule_format(struct snd_pcm_hw_params *params,
|
||||
struct snd_pcm_hw_rule *rule)
|
||||
{
|
||||
unsigned int k;
|
||||
snd_pcm_format_t k;
|
||||
const struct snd_interval *i =
|
||||
hw_param_interval_c(params, rule->deps[0]);
|
||||
struct snd_mask m;
|
||||
struct snd_mask *mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
|
||||
snd_mask_any(&m);
|
||||
for (k = 0; k <= SNDRV_PCM_FORMAT_LAST; ++k) {
|
||||
pcm_for_each_format(k) {
|
||||
int bits;
|
||||
if (! snd_mask_test(mask, k))
|
||||
if (!snd_mask_test_format(mask, k))
|
||||
continue;
|
||||
bits = snd_pcm_format_physical_width(k);
|
||||
if (bits <= 0)
|
||||
continue; /* ignore invalid formats */
|
||||
if ((unsigned)bits < i->min || (unsigned)bits > i->max)
|
||||
snd_mask_reset(&m, k);
|
||||
snd_mask_reset(&m, (__force unsigned)k);
|
||||
}
|
||||
return snd_mask_refine(mask, &m);
|
||||
}
|
||||
@ -2316,14 +2316,15 @@ static int snd_pcm_hw_rule_sample_bits(struct snd_pcm_hw_params *params,
|
||||
struct snd_pcm_hw_rule *rule)
|
||||
{
|
||||
struct snd_interval t;
|
||||
unsigned int k;
|
||||
snd_pcm_format_t k;
|
||||
|
||||
t.min = UINT_MAX;
|
||||
t.max = 0;
|
||||
t.openmin = 0;
|
||||
t.openmax = 0;
|
||||
for (k = 0; k <= SNDRV_PCM_FORMAT_LAST; ++k) {
|
||||
pcm_for_each_format(k) {
|
||||
int bits;
|
||||
if (! snd_mask_test(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT), k))
|
||||
if (!snd_mask_test_format(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT), k))
|
||||
continue;
|
||||
bits = snd_pcm_format_physical_width(k);
|
||||
if (bits <= 0)
|
||||
|
Loading…
Reference in New Issue
Block a user