All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] ASoC: PCM format type conversion fixes
@ 2018-07-25 21:17 Takashi Iwai
  2018-07-25 21:17 ` [PATCH 1/6] ALSA: pcm: Add snd_mask_set_format() helper for standard usages Takashi Iwai
                   ` (6 more replies)
  0 siblings, 7 replies; 15+ messages in thread
From: Takashi Iwai @ 2018-07-25 21:17 UTC (permalink / raw)
  To: alsa-devel
  Cc: Nicolin Chen, Lars-Peter Clausen, Timur Tabi,
	Pierre-Louis Bossart, Liam Girdwood, Mark Brown

Hi,

the PCM format is a fixed type with __bitwise, and it needs cast or
other trick to deal with integer.  This is a series of such fixes for
ASoC.


Takashi

===

Takashi Iwai (6):
  ALSA: pcm: Add snd_mask_set_format() helper for standard usages
  ASoC: doc: Replace open code with params_set_format()
  ASoC: intel: Fix snd_pcm_format_t handling
  ASoC: fsl: Use snd_mask_set_format()
  ASoC: pcm186x: Declare PCM format with snd_pcm_format_t
  ASoC: dmaengine: Use standard pcm_format_to_bits() macro

 Documentation/sound/soc/dpcm.rst                    |  4 +---
 include/sound/pcm_params.h                          | 10 ++++++++--
 sound/soc/codecs/pcm186x.c                          |  2 +-
 sound/soc/fsl/fsl-asoc-card.c                       |  2 +-
 sound/soc/intel/boards/bdw-rt5677.c                 |  4 +---
 sound/soc/intel/boards/bxt_da7219_max98357a.c       |  2 +-
 sound/soc/intel/boards/bxt_rt298.c                  |  2 +-
 sound/soc/intel/boards/kbl_da7219_max98357a.c       |  2 +-
 sound/soc/intel/boards/kbl_rt5663_max98927.c        |  4 ++--
 sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c |  4 ++--
 sound/soc/intel/boards/skl_nau88l25_max98357a.c     |  2 +-
 sound/soc/intel/boards/skl_nau88l25_ssm4567.c       |  2 +-
 sound/soc/intel/boards/skl_rt286.c                  |  2 +-
 sound/soc/soc-generic-dmaengine-pcm.c               |  2 +-
 14 files changed, 23 insertions(+), 21 deletions(-)

-- 
2.18.0

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/6] ALSA: pcm: Add snd_mask_set_format() helper for standard usages
  2018-07-25 21:17 [PATCH 0/6] ASoC: PCM format type conversion fixes Takashi Iwai
@ 2018-07-25 21:17 ` Takashi Iwai
  2018-07-26 16:11   ` Applied "ALSA: pcm: Add snd_mask_set_format() helper for standard usages" to the asoc tree Mark Brown
  2018-07-25 21:17 ` [PATCH 2/6] ASoC: doc: Replace open code with params_set_format() Takashi Iwai
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Takashi Iwai @ 2018-07-25 21:17 UTC (permalink / raw)
  To: alsa-devel
  Cc: Nicolin Chen, Lars-Peter Clausen, Timur Tabi,
	Pierre-Louis Bossart, Liam Girdwood, Mark Brown

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 <tiwai@suse.de>
---
 include/sound/pcm_params.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/sound/pcm_params.h b/include/sound/pcm_params.h
index c704357775fc..2dd37cada7c0 100644
--- a/include/sound/pcm_params.h
+++ b/include/sound/pcm_params.h
@@ -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);
@@ -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 */
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/6] ASoC: doc: Replace open code with params_set_format()
  2018-07-25 21:17 [PATCH 0/6] ASoC: PCM format type conversion fixes Takashi Iwai
  2018-07-25 21:17 ` [PATCH 1/6] ALSA: pcm: Add snd_mask_set_format() helper for standard usages Takashi Iwai
