Skip to contentSkip to conversation

ASoC: remove those unnecessary #ifdef CONFIG_PXA3xx .. #endif

RFC PATCH In review Eric Miao 3 participants 6 messages Apr 23, 2009

Subsystems (3)
lore
Share & tools
lore

Eric Miao

author
#0 lore raw

RFC PATCH 4/5 ASoC: remove those unnecessary #ifdef CONFIG_PXA3xx .. #endif

These are unnecessary since the compiler is smart enough to optimize the code away if CONFIG_PXA3xx is not defined, when cpu_is_pxa3xx() will just be expanded to constant 0.

---
 sound/soc/pxa/pxa-ssp.c |   15 ---------------
 1 files changed, 0 insertions(+), 15 deletions(-)
sound/soc/pxa/pxa-ssp.c +0 -0
index a65993c..2ce4fb6 100644
@@ -360,24 +360,20 @@ static int pxa_ssp_set_dai_clkdiv(struct

snd_soc_dai *cpu_dai,
case PXA_SSP_AUDIO_DIV_SCDB:
val = ssp_read_reg(ssp, SSACD);
val &= ~SSACD_SCDB;
-#if defined(CONFIG_PXA3xx)
if (cpu_is_pxa3xx())
val &= ~SSACD_SCDX8;
-#endif
switch (div) {
case PXA_SSP_CLK_SCDB_1:
val |= SSACD_SCDB;
break;
case PXA_SSP_CLK_SCDB_4:
break;
-#if defined(CONFIG_PXA3xx)
case PXA_SSP_CLK_SCDB_8:
if (cpu_is_pxa3xx())
val |= SSACD_SCDX8;
else
return -EINVAL;
break;
-#endif
default:
return -EINVAL;
}
@@ -403,10 +399,8 @@ static int pxa_ssp_set_dai_pll(struct snd_soc_dai *cpu_dai,
struct ssp_device *ssp = priv->ssp;
u32 ssacd = ssp_read_reg(ssp, SSACD) & ~0x70;

-#if defined(CONFIG_PXA3xx)
if (cpu_is_pxa3xx())
ssp_write_reg(ssp, SSACDD, 0);
-#endif

switch (freq_out) {
case 5622000:
@@ -431,7 +425,6 @@ static int pxa_ssp_set_dai_pll(struct snd_soc_dai *cpu_dai,
break;

default:
-#ifdef CONFIG_PXA3xx
/* PXA3xx has a clock ditherer which can be used to generate
* a wider range of frequencies - calculate a value for it. */
@@ -452,8 +445,6 @@ static int pxa_ssp_set_dai_pll(struct snd_soc_dai *cpu_dai,
val, freq_out);
break;
}
-#endif
-
return -EINVAL;
}

@@ -652,10 +643,8 @@ static int pxa_ssp_hw_params(struct snd_pcm_substream *substream,
sscr0 = ssp_read_reg(ssp, SSCR0);
switch (params_format(params)) {
case SNDRV_PCM_FORMAT_S16_LE:
-#ifdef CONFIG_PXA3xx
if (cpu_is_pxa3xx())
sscr0 |= SSCR0_FPCKE;
-#endif
sscr0 |= SSCR0_DataSize(16);
break;
case SNDRV_PCM_FORMAT_S24_LE:
@@ -682,7 +671,6 @@ static int pxa_ssp_hw_params(struct snd_pcm_substream *substream,
* needed for that mode are only available on PXA3xx. */

-#ifdef CONFIG_PXA3xx
if (!cpu_is_pxa3xx())
return -EINVAL;

@@ -691,9 +679,6 @@ static int pxa_ssp_hw_params(struct snd_pcm_substream *substream,

 			sspsp |= SSPSP_EDMYSTOP(3);
 			sspsp |= SSPSP_DMYSTOP(3);
 			sspsp |= SSPSP_DMYSTRT(1);

-#else
- return -EINVAL;
-#endif
} else {
/* The frame width is the width the LRCLK is
* asserted for; the delay is expressed in

Signature · 6 lines
1.6.0.4

-------------------------------------------------------------------
List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel
FAQ:        http://www.arm.linux.org.uk/mailinglists/faq.php
Etiquette:  http://www.arm.linux.org.uk/mailinglists/etiquette.php
#1 lore raw

Hi Eric,

Quoted 22 lines · Eric Miao
(quoted diff) +0 -2
@@ -652,10 +643,8 @@ static int pxa_ssp_hw_params(struct
 snd_pcm_substream *substream,
 	sscr0 = ssp_read_reg(ssp, SSCR0);
 	switch (params_format(params)) {
 	case SNDRV_PCM_FORMAT_S16_LE:
-#ifdef CONFIG_PXA3xx
 		if (cpu_is_pxa3xx())
 			sscr0 |= SSCR0_FPCKE;
-#endif
 		sscr0 |= SSCR0_DataSize(16);
 		break;
(quoted diff) +0 -1
 	case SNDRV_PCM_FORMAT_S24_LE:
@@ -682,7 +671,6 @@ static int pxa_ssp_hw_params(struct
 snd_pcm_substream *substream,
 			* needed for that mode are only available on PXA3xx.
 			*/
 
-#ifdef CONFIG_PXA3xx
 			if (!cpu_is_pxa3xx())
 				return -EINVAL;

Review static int pxa_ssp_hw_params(struct · line 682

Quoted 4 lines
(quoted diff) +0 -0
@@ -691,9 +679,6 @@ static int pxa_ssp_hw_params(struct
 snd_pcm_substream *substream,
 			sspsp |= SSPSP_EDMYSTOP(3);
 			sspsp |= SSPSP_DMYSTOP(3);
 			sspsp |= SSPSP_DMYSTRT(1);

These macros are only defined for PXA3xx since the register bits are not used on other PXAs. Hence, the usage of these macros must be conditional as well. Was this ever compiled for PXA2xx?

Daniel

#2 lore raw
In reply to Eric Miao
Quoted 3 lines · Eric Miao

These are unnecessary since the compiler is smart enough to optimize the code away if CONFIG_PXA3xx is not defined, when cpu_is_pxa3xx() will just be expanded to constant 0.

This isn't done for compiler optimisation - it's done because the register bit macros are only defined if PXA3xx support is being built in. I've no problem with removing those guards but without that you'll get build failures on PXA2xx.

author
#3 lore raw
Quoted 10 lines · Mark Brown
Quoted 3 lines · Eric Miao

These are unnecessary since the compiler is smart enough to optimize the code away if CONFIG_PXA3xx is not defined, when cpu_is_pxa3xx() will just be expanded to constant 0.

This isn't done for compiler optimisation - it's done because the register bit macros are only defined if PXA3xx support is being built in.  I've no problem with removing those guards but without that you'll get build failures on PXA2xx.

Yeah, indeed. This is a rush (so the title is RFC), sorry. I'll get those conditional #ifdef .. #endif removed as well in the ssp-regs.h, it always makes me upset. And possibly to get ssp-regs.h merged into ssp.h. No one else now wants to use either one of these header files.

Signature · 6 lines
Cheers
- eric
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#4 lore raw
Quoted 10 lines · Eric Miao
Quoted 5 lines · Mark Brown

This isn't done for compiler optimisation - it's done because the register bit macros are only defined if PXA3xx support is being built in.  I've no problem with removing those guards but without that you'll get build failures on PXA2xx.

Yeah, indeed. This is a rush (so the title is RFC), sorry. I'll get those conditional #ifdef .. #endif removed as well in the ssp-regs.h, it always makes me upset.

Well, I put them in there to clearly state which CPUs have support for this particular feature. Especially for PXAs, where even register definitions are considered confidential, this might help people fishing in muddy waters. Some comment would do as well, though.

Daniel

author
#5 lore raw
Quoted 8 lines · Daniel Mack
Quoted 7 lines · Eric Miao
Quoted 5 lines · Mark Brown

This isn't done for compiler optimisation - it's done because the register bit macros are only defined if PXA3xx support is being built in.  I've no problem with removing those guards but without that you'll get build failures on PXA2xx.

Quoted 9 lines
Quoted 3 lines

Yeah, indeed. This is a rush (so the title is RFC), sorry. I'll get those conditional #ifdef .. #endif removed as well in the ssp-regs.h, it always makes me upset.

Well, I put them in there to clearly state which CPUs have support for this particular feature. Especially for PXAs, where even register definitions are considered confidential, this might help people fishing in muddy waters. Some comment would do as well, though.

Yeah, I fully understand that. Actually these are inclusive #ifdef .. which actually doesn't hurt. (Unlike #ifdef .. #else .. #endif).

But since the compiler can actually optimize it away, and it's quite obvious pxa3xx specific by if (cpu_is_pxa3xx()) .. , I'm a bit intended to remove them away, no?
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel