diff mbox

ASoC: Intel: fix machine driver warnings

Message ID 1423181956-108810-1-git-send-email-yang.a.fang@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

yang.a.fang@intel.com Feb. 6, 2015, 12:19 a.m. UTC
From: "Fang, Yang A" <yang.a.fang@intel.com>

this patch will fix below sparse warnings

warning: incorrect type in argument 2 (different base types)
expected unsigned int [unsigned] val
got restricted snd_pcm_format_t [usertype] <noident>

sound/soc/intel/haswell.c:61:37
sound/soc/intel/broadwell.c:115:37:
sound/soc/intel/bytcr_dpcm_rt5640.c:118:37:
sound/soc/intel/cht_bsw_rt5672.c:183:37:
sound/soc/intel/cht_bsw_rt5645.c:208:37:

Signed-off-by: Fang, Yang A <yang.a.fang@intel.com>
---
 sound/soc/intel/broadwell.c         |    2 +-
 sound/soc/intel/bytcr_dpcm_rt5640.c |    2 +-
 sound/soc/intel/cht_bsw_rt5645.c    |    2 +-
 sound/soc/intel/cht_bsw_rt5672.c    |    2 +-
 sound/soc/intel/haswell.c           |    2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

Comments

Takashi Iwai Feb. 6, 2015, 7:22 a.m. UTC | #1
At Thu,  5 Feb 2015 16:19:16 -0800,
yang.a.fang@intel.com wrote:
> 
> From: "Fang, Yang A" <yang.a.fang@intel.com>
> 
> this patch will fix below sparse warnings
> 
> warning: incorrect type in argument 2 (different base types)
> expected unsigned int [unsigned] val
> got restricted snd_pcm_format_t [usertype] <noident>
> 
> sound/soc/intel/haswell.c:61:37
> sound/soc/intel/broadwell.c:115:37:
> sound/soc/intel/bytcr_dpcm_rt5640.c:118:37:
> sound/soc/intel/cht_bsw_rt5672.c:183:37:
> sound/soc/intel/cht_bsw_rt5645.c:208:37:
> 
> Signed-off-by: Fang, Yang A <yang.a.fang@intel.com>
> ---
>  sound/soc/intel/broadwell.c         |    2 +-
>  sound/soc/intel/bytcr_dpcm_rt5640.c |    2 +-
>  sound/soc/intel/cht_bsw_rt5645.c    |    2 +-
>  sound/soc/intel/cht_bsw_rt5672.c    |    2 +-
>  sound/soc/intel/haswell.c           |    2 +-
>  5 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/sound/soc/intel/broadwell.c b/sound/soc/intel/broadwell.c
> index 9cf7d01..0ca4015 100644
> --- a/sound/soc/intel/broadwell.c
> +++ b/sound/soc/intel/broadwell.c
> @@ -112,7 +112,7 @@ static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
>  	/* set SSP0 to 16 bit */
>  	snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
>  				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
> -				    SNDRV_PCM_FORMAT_S16_LE);
> +				    (__force int)SNDRV_PCM_FORMAT_S16_LE);
>  	return 0;
>  }

Oh, it's ugly, but unavoidable as long as we use this form.

Maybe it's better to provide a helper, e.g. params_set_format() to do
the forced cast.

Also, it would be possible to provide the whole hw constraints stuff
to make it working independently.  But I guess it's overkill for DPCM
hwparam fixups.