@ 2018-07-25 21:17 ` Takashi Iwai
  2018-07-26 16:11   ` Applied "ASoC: doc: Replace open code with params_set_format()" to the asoc tree Mark Brown
  2018-07-25 21:17 ` [PATCH 3/6] ASoC: intel: Fix snd_pcm_format_t handling Takashi Iwai
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Takashi Iwai @ 2018-07-25 21:17 UTC (permalink / raw)
  To: alsa-devel
  Cc: Nicolin Chen, Lars-Peter Clausen, Timur Tabi,
	Pierre-Louis Bossart, Liam Girdwood, Mark Brown

The example code in dpcm.rst contains an open code calling
snd_mask_set(), and this can be better represented with
params_set_format() instead.  This automatically fixes the sparse
warning about snd_pcm_format_t handling, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 Documentation/sound/soc/dpcm.rst | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/Documentation/sound/soc/dpcm.rst b/Documentation/sound/soc/dpcm.rst
index 395e5a516282..fe61e02277f8 100644
--- a/Documentation/sound/soc/dpcm.rst
+++ b/Documentation/sound/soc/dpcm.rst
@@ -254,9 +254,7 @@ configuration.
 	channels->min = channels->max = 2;
 
 	/* set DAI0 to 16 bit */
-	snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
-				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
-				    SNDRV_PCM_FORMAT_S16_LE);
+	params_set_format(params, SNDRV_PCM_FORMAT_S16_LE);
 	return 0;
   }
 
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/6] ASoC: intel: Fix snd_pcm_format_t handling
  2018-07-25 21:17 [PATCH 0/6] ASoC: PCM format type conversion fixes Takashi Iwai
  2018-07-25 21:17 ` [PATCH 1/6] ALSA: pcm: Add snd_mask_set_format() helper for standard usages Takashi Iwai
  2018-07-25 21:17 ` [PATCH 2/6] ASoC: doc: Replace open code with params_set_format() Takashi Iwai
@ 2018-07-25 21:17 ` Takashi Iwai
  2018-07-26 16:11   ` Applied "ASoC: intel: Fix snd_pcm_format_t handling" to the asoc tree Mark Brown
  2018-07-25 21:17 ` [PATCH 4/6] ASoC: fsl: Use snd_mask_set_format() Takashi Iwai
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Takashi Iwai @ 2018-07-25 21:17 UTC (permalink / raw)
  To: alsa-devel
  Cc: Nicolin Chen, Lars-Peter Clausen, Timur Tabi,
	Pierre-Louis Bossart, Liam Girdwood, Mark Brown

As sparse warns, the PCM format type can't be dealt as integer as
found in Intel SST driver codes.

Fix them in the following two ways:

- The open code with snd_mask_set() and params->masks reference is
  replaced with params_set_format()

- The rest codes with snd_mask_set(fmt, SNDRV_PCM_FORMAT_XXX) are
  replaced with the new helper, snd_mask_set_format().

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/intel/boards/bdw-rt5677.c                 | 4 +---
 sound/soc/intel/boards/bxt_da7219_max98357a.c       | 2 +-
 sound/soc/intel/boards/bxt_rt298.c                  | 2 +-
 sound/soc/intel/boards/kbl_da7219_max98357a.c       | 2 +-
 sound/soc/intel/boards/kbl_rt5663_max98927.c        | 4 ++--
 sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 4 ++--
 sound/soc/intel/boards/skl_nau88l25_max98357a.c     | 2 +-
 sound/soc/intel/boards/skl_nau88l25_ssm4567.c       | 2 +-
 sound/soc/intel/boards/skl_rt286.c                  | 2 +-
 9 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/sound/soc/intel/boards/bdw-rt5677.c b/sound/soc/intel/boards/bdw-rt5677.c
index 6ea360f33575..efcfd906c856 100644
--- a/sound/soc/intel/boards/bdw-rt5677.c
+++ b/sound/soc/intel/boards/bdw-rt5677.c
@@ -154,9 +154,7 @@ static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
 	channels->min = channels->max = 2;
 
 	/* 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);
+	params_set_format(params, SNDRV_PCM_FORMAT_S16_LE);
 	return 0;
 }
 
diff --git a/sound/soc/intel/boards/bxt_da7219_max98357a.c b/sound/soc/intel/boards/bxt_da7219_max98357a.c
index 40eb979d5ac1..05262494ffce 100644
--- a/sound/soc/intel/boards/bxt_da7219_max98357a.c
+++ b/sound/soc/intel/boards/bxt_da7219_max98357a.c
@@ -160,7 +160,7 @@ static int broxton_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/bxt_rt298.c b/sound/soc/intel/boards/bxt_rt298.c
index b68c289558a8..27308337ab12 100644
--- a/sound/soc/intel/boards/bxt_rt298.c
+++ b/sound/soc/intel/boards/bxt_rt298.c
@@ -221,7 +221,7 @@ static int broxton_ssp5_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP5 to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/kbl_da7219_max98357a.c b/sound/soc/intel/boards/kbl_da7219_max98357a.c
index 94294c27d1db..529bb993a956 100644
--- a/sound/soc/intel/boards/kbl_da7219_max98357a.c
+++ b/sound/soc/intel/boards/kbl_da7219_max98357a.c
@@ -152,7 +152,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c
index 3a61252fe450..21a6490746a6 100644
--- a/sound/soc/intel/boards/kbl_rt5663_max98927.c
+++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c
@@ -434,14 +434,14 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 		rate->min = rate->max = 48000;
 		channels->min = channels->max = 2;
 		snd_mask_none(fmt);
-		snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+		snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
 	}
 	/*
 	 * The speaker on the SSP0 supports S16_LE and not S24_LE.
 	 * thus changing the mask here
 	 */
 	if (!strcmp(be_dai_link->name, "SSP0-Codec"))
