alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] ASoC: Clean-up W=1 build warnings​ - part3
@ 2020-07-07 19:23 Pierre-Louis Bossart
  2020-07-07 19:23 ` [PATCH 1/3] ASoC: Intel: Skylake: remove comparison always false warning Pierre-Louis Bossart
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Pierre-Louis Bossart @ 2020-07-07 19:23 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, broonie, Lee Jones, Pierre-Louis Bossart

This is a much smaller set of cleanups, all related to warnings thrown
by the use of GENMASK() with an unsigned variable. I just made the
warning go away but I wonder if there's a better fix in the definition
of GENMASK() itself?

Pierre-Louis Bossart (3):
  ASoC: Intel: Skylake: remove comparison always false warning
  ASoC: meson: axg-pdm: remove comparison always false warning
  ASoC: meson: axg-spdifin: remove comparison always false warning

 sound/soc/intel/skylake/skl-sst-dsp.c | 2 +-
 sound/soc/meson/axg-pdm.c             | 2 +-
 sound/soc/meson/axg-spdifin.c         | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

-- 
2.25.1


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

* [PATCH 1/3] ASoC: Intel: Skylake: remove comparison always false warning
  2020-07-07 19:23 [PATCH 0/3] ASoC: Clean-up W=1 build warnings​ - part3 Pierre-Louis Bossart
@ 2020-07-07 19:23 ` Pierre-Louis Bossart
  2020-07-07 19:23 ` [PATCH 2/3] ASoC: meson: axg-pdm: " Pierre-Louis Bossart
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Pierre-Louis Bossart @ 2020-07-07 19:23 UTC (permalink / raw)
  To: alsa-devel
  Cc: Cezary Rojewski, tiwai, open list, Takashi Iwai, Jie Yang,
	Pierre-Louis Bossart, Liam Girdwood, broonie, Piotr Maziarz,
	Lee Jones

Fix W=1 warnings:

skl-sst-dsp.c: In function ‘skl_dsp_get_enabled_cores’:
include/linux/bits.h:26:28: warning: comparison of unsigned expression
< 0 is always false [-Wtype-limits]

cast the core number to a long to avoid checking if an unsigned value
is lower than zero.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/intel/skylake/skl-sst-dsp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/intel/skylake/skl-sst-dsp.c b/sound/soc/intel/skylake/skl-sst-dsp.c
index 225706d148d8..cb83b395f210 100644
--- a/sound/soc/intel/skylake/skl-sst-dsp.c
+++ b/sound/soc/intel/skylake/skl-sst-dsp.c
@@ -52,7 +52,7 @@ unsigned int skl_dsp_get_enabled_cores(struct sst_dsp *ctx)
 	unsigned int core_mask, en_cores_mask;
 	u32 val;
 
-	core_mask = SKL_DSP_CORES_MASK(skl->cores.count);
+	core_mask = SKL_DSP_CORES_MASK((long)skl->cores.count);
 
 	val = sst_dsp_shim_read_unlocked(ctx, SKL_ADSP_REG_ADSPCS);
 
-- 
2.25.1


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

* [PATCH 2/3] ASoC: meson: axg-pdm: remove comparison always false warning
  2020-07-07 19:23 [PATCH 0/3] ASoC: Clean-up W=1 build warnings​ - part3 Pierre-Louis Bossart
  2020-07-07 19:23 ` [PATCH 1/3] ASoC: Intel: Skylake: remove comparison always false warning Pierre-Louis Bossart
@ 2020-07-07 19:23 ` Pierre-Louis Bossart
  2020-07-07 19:23 ` [PATCH 3/3] ASoC: meson: axg-spdifin: " Pierre-Louis Bossart
  2020-07-07 19:39 ` [PATCH 0/3] ASoC: Clean-up W=1 build warnings​ - part3 Jerome Brunet
  3 siblings, 0 replies; 8+ messages in thread
From: Pierre-Louis Bossart @ 2020-07-07 19:23 UTC (permalink / raw)
  To: alsa-devel
  Cc: open list, tiwai, Kevin Hilman, Takashi Iwai, Liam Girdwood,
	Pierre-Louis Bossart, broonie,
	open list:ARM/Amlogic Meson SoC support, Lee Jones,
	moderated list:ARM/Amlogic Meson SoC support, Jerome Brunet

Fix W=1 warning.

sound/soc/meson/axg-pdm.c: In function ‘axg_pdm_set_channel_mask’:
include/linux/bits.h:26:28: warning: comparison of unsigned expression
< 0 is always false [-Wtype-limits]

cast the channel number to an int to avoid checking if an unsigned
value is lower than zero.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/meson/axg-pdm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/meson/axg-pdm.c b/sound/soc/meson/axg-pdm.c
index bfd37d49a73e..8fe5b2563619 100644
--- a/sound/soc/meson/axg-pdm.c
+++ b/sound/soc/meson/axg-pdm.c
@@ -206,7 +206,7 @@ static int axg_pdm_set_sample_pointer(struct axg_pdm *priv)
 static void axg_pdm_set_channel_mask(struct axg_pdm *priv,
 				     unsigned int channels)
 {
-	unsigned int mask = GENMASK(channels - 1, 0);
+	unsigned int mask = GENMASK((int)channels - 1, 0);
 
 	/* Put all channel in reset */
 	regmap_update_bits(priv->map, PDM_CTRL,
-- 
2.25.1


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

* [PATCH 3/3] ASoC: meson: axg-spdifin: remove comparison always false warning
  2020-07-07 19:23 [PATCH 0/3] ASoC: Clean-up W=1 build warnings​ - part3 Pierre-Louis Bossart
  2020-07-07 19:23 ` [PATCH 1/3] ASoC: Intel: Skylake: remove comparison always false warning Pierre-Louis Bossart
  2020-07-07 19:23 ` [PATCH 2/3] ASoC: meson: axg-pdm: " Pierre-Louis Bossart
@ 2020-07-07 19:23 ` Pierre-Louis Bossart
  2020-07-07 19:39 ` [PATCH 0/3] ASoC: Clean-up W=1 build warnings​ - part3 Jerome Brunet
  3 siblings, 0 replies; 8+ messages in thread
From: Pierre-Louis Bossart @ 2020-07-07 19:23 UTC (permalink / raw)
  To: alsa-devel
  Cc: open list, tiwai, Kevin Hilman, Takashi Iwai, Liam Girdwood,
	Pierre-Louis Bossart, broonie,
	open list:ARM/Amlogic Meson SoC support, Lee Jones,
	moderated list:ARM/Amlogic Meson SoC support, Jerome Brunet

Fix W=1 warning:

sound/soc/meson/axg-spdifin.c: In function ‘axg_spdifin_write_mode_param’:
include/linux/bits.h:26:28: warning: comparison of unsigned expression
< 0 is always false [-Wtype-limits]

Cast width to an int to avoid checking if an unsigned value is lower
than zero.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/meson/axg-spdifin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/meson/axg-spdifin.c b/sound/soc/meson/axg-spdifin.c
index d0d09f945b48..5fa411d4e985 100644
--- a/sound/soc/meson/axg-spdifin.c
+++ b/sound/soc/meson/axg-spdifin.c
@@ -154,7 +154,7 @@ static void axg_spdifin_write_mode_param(struct regmap *map, int mode,
 	reg = offset * regmap_get_reg_stride(map) + base_reg;
 	shift = width * (num_per_reg - 1 - rem);
 
-	regmap_update_bits(map, reg, GENMASK(width - 1, 0) << shift,
+	regmap_update_bits(map, reg, GENMASK((int)width - 1, 0) << shift,
 			   val << shift);
 }
 
-- 
2.25.1


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

* Re: [PATCH 0/3] ASoC: Clean-up W=1 build warnings​ - part3
  2020-07-07 19:23 [PATCH 0/3] ASoC: Clean-up W=1 build warnings​ - part3 Pierre-Louis Bossart
                   ` (2 preceding siblings ...)
  2020-07-07 19:23 ` [PATCH 3/3] ASoC: meson: axg-spdifin: " Pierre-Louis Bossart
@ 2020-07-07 19:39 ` Jerome Brunet
  2020-07-08  0:16   ` Pierre-Louis Bossart
  3 siblings, 1 reply; 8+ messages in thread
From: Jerome Brunet @ 2020-07-07 19:39 UTC (permalink / raw)
  To: Pierre-Louis Bossart, alsa-devel; +Cc: tiwai, broonie, Lee Jones


On Tue 07 Jul 2020 at 21:23, Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> wrote:

> This is a much smaller set of cleanups, all related to warnings thrown
> by the use of GENMASK() with an unsigned variable. I just made the
> warning go away but I wonder if there's a better fix in the definition
> of GENMASK() itself?

Looking at the patch I was going to ask the same thing.
It does not make much sense to me to force GENMASK arguments to be
integer (instead of unsigned integer) to then check there are positive ...

>
> Pierre-Louis Bossart (3):
>   ASoC: Intel: Skylake: remove comparison always false warning
>   ASoC: meson: axg-pdm: remove comparison always false warning
>   ASoC: meson: axg-spdifin: remove comparison always false warning
>
>  sound/soc/intel/skylake/skl-sst-dsp.c | 2 +-
>  sound/soc/meson/axg-pdm.c             | 2 +-
>  sound/soc/meson/axg-spdifin.c         | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)


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

* Re: [PATCH 0/3] ASoC: Clean-up W=1 build warnings​ - part3
  2020-07-07 19:39 ` [PATCH 0/3] ASoC: Clean-up W=1 build warnings​ - part3 Jerome Brunet
@ 2020-07-08  0:16   ` Pierre-Louis Bossart
  2020-07-08  6:31     ` Lee Jones
  0 siblings, 1 reply; 8+ messages in thread
From: Pierre-Louis Bossart @ 2020-07-08  0:16 UTC (permalink / raw)
  To: Jerome Brunet, alsa-devel; +Cc: tiwai, broonie, Lee Jones, Rikard Falkeborn