Takashi
yang.a.fang@intel.com Feb. 6, 2015, 7:42 a.m. UTC | #2
> -----Original Message-----
> From: Takashi Iwai [mailto:tiwai@suse.de]
> Sent: Thursday, February 05, 2015 11:23 PM
> To: Fang, Yang A
> Cc: broonie@kernel.org; lgirdwood@gmail.com; alsa-devel@alsa-project.org;
> Iriawan, Denny; N, Harshapriya; Jain, Praveen K; Strasser, Kevin; Koul, Vinod;
> Lin, Mengdong
> Subject: Re: [alsa-devel] [PATCH] ASoC: Intel: fix machine driver warnings
> 
> At Thu,  5 Feb 2015 16:19:16 -0800,
> yang.a.fang@intel.com wrote:
> >
> > From: "Fang, Yang A" <yang.a.fang@intel.com>
> >
> > this patch will fix below sparse warnings
> >
> > warning: incorrect type in argument 2 (different base types) expected
> > unsigned int [unsigned] val got restricted snd_pcm_format_t [usertype]
> > <noident>
> >
> > sound/soc/intel/haswell.c:61:37
> > sound/soc/intel/broadwell.c:115:37:
> > sound/soc/intel/bytcr_dpcm_rt5640.c:118:37:
> > sound/soc/intel/cht_bsw_rt5672.c:183:37:
> > sound/soc/intel/cht_bsw_rt5645.c:208:37:
> >
> > Signed-off-by: Fang, Yang A <yang.a.fang@intel.com>
> > ---
> >  sound/soc/intel/broadwell.c         |    2 +-
> >  sound/soc/intel/bytcr_dpcm_rt5640.c |    2 +-
> >  sound/soc/intel/cht_bsw_rt5645.c    |    2 +-
> >  sound/soc/intel/cht_bsw_rt5672.c    |    2 +-
> >  sound/soc/intel/haswell.c           |    2 +-
> >  5 files changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/sound/soc/intel/broadwell.c b/sound/soc/intel/broadwell.c
> > index 9cf7d01..0ca4015 100644
> > --- a/sound/soc/intel/broadwell.c
> > +++ b/sound/soc/intel/broadwell.c
> > @@ -112,7 +112,7 @@ static int broadwell_ssp0_fixup(struct
> snd_soc_pcm_runtime *rtd,
> >  	/* set SSP0 to 16 bit */
> >  	snd_mask_set(&params-
> >masks[SNDRV_PCM_HW_PARAM_FORMAT -
> >  				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
> > -				    SNDRV_PCM_FORMAT_S16_LE);
> > +				    (__force
> int)SNDRV_PCM_FORMAT_S16_LE);
> >  	return 0;
> >  }
> 
> Oh, it's ugly, but unavoidable as long as we use this form.
> 
> Maybe it's better to provide a helper, e.g. params_set_format() to do the
> forced cast.
> 
> Also, it would be possible to provide the whole hw constraints stuff to make
> it working independently.  But I guess it's overkill for DPCM hwparam fixups.
> 
> 
> Takashi

Hi Takashi,

Thanks for the feedback. Are you looking for something like this?
> >masks[SNDRV_PCM_HW_PARAM_FORMAT -
> >  				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
> > -				    SNDRV_PCM_FORMAT_S16_LE);
> > +				   params_set_format( SNDRV_PCM_FORMAT_S16_LE));
Takashi Iwai Feb. 6, 2015, 7:46 a.m. UTC | #3
At Fri, 6 Feb 2015 07:42:03 +0000,
Fang, Yang A wrote:
> 
> > -----Original Message-----
> > From: Takashi Iwai [mailto:tiwai@suse.de]
> > Sent: Thursday, February 05, 2015 11:23 PM
> > To: Fang, Yang A
> > Cc: broonie@kernel.org; lgirdwood@gmail.com; alsa-devel@alsa-project.org;
> > Iriawan, Denny; N, Harshapriya; Jain, Praveen K; Strasser, Kevin; Koul, Vinod;
> > Lin, Mengdong
> > Subject: Re: [alsa-devel] [PATCH] ASoC: Intel: fix machine driver warnings
> > 
> > At Thu,  5 Feb 2015 16:19:16 -0800,
> > yang.a.fang@intel.com wrote:
> > >
> > > From: "Fang, Yang A" <yang.a.fang@intel.com>
> > >
> > > this patch will fix below sparse warnings
> > >
> > > warning: incorrect type in argument 2 (different base types) expected
> > > unsigned int [unsigned] val got restricted snd_pcm_format_t [usertype]
> > > <noident>
> > >
> > > sound/soc/intel/haswell.c:61:37
> > > sound/soc/intel/broadwell.c:115:37:
> > > sound/soc/intel/bytcr_dpcm_rt5640.c:118:37:
> > > sound/soc/intel/cht_bsw_rt5672.c:183:37:
> > > sound/soc/intel/cht_bsw_rt5645.c:208:37:
> > >
> > > Signed-off-by: Fang, Yang A <yang.a.fang@intel.com>
> > > ---
> > >  sound/soc/intel/broadwell.c         |    2 +-
> > >  sound/soc/intel/bytcr_dpcm_rt5640.c |    2 +-
> > >  sound/soc/intel/cht_bsw_rt5645.c    |    2 +-
> > >  sound/soc/intel/cht_bsw_rt5672.c    |    2 +-
> > >  sound/soc/intel/haswell.c           |    2 +-
> > >  5 files changed, 5 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/sound/soc/intel/broadwell.c b/sound/soc/intel/broadwell.c
> > > index 9cf7d01..0ca4015 100644
> > > --- a/sound/soc/intel/broadwell.c
> > > +++ b/sound/soc/intel/broadwell.c
> > > @@ -112,7 +112,7 @@ static int broadwell_ssp0_fixup(struct
> > snd_soc_pcm_runtime *rtd,
> > >  	/* set SSP0 to 16 bit */
> > >  	snd_mask_set(&params-
> > >masks[SNDRV_PCM_HW_PARAM_FORMAT -
> > >  				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
> > > -				    SNDRV_PCM_FORMAT_S16_LE);
> > > +				    (__force
> > int)SNDRV_PCM_FORMAT_S16_LE);
> > >  	return 0;
> > >  }
> > 
> > Oh, it's ugly, but unavoidable as long as we use this form.
> > 
> > Maybe it's better to provide a helper, e.g. params_set_format() to do the
> > forced cast.
> > 
> > Also, it would be possible to provide the whole hw constraints stuff to make
> > it working independently.  But I guess it's overkill for DPCM hwparam fixups.
> > 
> > 
> > Takashi
> 
> Hi Takashi,
> 
> Thanks for the feedback. Are you looking for something like this?
> > >masks[SNDRV_PCM_HW_PARAM_FORMAT -
> > >  				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
> > > -				    SNDRV_PCM_FORMAT_S16_LE);
> > > +				   params_set_format( SNDRV_PCM_FORMAT_S16_LE));