-		snd_mask_set(fmt, SNDRV_PCM_FORMAT_S16_LE);
+		snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
index 92f5fb2ae0a3..a892b37eab7c 100644
--- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
+++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
@@ -307,7 +307,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 		rate->min = rate->max = 48000;
 		channels->min = channels->max = 2;
 		snd_mask_none(fmt);
-		snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+		snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
 	} else if (!strcmp(fe_dai_link->name, "Kbl Audio DMIC cap")) {
 		if (params_channels(params) == 2 ||
 				DMIC_CH(dmic_constraints) == 2)
@@ -320,7 +320,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 	 * thus changing the mask here
 	 */
 	if (!strcmp(be_dai_link->name, "SSP0-Codec"))
-		snd_mask_set(fmt, SNDRV_PCM_FORMAT_S16_LE);
+		snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/skl_nau88l25_max98357a.c b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
index 3ff6646cfa21..d31482b8c9bb 100644
--- a/sound/soc/intel/boards/skl_nau88l25_max98357a.c
+++ b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
@@ -157,7 +157,7 @@ static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP0 to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
index b0610bba3cfa..e877bb60beb1 100644
--- a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
+++ b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
@@ -346,7 +346,7 @@ static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP0 to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
 	return 0;
 }
 
diff --git a/sound/soc/intel/boards/skl_rt286.c b/sound/soc/intel/boards/skl_rt286.c
index 38a1495c29cf..0e1818dd4cc6 100644
--- a/sound/soc/intel/boards/skl_rt286.c
+++ b/sound/soc/intel/boards/skl_rt286.c
@@ -229,7 +229,7 @@ static int skylake_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP0 to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
 	return 0;
 }
 
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 4/6] ASoC: fsl: Use snd_mask_set_format()
  2018-07-25 21:17 [PATCH 0/6] ASoC: PCM format type conversion fixes Takashi Iwai
                   ` (2 preceding siblings ...)
  2018-07-25 21:17 ` [PATCH 3/6] ASoC: intel: Fix snd_pcm_format_t handling Takashi Iwai
@ 2018-07-25 21:17 ` Takashi Iwai
  2018-07-26 16:11   ` Applied "ASoC: fsl: Use snd_mask_set_format()" to the asoc tree Mark Brown
  2018-07-25 21:17 ` [PATCH 5/6] ASoC: pcm186x: Declare PCM format with snd_pcm_format_t Takashi Iwai
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Takashi Iwai @ 2018-07-25 21:17 UTC (permalink / raw)
  To: alsa-devel
  Cc: Nicolin Chen, Lars-Peter Clausen, Timur Tabi,
	Pierre-Louis Bossart, Liam Girdwood, Mark Brown

Use the new helper function snd_mask_set_format() for avoiding the
ugly cast with __force prefix.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/fsl/fsl-asoc-card.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index 4a6750aa3637..9a973df582fb 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -199,7 +199,7 @@ static int be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
 	snd_mask_none(mask);
-	snd_mask_set(mask, (__force int)priv->asrc_format);
+	snd_mask_set_format(mask, priv->asrc_format);
 
 	return 0;
 }
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 5/6] ASoC: pcm186x: Declare PCM format with snd_pcm_format_t
  2018-07-25 21:17 [PATCH 0/6] ASoC: PCM format type conversion fixes Takashi Iwai
                   ` (3 preceding siblings ...)
  2018-07-25 21:17 ` [PATCH 4/6] ASoC: fsl: Use snd_mask_set_format() Takashi Iwai
@ 2018-07-25 21:17 ` Takashi Iwai
  2018-07-26 16:11   ` Applied "ASoC: pcm186x: Declare PCM format with snd_pcm_format_t" to the asoc tree Mark Brown
  2018-07-25 21:17 ` [PATCH 6/6] ASoC: dmaengine: Use standard pcm_format_to_bits() macro Takashi Iwai
  2018-07-26 14:46 ` [PATCH 0/6] ASoC: PCM format type conversion fixes Mark Brown
  6 siblings, 1 reply; 15+ messages in thread
From: Takashi Iwai @ 2018-07-25 21:17 UTC (permalink / raw)
  To: alsa-devel
  Cc: Nicolin Chen, Lars-Peter Clausen, Timur Tabi,
	Pierre-Louis Bossart, Liam Girdwood, Mark Brown

The PCM format type is with __bitwise, so we should use the dedicated
snd_pcm_format_t instead of int.

This fixes the sparse warning like:
  sound/soc/codecs/pcm186x.c:268:44: warning: incorrect type in initializer (different base types)

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/codecs/pcm186x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/pcm186x.c b/sound/soc/codecs/pcm186x.c
index 88fde70b1e9e..690c26e7389e 100644
--- a/sound/soc/codecs/pcm186x.c
+++ b/sound/soc/codecs/pcm186x.c
@@ -265,7 +265,7 @@ static int pcm186x_hw_params(struct snd_pcm_substream *substream,
 	struct snd_soc_component *component = dai->component;
 	struct pcm186x_priv *priv = snd_soc_component_get_drvdata(component);
 	unsigned int rate = params_rate(params);
-	unsigned int format = params_format(params);
+	snd_pcm_format_t format = params_format(params);
 	unsigned int width = params_width(params);
 	unsigned int channels = params_channels(params);
 	unsigned int div_lrck;
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 6/6] ASoC: dmaengine: Use standard pcm_format_to_bits() macro
  2018-07-25 21:17 [PATCH 0/6] ASoC: PCM format type conversion fixes Takashi Iwai
                   ` (4 preceding siblings ...)
  2018-07-25 21:17 ` [PATCH 5/6] ASoC: pcm186x: Declare PCM format with snd_pcm_format_t Takashi Iwai
@ 2018-07-25 21:17 ` Takashi Iwai
  2018-07-26 16:11   ` Applied "ASoC: dmaengine: Use standard pcm_format_to_bits() macro" to the asoc tree Mark Brown
  2018-07-26 14:46 ` [PATCH 0/6] ASoC: PCM format type conversion fixes Mark Brown
  6 siblings, 1 reply; 15+ messages in thread
From: Takashi Iwai @ 2018-07-25 21:17 UTC (permalink / raw)
  To: alsa-devel
  Cc: Nicolin Chen, Lars-Peter Clausen, Timur Tabi,
	Pierre-Louis Bossart, Liam Girdwood, Mark Brown

The conversion from PCM format type to bits needs an explicit cast,
and it'll be uglier.  Since we have a standard macro for that, let's
use it instead.

This patch fixes the sparse warning:
  sound/soc/soc-generic-dmaengine-pcm.c:200:63: warning: restricted snd_pcm_format_t degrades to integer

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/soc-generic-dmaengine-pcm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c
index 61027dd0ef91..bf7aca8523b1 100644
--- a/sound/soc/soc-generic-dmaengine-pcm.c
+++ b/sound/soc/soc-generic-dmaengine-pcm.c
@@ -197,7 +197,7 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea
 			case 32:
 			case 64:
 				if (addr_widths & (1 << (bits / 8)))
-					hw.formats |= (1LL << i);
+					hw.formats |= pcm_format_to_bits(i);
 				break;
 			default:
 				/* Unsupported types */
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/6] ASoC: PCM format type conversion fixes
  2018-07-25 21:17 [PATCH 0/6] ASoC: PCM format type conversion fixes Takashi Iwai
                   ` (5 preceding siblings ...)
  2018-07-25 21:17 ` [PATCH 6/6] ASoC: dmaengine: Use standard pcm_format_to_bits() macro Takashi Iwai
