Skip to content

Commit

Permalink
ALSA: pcm: Add snd_mask_set_format() helper for standard usages
Browse files Browse the repository at this point in the history
Many drivers calling snd_mask_set() need to do ugly cast with __force
for shutting up the sparse warnings.  Actually almost all of them are
about setting the format, so it's far better to provide a common
helper snd_mask_set_format() to pass SNDRV_PCM_FORMAT_* directly
without the cast.

There are a few other calls of snd_mask_set(), but they are in the PCM
core code, so we leave them for now.

Signed-off-by: Takashi Iwai <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
tiwai authored and broonie committed Jul 26, 2018
1 parent fd56361 commit 0b62834
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions include/sound/pcm_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ static inline void snd_mask_set(struct snd_mask *mask, unsigned int val)
mask->bits[MASK_OFS(val)] |= MASK_BIT(val);
}

/* Most of drivers need only this one */
static inline void snd_mask_set_format(struct snd_mask *mask,
snd_pcm_format_t format)
{
snd_mask_set(mask, (__force unsigned int)format);
}

static inline void snd_mask_reset(struct snd_mask *mask, unsigned int val)
{
mask->bits[MASK_OFS(val)] &= ~MASK_BIT(val);
Expand Down Expand Up @@ -369,8 +376,7 @@ static inline int params_physical_width(const struct snd_pcm_hw_params *p)
static inline void
params_set_format(struct snd_pcm_hw_params *p, snd_pcm_format_t fmt)
{
snd_mask_set(hw_param_mask(p, SNDRV_PCM_HW_PARAM_FORMAT),
(__force int)fmt);
snd_mask_set_format(hw_param_mask(p, SNDRV_PCM_HW_PARAM_FORMAT), fmt);
}

#endif /* __SOUND_PCM_PARAMS_H */

0 comments on commit 0b62834

Please sign in to comment.