No, something like below in pcm_params.h:

static inline void params_set_format(struct snd_pcm_hw_params *p,
				     snd_pcm_format_t format)
{
	snd_mask_set(p, (__force int)format);
}


Takashi
yang.a.fang@intel.com Feb. 6, 2015, 7:49 a.m. UTC | #4
> -----Original Message-----
> From: Takashi Iwai [mailto:tiwai@suse.de]
> Sent: Thursday, February 05, 2015 11:47 PM
> To: Fang, Yang A
> Cc: broonie@kernel.org; lgirdwood@gmail.com; alsa-devel@alsa-project.org;
> Iriawan, Denny; N, Harshapriya; Jain, Praveen K; Strasser, Kevin; Koul, Vinod;
> Lin, Mengdong
> Subject: Re: [alsa-devel] [PATCH] ASoC: Intel: fix machine driver warnings
> 
> At Fri, 6 Feb 2015 07:42:03 +0000,
> Fang, Yang A wrote:
> >
> > > -----Original Message-----
> > > From: Takashi Iwai [mailto:tiwai@suse.de]
> > > Sent: Thursday, February 05, 2015 11:23 PM
> > > To: Fang, Yang A
> > > Cc: broonie@kernel.org; lgirdwood@gmail.com;
> > > alsa-devel@alsa-project.org; Iriawan, Denny; N, Harshapriya; Jain,
> > > Praveen K; Strasser, Kevin; Koul, Vinod; Lin, Mengdong
> > > Subject: Re: [alsa-devel] [PATCH] ASoC: Intel: fix machine driver
> > > warnings
> > >
> > > At Thu,  5 Feb 2015 16:19:16 -0800,
> > > yang.a.fang@intel.com wrote:
> > > >
> > > > From: "Fang, Yang A" <yang.a.fang@intel.com>
> > > >
> > > > this patch will fix below sparse warnings
> > > >
> > > > warning: incorrect type in argument 2 (different base types)
> > > > expected unsigned int [unsigned] val got restricted
> > > > snd_pcm_format_t [usertype] <noident>
> > > >
> > > > sound/soc/intel/haswell.c:61:37
> > > > sound/soc/intel/broadwell.c:115:37:
> > > > sound/soc/intel/bytcr_dpcm_rt5640.c:118:37:
> > > > sound/soc/intel/cht_bsw_rt5672.c:183:37:
> > > > sound/soc/intel/cht_bsw_rt5645.c:208:37:
> > > >
> > > > Signed-off-by: Fang, Yang A <yang.a.fang@intel.com>
> > > > ---
> > > >  sound/soc/intel/broadwell.c         |    2 +-
> > > >  sound/soc/intel/bytcr_dpcm_rt5640.c |    2 +-
> > > >  sound/soc/intel/cht_bsw_rt5645.c    |    2 +-
> > > >  sound/soc/intel/cht_bsw_rt5672.c    |    2 +-
> > > >  sound/soc/intel/haswell.c           |    2 +-
> > > >  5 files changed, 5 insertions(+), 5 deletions(-)
> > > >
> > > > diff --git a/sound/soc/intel/broadwell.c
> > > > b/sound/soc/intel/broadwell.c index 9cf7d01..0ca4015 100644
> > > > --- a/sound/soc/intel/broadwell.c
> > > > +++ b/sound/soc/intel/broadwell.c
> > > > @@ -112,7 +112,7 @@ static int broadwell_ssp0_fixup(struct
> > > snd_soc_pcm_runtime *rtd,
> > > >  	/* set SSP0 to 16 bit */
> > > >  	snd_mask_set(&params-
> > > >masks[SNDRV_PCM_HW_PARAM_FORMAT -
> > > >  				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
> > > > -				    SNDRV_PCM_FORMAT_S16_LE);
> > > > +				    (__force
> > > int)SNDRV_PCM_FORMAT_S16_LE);
> > > >  	return 0;
> > > >  }
> > >
> > > Oh, it's ugly, but unavoidable as long as we use this form.
> > >
> > > Maybe it's better to provide a helper, e.g. params_set_format() to
> > > do the forced cast.
> > >
> > > Also, it would be possible to provide the whole hw constraints stuff
> > > to make it working independently.  But I guess it's overkill for DPCM
> hwparam fixups.
> > >
> > >
> > > Takashi
> >
> > Hi Takashi,
> >
> > Thanks for the feedback. Are you looking for something like this?
> > > >masks[SNDRV_PCM_HW_PARAM_FORMAT -
> > > >  				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
> > > > -				    SNDRV_PCM_FORMAT_S16_LE);
> > > > +
> params_set_format( SNDRV_PCM_FORMAT_S16_LE));
> 
> No, something like below in pcm_params.h:
> 
> static inline void params_set_format(struct snd_pcm_hw_params *p,
> 				     snd_pcm_format_t format)
> {
> 	snd_mask_set(p, (__force int)format);
> }
> 
> 
> Takashi