@ 2018-07-26 14:46 ` Mark Brown
  2018-07-26 15:03   ` Takashi Iwai
  6 siblings, 1 reply; 15+ messages in thread
From: Mark Brown @ 2018-07-26 14:46 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Nicolin Chen, alsa-devel, Lars-Peter Clausen, Timur Tabi,
	Pierre-Louis Bossart, Liam Girdwood


[-- Attachment #1.1: Type: text/plain, Size: 317 bytes --]

On Wed, Jul 25, 2018 at 11:17:16PM +0200, Takashi Iwai wrote:
> Hi,
> 
> the PCM format is a fixed type with __bitwise, and it needs cast or
> other trick to deal with integer.  This is a series of such fixes for
> ASoC.

Nice!  Should I just apply all these (including the initial patch adding
the helper)?

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/6] ASoC: PCM format type conversion fixes
  2018-07-26 14:46 ` [PATCH 0/6] ASoC: PCM format type conversion fixes Mark Brown
@ 2018-07-26 15:03   ` Takashi Iwai
  0 siblings, 0 replies; 15+ messages in thread
From: Takashi Iwai @ 2018-07-26 15:03 UTC (permalink / raw)
  To: Mark Brown
  Cc: Nicolin Chen, alsa-devel, Lars-Peter Clausen, Timur Tabi,
	Pierre-Louis Bossart, Liam Girdwood

On Thu, 26 Jul 2018 16:46:59 +0200,
Mark Brown wrote:
> 
> On Wed, Jul 25, 2018 at 11:17:16PM +0200, Takashi Iwai wrote:
> > Hi,
> > 
> > the PCM format is a fixed type with __bitwise, and it needs cast or
> > other trick to deal with integer.  This is a series of such fixes for
> > ASoC.
> 
> Nice!  Should I just apply all these (including the initial patch adding
> the helper)?

Yes, please.


Takashi

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Applied "ASoC: dmaengine: Use standard pcm_format_to_bits() macro" to the asoc tree
  2018-07-25 21:17 ` [PATCH 6/6] ASoC: dmaengine: Use standard pcm_format_to_bits() macro Takashi Iwai
@ 2018-07-26 16:11   ` Mark Brown
  0 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2018-07-26 16:11 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Liam Girdwood, alsa-devel, Lars-Peter Clausen, Timur Tabi,
	Pierre-Louis Bossart, Nicolin Chen, Mark Brown

The patch

   ASoC: dmaengine: Use standard pcm_format_to_bits() macro

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 8adf3df4156345f1edcdfa8c7f7beeb0de351ce2 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Wed, 25 Jul 2018 23:17:22 +0200
Subject: [PATCH] ASoC: dmaengine: Use standard pcm_format_to_bits() macro

The conversion from PCM format type to bits needs an explicit cast,
and it'll be uglier.  Since we have a standard macro for that, let's
use it instead.

This patch fixes the sparse warning:
  sound/soc/soc-generic-dmaengine-pcm.c:200:63: warning: restricted snd_pcm_format_t degrades to integer

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/soc-generic-dmaengine-pcm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c
index 120f7b39e256..52fd7af952a5 100644
--- a/sound/soc/soc-generic-dmaengine-pcm.c
+++ b/sound/soc/soc-generic-dmaengine-pcm.c
@@ -188,7 +188,7 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea
 			case 32:
 			case 64:
 				if (addr_widths & (1 << (bits / 8)))
-					hw.formats |= (1LL << i);
+					hw.formats |= pcm_format_to_bits(i);
 				break;
 			default:
 				/* Unsupported types */
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Applied "ASoC: pcm186x: Declare PCM format with snd_pcm_format_t" to the asoc tree
  2018-07-25 21:17 ` [PATCH 5/6] ASoC: pcm186x: Declare PCM format with snd_pcm_format_t Takashi Iwai
@ 2018-07-26 16:11   ` Mark Brown
  0 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2018-07-26 16:11 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Liam Girdwood, alsa-devel, Lars-Peter Clausen, Timur Tabi,
	Pierre-Louis Bossart, Nicolin Chen, Mark Brown

The patch

   ASoC: pcm186x: Declare PCM format with snd_pcm_format_t

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 79b8a50813a80ac15fdcdc96674098dee15eaaf5 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Wed, 25 Jul 2018 23:17:21 +0200
Subject: [PATCH] ASoC: pcm186x: Declare PCM format with snd_pcm_format_t

