Skip to contentSkip to conversation

ASoC: Fix trival sparse warnings

PATCH Applied Lars-Peter Clausen 4 participants 19 messages Jun 19, 2014 – Jul 1, 2014

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover ASoC: Fix trival sparse warnings

Hi,

This series fixes a couple of trivial issues that are reported when running the sparse codechecker on the ASoC tree.

- Lars

Lars-Peter Clausen (5):
ASoC: tlv320aic31xx: Remove duplicate const
ASoC: cs42xx8: Make of match table static
ASoC: omap-pcm: Include omap-pcm.h
ASoC: rcar: Fix dma direction type
ASoC: sh/fsi: Make one-bit bitfields unsigned

 sound/soc/codecs/cs42xx8.c       |  2 +-
 sound/soc/codecs/tlv320aic31xx.c | 21 ++++++++++-----------
 sound/soc/omap/omap-pcm.c        |  1 +
 sound/soc/sh/fsi.c               | 12 ++++++------
 sound/soc/sh/rcar/core.c         |  2 +-
 sound/soc/sh/rcar/rsnd.h         |  2 +-
 6 files changed, 20 insertions(+), 20 deletions(-)
Signature · 1 line
1.8.0
#1 lore raw

PATCH 1/5 ASoC: tlv320aic31xx: Remove duplicate const

SOC_ENUM_SINGLE_DECL() already adds the const qualifier, so there is no need to manually specify it.

Fixes the following warnings from sparse:

	sound/soc/codecs/tlv320aic31xx.c:253:1: warning: duplicate const
	sound/soc/codecs/tlv320aic31xx.c:255:1: warning: duplicate const
	sound/soc/codecs/tlv320aic31xx.c:257:1: warning: duplicate const
	sound/soc/codecs/tlv320aic31xx.c:260:1: warning: duplicate const
	sound/soc/codecs/tlv320aic31xx.c:262:1: warning: duplicate const
---
 sound/soc/codecs/tlv320aic31xx.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
sound/soc/codecs/tlv320aic31xx.c +10 -11
index 2341910..5128e66 100644
@@ -249,17 +249,16 @@ static const char * const mic_select_text[] = {
 	"Off", "FFR 10 Ohm", "FFR 20 Ohm", "FFR 40 Ohm"
 };
 
-static const
-SOC_ENUM_SINGLE_DECL(mic1lp_p_enum, AIC31XX_MICPGAPI, 6, mic_select_text);
-static const
-SOC_ENUM_SINGLE_DECL(mic1rp_p_enum, AIC31XX_MICPGAPI, 4, mic_select_text);
-static const
-SOC_ENUM_SINGLE_DECL(mic1lm_p_enum, AIC31XX_MICPGAPI, 2, mic_select_text);
-
-static const
-SOC_ENUM_SINGLE_DECL(cm_m_enum, AIC31XX_MICPGAMI, 6, mic_select_text);
-static const
-SOC_ENUM_SINGLE_DECL(mic1lm_m_enum, AIC31XX_MICPGAMI, 4, mic_select_text);
+static SOC_ENUM_SINGLE_DECL(mic1lp_p_enum, AIC31XX_MICPGAPI, 6,
+	mic_select_text);
+static SOC_ENUM_SINGLE_DECL(mic1rp_p_enum, AIC31XX_MICPGAPI, 4,
+	mic_select_text);
+static SOC_ENUM_SINGLE_DECL(mic1lm_p_enum, AIC31XX_MICPGAPI, 2,
+	mic_select_text);
+
+static SOC_ENUM_SINGLE_DECL(cm_m_enum, AIC31XX_MICPGAMI, 6, mic_select_text);
+static SOC_ENUM_SINGLE_DECL(mic1lm_m_enum, AIC31XX_MICPGAMI, 4,
+	mic_select_text);
 
 static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6350, 50, 0);
 static const DECLARE_TLV_DB_SCALE(adc_fgain_tlv, 0, 10, 0);
Signature · 1 line
1.8.0
maintainer Applied
#2 lore raw