I see. 

Thanks
Yang
diff mbox

Patch

diff --git a/sound/soc/intel/broadwell.c b/sound/soc/intel/broadwell.c
index 9cf7d01..0ca4015 100644
--- a/sound/soc/intel/broadwell.c
+++ b/sound/soc/intel/broadwell.c
@@ -112,7 +112,7 @@  static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
 	/* set SSP0 to 16 bit */
 	snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
 				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
-				    SNDRV_PCM_FORMAT_S16_LE);
+				    (__force int)SNDRV_PCM_FORMAT_S16_LE);
 	return 0;
 }
 
diff --git a/sound/soc/intel/bytcr_dpcm_rt5640.c b/sound/soc/intel/bytcr_dpcm_rt5640.c
index 5930862..b171443 100644
--- a/sound/soc/intel/bytcr_dpcm_rt5640.c
+++ b/sound/soc/intel/bytcr_dpcm_rt5640.c
@@ -115,7 +115,7 @@  static int byt_codec_fixup(struct snd_soc_pcm_runtime *rtd,
 	/* set SSP2 to 24-bit */
 	snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
 				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
-				    SNDRV_PCM_FORMAT_S24_LE);
+				    (__force int)SNDRV_PCM_FORMAT_S24_LE);
 	return 0;
 }
 
diff --git a/sound/soc/intel/cht_bsw_rt5645.c b/sound/soc/intel/cht_bsw_rt5645.c
index b6f8377..7781fbe 100644
--- a/sound/soc/intel/cht_bsw_rt5645.c
+++ b/sound/soc/intel/cht_bsw_rt5645.c
@@ -205,7 +205,7 @@  static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd,
 	/* set SSP2 to 24-bit */
 	snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
 				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
-				    SNDRV_PCM_FORMAT_S24_LE);
+				    (__force int)SNDRV_PCM_FORMAT_S24_LE);
 	return 0;
 }
 
diff --git a/sound/soc/intel/cht_bsw_rt5672.c b/sound/soc/intel/cht_bsw_rt5672.c
index ff01662..b1842fa 100644
--- a/sound/soc/intel/cht_bsw_rt5672.c
+++ b/sound/soc/intel/cht_bsw_rt5672.c
@@ -180,7 +180,7 @@  static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd,
 	/* set SSP2 to 24-bit */
 	snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
 				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
-				    SNDRV_PCM_FORMAT_S24_LE);
+				    (__force int)SNDRV_PCM_FORMAT_S24_LE);
 	return 0;
 }
 
diff --git a/sound/soc/intel/haswell.c b/sound/soc/intel/haswell.c
index 35edf51..b19f1ce 100644
--- a/sound/soc/intel/haswell.c
+++ b/sound/soc/intel/haswell.c
@@ -58,7 +58,7 @@  static int haswell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
 	/* set SSP0 to 16 bit */
 	snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
 				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
-				    SNDRV_PCM_FORMAT_S16_LE);
+				    (__force int)SNDRV_PCM_FORMAT_S16_LE);
 	return 0;
 }