The PCM format type is with __bitwise, so we should use the dedicated
snd_pcm_format_t instead of int.

This fixes the sparse warning like:
  sound/soc/codecs/pcm186x.c:268:44: warning: incorrect type in initializer (different base types)

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/pcm186x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/pcm186x.c b/sound/soc/codecs/pcm186x.c
index 88fde70b1e9e..690c26e7389e 100644
--- a/sound/soc/codecs/pcm186x.c
+++ b/sound/soc/codecs/pcm186x.c
@@ -265,7 +265,7 @@ static int pcm186x_hw_params(struct snd_pcm_substream *substream,
 	struct snd_soc_component *component = dai->component;
 	struct pcm186x_priv *priv = snd_soc_component_get_drvdata(component);
 	unsigned int rate = params_rate(params);
-	unsigned int format = params_format(params);
+	snd_pcm_format_t format = params_format(params);
 	unsigned int width = params_width(params);
 	unsigned int channels = params_channels(params);
 	unsigned int div_lrck;
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Applied "ASoC: fsl: Use snd_mask_set_format()" to the asoc tree
  2018-07-25 21:17 ` [PATCH 4/6] ASoC: fsl: Use snd_mask_set_format() Takashi Iwai
@ 2018-07-26 16:11   ` Mark Brown
  0 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2018-07-26 16:11 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Liam Girdwood, alsa-devel, Lars-Peter Clausen, Timur Tabi,
	Pierre-Louis Bossart, Nicolin Chen, Mark Brown

The patch

   ASoC: fsl: Use snd_mask_set_format()

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From ebc22af0c9268dc4032326c20b02f2f227203330 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Wed, 25 Jul 2018 23:17:20 +0200
Subject: [PATCH] ASoC: fsl: Use snd_mask_set_format()

Use the new helper function snd_mask_set_format() for avoiding the
ugly cast with __force prefix.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/fsl/fsl-asoc-card.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index 07808c6d5461..44433b20435c 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -195,7 +195,7 @@ static int be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
 	snd_mask_none(mask);
-	snd_mask_set(mask, (__force int)priv->asrc_format);
+	snd_mask_set_format(mask, priv->asrc_format);
 
 	return 0;
 }
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Applied "ASoC: intel: Fix snd_pcm_format_t handling" to the asoc tree
  2018-07-25 21:17 ` [PATCH 3/6] ASoC: intel: Fix snd_pcm_format_t handling Takashi Iwai
@ 2018-07-26 16:11   ` Mark Brown
  0 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2018-07-26 16:11 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Liam Girdwood, alsa-devel, Lars-Peter Clausen, Timur Tabi,
	Pierre-Louis Bossart, Nicolin Chen, Mark Brown

The patch

   ASoC: intel: Fix snd_pcm_format_t handling

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From b5453e8ca311fdb6003c6583ad101d2b9131b994 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Wed, 25 Jul 2018 23:17:19 +0200
Subject: [PATCH] ASoC: intel: Fix snd_pcm_format_t handling

As sparse warns, the PCM format type can't be dealt as integer as
found in Intel SST driver codes.

Fix them in the following two ways:

- The open code with snd_mask_set() and params->masks reference is
  replaced with params_set_format()

- The rest codes with snd_mask_set(fmt, SNDRV_PCM_FORMAT_XXX) are
  replaced with the new helper, snd_mask_set_format().

Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/boards/bdw-rt5677.c                 | 4 +---
 sound/soc/intel/boards/bxt_da7219_max98357a.c       | 2 +-
 sound/soc/intel/boards/bxt_rt298.c                  | 2 +-
 sound/soc/intel/boards/kbl_da7219_max98357a.c       | 2 +-
 sound/soc/intel/boards/kbl_rt5663_max98927.c        | 4 ++--
 sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 4 ++--
 sound/soc/intel/boards/skl_nau88l25_max98357a.c     | 2 +-
 sound/soc/intel/boards/skl_nau88l25_ssm4567.c       | 2 +-
 sound/soc/intel/boards/skl_rt286.c                  | 2 +-
 9 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/sound/soc/intel/boards/bdw-rt5677.c b/sound/soc/intel/boards/bdw-rt5677.c