On 7/7/20 2:39 PM, Jerome Brunet wrote:
> 
> On Tue 07 Jul 2020 at 21:23, Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> wrote:
> 
>> This is a much smaller set of cleanups, all related to warnings thrown
>> by the use of GENMASK() with an unsigned variable. I just made the
>> warning go away but I wonder if there's a better fix in the definition
>> of GENMASK() itself?
> 
> Looking at the patch I was going to ask the same thing.
> It does not make much sense to me to force GENMASK arguments to be
> integer (instead of unsigned integer) to then check there are positive ...

Agree, it's just that the following macro isn't exactly simple to change:

#define GENMASK_INPUT_CHECK(h, l) \
	(BUILD_BUG_ON_ZERO(__builtin_choose_expr( \
		__builtin_constant_p((l) > (h)), (l) > (h), 0)))

I couldn't find a means to avoid the comparison.

I just realized this is a fairly recent addition in 295bcca84916 
('linux/bits.h: add compile time sanity check of GENMASK inputs'), 
adding the author Rikard Falkeborn in CC:

include/linux/bits.h:26:28: warning: comparison of unsigned expression < 
0 is always false [-Wtype-limits]
    26 |   __builtin_constant_p((l) > (h)), (l) > (h), 0)))

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

* Re: [PATCH 0/3] ASoC: Clean-up W=1 build warnings​ - part3
  2020-07-08  0:16   ` Pierre-Louis Bossart
@ 2020-07-08  6:31     ` Lee Jones
  2020-07-08 11:13       ` Mark Brown
  0 siblings, 1 reply; 8+ messages in thread
From: Lee Jones @ 2020-07-08  6:31 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: tiwai, alsa-devel, broonie, Rikard Falkeborn, Jerome Brunet

On Tue, 07 Jul 2020, Pierre-Louis Bossart wrote:
> On 7/7/20 2:39 PM, Jerome Brunet wrote:
> > 
> > On Tue 07 Jul 2020 at 21:23, Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> wrote:
> > 
> > > This is a much smaller set of cleanups, all related to warnings thrown
> > > by the use of GENMASK() with an unsigned variable. I just made the
> > > warning go away but I wonder if there's a better fix in the definition
> > > of GENMASK() itself?
> > 
> > Looking at the patch I was going to ask the same thing.
> > It does not make much sense to me to force GENMASK arguments to be
> > integer (instead of unsigned integer) to then check there are positive ...
> 
> Agree, it's just that the following macro isn't exactly simple to change:
> 
> #define GENMASK_INPUT_CHECK(h, l) \
> 	(BUILD_BUG_ON_ZERO(__builtin_choose_expr( \
> 		__builtin_constant_p((l) > (h)), (l) > (h), 0)))
> 
> I couldn't find a means to avoid the comparison.
> 
> I just realized this is a fairly recent addition in 295bcca84916
> ('linux/bits.h: add compile time sanity check of GENMASK inputs'), adding
> the author Rikard Falkeborn in CC:
> 
> include/linux/bits.h:26:28: warning: comparison of unsigned expression < 0
> is always false [-Wtype-limits]
>    26 |   __builtin_constant_p((l) > (h)), (l) > (h), 0)))

Linus recently complained about the type-limits warning, saying that
it was invalid.  He preferred the warning to be bumped from W=1 to
W=2, although I haven't seen a patch doing this yet.

Rikard also tried to fix GENMASK directly; however, Linus did not
approve of this either.

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH 0/3] ASoC: Clean-up W=1 build warnings​ - part3
  2020-07-08  6:31     ` Lee Jones
@ 2020-07-08 11:13       ` Mark Brown
  0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2020-07-08 11:13 UTC (permalink / raw)
  To: Lee Jones
  Cc: tiwai, alsa-devel, Pierre-Louis Bossart, Rikard Falkeborn, Jerome Brunet

[-- Attachment #1: Type: text/plain, Size: 394 bytes --]

On Wed, Jul 08, 2020 at 07:31:00AM +0100, Lee Jones wrote:

> Linus recently complained about the type-limits warning, saying that
> it was invalid.  He preferred the warning to be bumped from W=1 to
> W=2, although I haven't seen a patch doing this yet.

> Rikard also tried to fix GENMASK directly; however, Linus did not
> approve of this either.

Let's just leave this series for now then.

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

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

end of thread, other threads:[~2020-07-08 11:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-07 19:23 [PATCH 0/3] ASoC: Clean-up W=1 build warnings​ - part3 Pierre-Louis Bossart
2020-07-07 19:23 ` [PATCH 1/3] ASoC: Intel: Skylake: remove comparison always false warning Pierre-Louis Bossart
2020-07-07 19:23 ` [PATCH 2/3] ASoC: meson: axg-pdm: " Pierre-Louis Bossart
2020-07-07 19:23 ` [PATCH 3/3] ASoC: meson: axg-spdifin: " Pierre-Louis Bossart
2020-07-07 19:39 ` [PATCH 0/3] ASoC: Clean-up W=1 build warnings​ - part3 Jerome Brunet
2020-07-08  0:16   ` Pierre-Louis Bossart
2020-07-08  6:31     ` Lee Jones
2020-07-08 11:13       ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).