Re: [PATCH 1/5] ASoC: tlv320aic31xx: Remove duplicate const

Quoted 2 lines · Lars-Peter Clausen

SOC_ENUM_SINGLE_DECL() already adds the const qualifier, so there is no need to manually specify it.

Applied, thanks.

#3 lore raw

PATCH 2/5 ASoC: cs42xx8: Make of match table static

In reply to Lars-Peter Clausen

The cs42xx8_of_match table is not used outside of the driver, hence it can and should be made static.

Fixes the following warning from sparse:

	sound/soc/codecs/cs42xx8.c:425:27: warning: symbol 'cs42xx8_of_match' was
	not declared. Should it be static?
---
 sound/soc/codecs/cs42xx8.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/cs42xx8.c +1 -1
index a25bc60..ec53ffc 100644
@@ -422,7 +422,7 @@ const struct cs42xx8_driver_data cs42888_data = {
 };
 EXPORT_SYMBOL_GPL(cs42888_data);
 
-const struct of_device_id cs42xx8_of_match[] = {
+static const struct of_device_id cs42xx8_of_match[] = {
 	{ .compatible = "cirrus,cs42448", .data = &cs42448_data, },
 	{ .compatible = "cirrus,cs42888", .data = &cs42888_data, },
 	{ /* sentinel */ }
Signature · 1 line
1.8.0
Acked-by on v1 2/5
#4 lore raw

Re: [PATCH 2/5] ASoC: cs42xx8: Make of match table static

Quoted 8 lines · Lars-Peter Clausen

The cs42xx8_of_match table is not used outside of the driver, hence it can and should be made static.

Fixes the following warning from sparse:

	sound/soc/codecs/cs42xx8.c:425:27: warning: symbol 'cs42xx8_of_match' was
	not declared. Should it be static?

Thanks,

maintainer Applied
#5 lore raw

Re: [PATCH 2/5] ASoC: cs42xx8: Make of match table static

In reply to Lars-Peter Clausen
Quoted 2 lines · Lars-Peter Clausen

The cs42xx8_of_match table is not used outside of the driver, hence it can and should be made static.

Applied, thanks.

#6 lore raw

PATCH 3/5 ASoC: omap-pcm: Include omap-pcm.h

In reply to Lars-Peter Clausen

omap_pcm_platform_register() is declared in omap-pcm.h and defined in omap-pcm.c. To make sure that the function signature matches for both omap-pcm.c should include omap-pcm.h

Fixes the following warning from sparse:

	sound/soc/omap/omap-pcm.c:235:5: warning: symbol
	'omap_pcm_platform_register' was not declared. Should it be static?
---
 sound/soc/omap/omap-pcm.c | 1 +
 1 file changed, 1 insertion(+)
sound/soc/omap/omap-pcm.c +1 -0
index 8d809f8..f4b05bc 100644
@@ -31,6 +31,7 @@
 #include <sound/pcm_params.h>
 #include <sound/dmaengine_pcm.h>
 #include <sound/soc.h>
+#include <sound/omap-pcm.h>
 
 #ifdef CONFIG_ARCH_OMAP1
 #define pcm_omap1510()	cpu_is_omap1510()
Signature · 1 line
1.8.0
maintainer Applied
#7 lore raw

Re: [PATCH 3/5] ASoC: omap-pcm: Include omap-pcm.h

Quoted 3 lines · Lars-Peter Clausen

omap_pcm_platform_register() is declared in omap-pcm.h and defined in omap-pcm.c. To make sure that the function signature matches for both omap-pcm.c should include omap-pcm.h

Applied, thanks.

#8 lore raw

Re: [PATCH 3/5] ASoC: omap-pcm: Include omap-pcm.h

Quoted 6 lines · Mark Brown
Quoted 3 lines · Lars-Peter Clausen

omap_pcm_platform_register() is declared in omap-pcm.h and defined in omap-pcm.c. To make sure that the function signature matches for both omap-pcm.c should include omap-pcm.h

Applied, thanks.

This patch somehow did not make it, the patch is not in asoc/next, nor is there a asoc/topic/omap or similar. Shall I resend?

Thanks,
- Lars

maintainer
#9 lore raw

Re: [PATCH 3/5] ASoC: omap-pcm: Include omap-pcm.h

Quoted 6 lines · Lars-Peter Clausen
Quoted 1 line · Mark Brown

Applied, thanks.

This patch somehow did not make it, the patch is not in asoc/next, nor is there a asoc/topic/omap or similar. Shall I resend?

It seems to be there?

#10 lore raw

Re: [PATCH 3/5] ASoC: omap-pcm: Include omap-pcm.h

Quoted 10 lines · Mark Brown
Quoted 6 lines · Lars-Peter Clausen
Quoted 1 line · Mark Brown

Applied, thanks.

This patch somehow did not make it, the patch is not in asoc/next, nor is there a asoc/topic/omap or similar. Shall I resend?

It seems to be there?

Now it is.

Thanks,
- Lars

#11 lore raw

PATCH 4/5 ASoC: rcar: Fix dma direction type

In reply to Lars-Peter Clausen

dmaengine_prep_slave_single() expects a enum dma_transfer_direction and not a enum dma_data_direction. Since the integer representations of both DMA_TO_DEVICE and DMA_MEM_TO_DEV aswell as DMA_FROM_DEVICE and DMA_DEV_TO_MEM have the same value the code worked fine even though it was using the wrong type.

Fixes the following warning from sparse:
sound/soc/sh/rcar/core.c:227:49: warning: mixing different enum types
sound/soc/sh/rcar/core.c:227:49: int enum dma_data_direction versus
sound/soc/sh/rcar/core.c:227:49: int enum dma_transfer_direction

---
 sound/soc/sh/rcar/core.c | 2 +-
 sound/soc/sh/rcar/rsnd.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
sound/soc/sh/rcar/core.c +1 -1
index 4e86265..518a78c 100644
@@ -363,7 +363,7 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma,
 	if (ret < 0)
 		goto rsnd_dma_init_err;
 
-	dma->dir = is_play ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
+	dma->dir = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
 	INIT_WORK(&dma->work, rsnd_dma_do_work);
 
 	return 0;
sound/soc/sh/rcar/rsnd.h +1 -1
index 39d98af..067a89e 100644
@@ -158,7 +158,7 @@ struct rsnd_dma {
 	struct sh_dmae_slave	slave;
 	struct work_struct	work;
 	struct dma_chan		*chan;
-	enum dma_data_direction dir;
+	enum dma_transfer_direction dir;
 
 	int submit_loop;
 	int offset; /* it cares A/B plane */
Signature · 1 line
1.8.0
Acked-by on v1 4/5
#12 lore raw

Re: [PATCH 4/5] ASoC: rcar: Fix dma direction type

Hi Lars

Quoted 5 lines

dmaengine_prep_slave_single() expects a enum dma_transfer_direction and not a enum dma_data_direction. Since the integer representations of both DMA_TO_DEVICE and DMA_MEM_TO_DEV aswell as DMA_FROM_DEVICE and DMA_DEV_TO_MEM have the same value the code worked fine even though it was using the wrong type.

Quoted 7 lines

Fixes the following warning from sparse:
sound/soc/sh/rcar/core.c:227:49: warning: mixing different enum types
sound/soc/sh/rcar/core.c:227:49: int enum dma_data_direction versus
sound/soc/sh/rcar/core.c:227:49: int enum dma_transfer_direction

---

Actually, ${LINUX}/sound/soc/sh/fsi.c :: fsi_dma_transfer() is using enum dma_data_direction to dmaengine_prep_dma_cyclic() Does it have same issue ?

Quoted 33 lines
 sound/soc/sh/rcar/core.c | 2 +-
 sound/soc/sh/rcar/rsnd.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
sound/soc/sh/rcar/core.c +1 -1
index 4e86265..518a78c 100644
@@ -363,7 +363,7 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma,
 	if (ret < 0)
 		goto rsnd_dma_init_err;
 
-	dma->dir = is_play ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
+	dma->dir = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
 	INIT_WORK(&dma->work, rsnd_dma_do_work);
 
 	return 0;
sound/soc/sh/rcar/rsnd.h +1 -1
index 39d98af..067a89e 100644
@@ -158,7 +158,7 @@ struct rsnd_dma {
 	struct sh_dmae_slave	slave;
 	struct work_struct	work;
 	struct dma_chan		*chan;
-	enum dma_data_direction dir;
+	enum dma_transfer_direction dir;
 
 	int submit_loop;
 	int offset; /* it cares A/B plane */
Signature · 1 line
1.8.0
#13 lore raw

Re: [PATCH 4/5] ASoC: rcar: Fix dma direction type

Quoted 13 lines · Kuninori Morimoto

Hi Lars

Quoted 10 lines

dmaengine_prep_slave_single() expects a enum dma_transfer_direction and not a enum dma_data_direction. Since the integer representations of both DMA_TO_DEVICE and DMA_MEM_TO_DEV aswell as DMA_FROM_DEVICE and DMA_DEV_TO_MEM have the same value the code worked fine even though it was using the wrong type.

Fixes the following warning from sparse:
sound/soc/sh/rcar/core.c:227:49: warning: mixing different enum types
sound/soc/sh/rcar/core.c:227:49: int enum dma_data_direction versus
sound/soc/sh/rcar/core.c:227:49: int enum dma_transfer_direction

Quoted 8 lines
Quoted 2 lines

---

Actually, ${LINUX}/sound/soc/sh/fsi.c :: fsi_dma_transfer() is using enum dma_data_direction to dmaengine_prep_dma_cyclic() Does it have same issue ?

Yes, but the fix for that should go in after your "ASoC: fsi: use SNDRV_DMA_TYPE_DEV for sound buffer" patch, because otherwise the fix just introduces a new warning because before that patch dir is also passed to dma_sync_single_xxx() which wants a enum dma_data_direction.

- Lars

#14 lore raw

Re: [PATCH 4/5] ASoC: rcar: Fix dma direction type

Hi Lars

Quoted 15 lines
Quoted 15 lines
Quoted 5 lines

dmaengine_prep_slave_single() expects a enum dma_transfer_direction and not a enum dma_data_direction. Since the integer representations of both DMA_TO_DEVICE and DMA_MEM_TO_DEV aswell as DMA_FROM_DEVICE and DMA_DEV_TO_MEM have the same value the code worked fine even though it was using the wrong type.

Quoted 7 lines

Fixes the following warning from sparse:
sound/soc/sh/rcar/core.c:227:49: warning: mixing different enum types
sound/soc/sh/rcar/core.c:227:49: int enum dma_data_direction versus
sound/soc/sh/rcar/core.c:227:49: int enum dma_transfer_direction

---

Quoted 8 lines
Quoted 3 lines

Actually, ${LINUX}/sound/soc/sh/fsi.c :: fsi_dma_transfer() is using enum dma_data_direction to dmaengine_prep_dma_cyclic() Does it have same issue ?

Yes, but the fix for that should go in after your "ASoC: fsi: use SNDRV_DMA_TYPE_DEV for sound buffer" patch, because otherwise the fix just introduces a new warning because before that patch dir is also passed to dma_sync_single_xxx() which wants a enum dma_data_direction.

Ahh, yes, indeed
Thank you for your explain

maintainer Applied
#15 lore raw

Re: [PATCH 4/5] ASoC: rcar: Fix dma direction type

In reply to Lars-Peter Clausen
Quoted 4 lines · Lars-Peter Clausen

dmaengine_prep_slave_single() expects a enum dma_transfer_direction and not a enum dma_data_direction. Since the integer representations of both DMA_TO_DEVICE and DMA_MEM_TO_DEV aswell as DMA_FROM_DEVICE and DMA_DEV_TO_MEM have the same value the code worked fine even though it was using the wrong type.

Applied, thanks.

#16 lore raw

PATCH 5/5 ASoC: sh/fsi: Make one-bit bitfields unsigned

In reply to Lars-Peter Clausen

One-bit signed bitfields have two possible values: 0 and -1. This sometimes leads to unexpected results (e.g. foo.bar = 1; foo.bar == 1 => false) which is why it is recommended to make one-bit bitfields unsigned.

This fixes the following sparse warnings:
sound/soc/sh/fsi.c:267:25: error: dubious one-bit signed bitfield sound/soc/sh/fsi.c:268:22: error: dubious one-bit signed bitfield sound/soc/sh/fsi.c:269:20: error: dubious one-bit signed bitfield sound/soc/sh/fsi.c:270:28: error: dubious one-bit signed bitfield sound/soc/sh/fsi.c:271:26: error: dubious one-bit signed bitfield sound/soc/sh/fsi.c:272:25: error: dubious one-bit signed bitfield

---
 sound/soc/sh/fsi.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
sound/soc/sh/fsi.c +6 -6
index 710a079..2c95d85 100644
@@ -264,12 +264,12 @@ struct fsi_priv {
 	u32 fmt;
 
 	int chan_num:16;
-	int clk_master:1;
-	int clk_cpg:1;
-	int spdif:1;
-	int enable_stream:1;
-	int bit_clk_inv:1;
-	int lr_clk_inv:1;
+	unsigned int clk_master:1;
+	unsigned int clk_cpg:1;
+	unsigned int spdif:1;
+	unsigned int enable_stream:1;
+	unsigned int bit_clk_inv:1;
+	unsigned int lr_clk_inv:1;
 };
 
 struct fsi_stream_handler {
Signature · 1 line
1.8.0
Acked-by on v1 5/5
#17 lore raw

Re: [PATCH 5/5] ASoC: sh/fsi: Make one-bit bitfields unsigned

Hi

Quoted 12 lines

One-bit signed bitfields have two possible values: 0 and -1. This sometimes leads to unexpected results (e.g. foo.bar = 1; foo.bar == 1 => false) which is why it is recommended to make one-bit bitfields unsigned.

This fixes the following sparse warnings:
sound/soc/sh/fsi.c:267:25: error: dubious one-bit signed bitfield sound/soc/sh/fsi.c:268:22: error: dubious one-bit signed bitfield sound/soc/sh/fsi.c:269:20: error: dubious one-bit signed bitfield sound/soc/sh/fsi.c:270:28: error: dubious one-bit signed bitfield sound/soc/sh/fsi.c:271:26: error: dubious one-bit signed bitfield sound/soc/sh/fsi.c:272:25: error: dubious one-bit signed bitfield

Quoted 2 lines

---

Quoted 29 lines
 sound/soc/sh/fsi.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
sound/soc/sh/fsi.c +6 -6
index 710a079..2c95d85 100644
@@ -264,12 +264,12 @@ struct fsi_priv {
 	u32 fmt;
 
 	int chan_num:16;
-	int clk_master:1;
-	int clk_cpg:1;
-	int spdif:1;
-	int enable_stream:1;
-	int bit_clk_inv:1;
-	int lr_clk_inv:1;
+	unsigned int clk_master:1;
+	unsigned int clk_cpg:1;
+	unsigned int spdif:1;
+	unsigned int enable_stream:1;
+	unsigned int bit_clk_inv:1;
+	unsigned int lr_clk_inv:1;
 };
 
 struct fsi_stream_handler {
Signature · 1 line
1.8.0
maintainer Applied
#18 lore raw

Re: [PATCH 5/5] ASoC: sh/fsi: Make one-bit bitfields unsigned

In reply to Lars-Peter Clausen
Quoted 3 lines · Lars-Peter Clausen

One-bit signed bitfields have two possible values: 0 and -1. This sometimes leads to unexpected results (e.g. foo.bar = 1; foo.bar == 1 => false) which is why it is recommended to make one-bit bitfields unsigned.

Applied, thanks.