index 6ea360f33575..efcfd906c856 100644
--- a/sound/soc/intel/boards/bdw-rt5677.c
+++ b/sound/soc/intel/boards/bdw-rt5677.c
@@ -154,9 +154,7 @@ static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
 	channels->min = channels->max = 2;
 
 	/* 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);
+	params_set_format(params, SNDRV_PCM_FORMAT_S16_LE);
 	return 0;
 }
 
diff --git a/sound/soc/intel/boards/bxt_da7219_max98357a.c b/sound/soc/intel/boards/bxt_da7219_max98357a.c
index 3aba5bcf806a..be6e4b40bf03 100644
--- a/sound/soc/intel/boards/bxt_da7219_max98357a.c
+++ b/sound/soc/intel/boards/bxt_da7219_max98357a.c
@@ -160,7 +160,7 @@ static int broxton_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/bxt_rt298.c b/sound/soc/intel/boards/bxt_rt298.c
index b68c289558a8..27308337ab12 100644
--- a/sound/soc/intel/boards/bxt_rt298.c
+++ b/sound/soc/intel/boards/bxt_rt298.c
@@ -221,7 +221,7 @@ static int broxton_ssp5_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP5 to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/kbl_da7219_max98357a.c b/sound/soc/intel/boards/kbl_da7219_max98357a.c
index 7961f1fd18bd..38f6ab74709d 100644
--- a/sound/soc/intel/boards/kbl_da7219_max98357a.c
+++ b/sound/soc/intel/boards/kbl_da7219_max98357a.c
@@ -152,7 +152,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c
index 3a61252fe450..21a6490746a6 100644
--- a/sound/soc/intel/boards/kbl_rt5663_max98927.c
+++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c
@@ -434,14 +434,14 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 		rate->min = rate->max = 48000;
 		channels->min = channels->max = 2;
 		snd_mask_none(fmt);
-		snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+		snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
 	}
 	/*
 	 * The speaker on the SSP0 supports S16_LE and not S24_LE.
 	 * thus changing the mask here
 	 */
 	if (!strcmp(be_dai_link->name, "SSP0-Codec"))
-		snd_mask_set(fmt, SNDRV_PCM_FORMAT_S16_LE);
+		snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
index 92f5fb2ae0a3..a892b37eab7c 100644
--- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
+++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
@@ -307,7 +307,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 		rate->min = rate->max = 48000;
 		channels->min = channels->max = 2;
 		snd_mask_none(fmt);
-		snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+		snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
 	} else if (!strcmp(fe_dai_link->name, "Kbl Audio DMIC cap")) {
 		if (params_channels(params) == 2 ||
 				DMIC_CH(dmic_constraints) == 2)
@@ -320,7 +320,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 	 * thus changing the mask here
 	 */
 	if (!strcmp(be_dai_link->name, "SSP0-Codec"))
-		snd_mask_set(fmt, SNDRV_PCM_FORMAT_S16_LE);
+		snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/skl_nau88l25_max98357a.c b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
index 3ff6646cfa21..d31482b8c9bb 100644
--- a/sound/soc/intel/boards/skl_nau88l25_max98357a.c
+++ b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
@@ -157,7 +157,7 @@ static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP0 to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
 
 	return 0;
 }
diff --git a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
index b0610bba3cfa..e877bb60beb1 100644
--- a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
+++ b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
@@ -346,7 +346,7 @@ static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP0 to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
 	return 0;
 }
 
diff --git a/sound/soc/intel/boards/skl_rt286.c b/sound/soc/intel/boards/skl_rt286.c
index 38a1495c29cf..0e1818dd4cc6 100644
--- a/sound/soc/intel/boards/skl_rt286.c
+++ b/sound/soc/intel/boards/skl_rt286.c
@@ -229,7 +229,7 @@ static int skylake_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
 
 	/* set SSP0 to 24 bit */
 	snd_mask_none(fmt);
-	snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE);
+	snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S24_LE);
 	return 0;
 }
 
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Applied "ASoC: doc: Replace open code with params_set_format()" to the asoc tree
  2018-07-25 21:17 ` [PATCH 2/6] ASoC: doc: Replace open code with params_set_format() Takashi Iwai
@ 2018-07-26 16:11   ` Mark Brown
  0 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2018-07-26 16:11 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Liam Girdwood, alsa-devel, Lars-Peter Clausen, Timur Tabi,
	Pierre-Louis Bossart, Nicolin Chen, Mark Brown

The patch

   ASoC: doc: Replace open code with params_set_format()

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 533a9274850b041b32fbe6d1df58a5c5b0b9e652 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Wed, 25 Jul 2018 23:17:18 +0200
Subject: [PATCH] ASoC: doc: Replace open code with params_set_format()

The example code in dpcm.rst contains an open code calling
snd_mask_set(), and this can be better represented with
params_set_format() instead.  This automatically fixes the sparse
warning about snd_pcm_format_t handling, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 Documentation/sound/soc/dpcm.rst | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/Documentation/sound/soc/dpcm.rst b/Documentation/sound/soc/dpcm.rst
index 395e5a516282..fe61e02277f8 100644
--- a/Documentation/sound/soc/dpcm.rst
+++ b/Documentation/sound/soc/dpcm.rst
@@ -254,9 +254,7 @@ configuration.
 	channels->min = channels->max = 2;
 
 	/* set DAI0 to 16 bit */
-	snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
-				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
-				    SNDRV_PCM_FORMAT_S16_LE);
+	params_set_format(params, SNDRV_PCM_FORMAT_S16_LE);
 	return 0;
   }
 
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Applied "ALSA: pcm: Add snd_mask_set_format() helper for standard usages" to the asoc tree
  2018-07-25 21:17 ` [PATCH 1/6] ALSA: pcm: Add snd_mask_set_format() helper for standard usages Takashi Iwai
@ 2018-07-26 16:11   ` Mark Brown
  0 siblings, 0 replies; 15+ messages in thread
From: Mark Brown @ 2018-07-26 16:11 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Liam Girdwood, alsa-devel, Lars-Peter Clausen, Timur Tabi,
	Pierre-Louis Bossart, Nicolin Chen, Mark Brown

The patch

   ALSA: pcm: Add snd_mask_set_format() helper for standard usages

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 0b62834e73e332fea76a340d62aaf50c732b17e0 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Wed, 25 Jul 2018 23:17:17 +0200
Subject: [PATCH] ALSA: pcm: Add snd_mask_set_format() helper for standard
 usages

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 <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 include/sound/pcm_params.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/sound/pcm_params.h b/include/sound/pcm_params.h
index c704357775fc..2dd37cada7c0 100644
--- a/include/sound/pcm_params.h
+++ b/include/sound/pcm_params.h
@@ -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);
@@ -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 */
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-07-30 18:22 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-25 21:17 [PATCH 0/6] ASoC: PCM format type conversion fixes Takashi Iwai
2018-07-25 21:17 ` [PATCH 1/6] ALSA: pcm: Add snd_mask_set_format() helper for standard usages Takashi Iwai
2018-07-26 16:11   ` Applied "ALSA: pcm: Add snd_mask_set_format() helper for standard usages" to the asoc tree Mark Brown
2018-07-25 21:17 ` [PATCH 2/6] ASoC: doc: Replace open code with params_set_format() Takashi Iwai
2018-07-26 16:11   ` Applied "ASoC: doc: Replace open code with params_set_format()" to the asoc tree Mark Brown
2018-07-25 21:17 ` [PATCH 3/6] ASoC: intel: Fix snd_pcm_format_t handling Takashi Iwai
2018-07-26 16:11   ` Applied "ASoC: intel: Fix snd_pcm_format_t handling" to the asoc tree Mark Brown
2018-07-25 21:17 ` [PATCH 4/6] ASoC: fsl: Use snd_mask_set_format() Takashi Iwai
2018-07-26 16:11   ` Applied "ASoC: fsl: Use snd_mask_set_format()" to the asoc tree Mark Brown
2018-07-25 21:17 ` [PATCH 5/6] ASoC: pcm186x: Declare PCM format with snd_pcm_format_t Takashi Iwai
2018-07-26 16:11   ` Applied "ASoC: pcm186x: Declare PCM format with snd_pcm_format_t" to the asoc tree Mark Brown
2018-07-25 21:17 ` [PATCH 6/6] ASoC: dmaengine: Use standard pcm_format_to_bits() macro Takashi Iwai
2018-07-26 16:11   ` Applied "ASoC: dmaengine: Use standard pcm_format_to_bits() macro" to the asoc tree Mark Brown
2018-07-26 14:46 ` [PATCH 0/6] ASoC: PCM format type conversion fixes Mark Brown
2018-07-26 15:03   ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.