Patchwork [2/4] sparc32,leon: always include leon_pmc in build

login
register
mail settings
Submitter Sam Ravnborg
Date May 26, 2012, 2:43 p.m.
Message ID <1338043409-6827-2-git-send-email-sam@ravnborg.org>
Download mbox | patch
Permalink /patch/161488/
State Accepted
Delegated to: David Miller
Headers show

Comments

Sam Ravnborg - May 26, 2012, 2:43 p.m.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Daniel Hellstrom <daniel@gaisler.com>
Cc: Konrad Eisele <konrad@gaisler.com>
---
 arch/sparc/kernel/Makefile   |    2 +-
 arch/sparc/kernel/leon_pmc.c |   15 +++++++++------
 2 files changed, 10 insertions(+), 7 deletions(-)
Josip Rodin - May 27, 2012, 10:36 p.m.
On Sat, May 26, 2012 at 04:43:27PM +0200, Sam Ravnborg wrote:
> @@ -65,13 +66,15 @@ void pmc_leon_idle(void)
>  /* Install LEON Power Down function */
>  static int __init leon_pmc_install(void)
>  {
> -	/* Assign power management IDLE handler */
> -	if (pmc_leon_need_fixup())
> -		pm_idle = pmc_leon_idle_fixup;
> -	else
> -		pm_idle = pmc_leon_idle;
> +	if (sparc_cpu_model == sparc_leon) {
> +		/* Assign power management IDLE handler */
> +		if (pmc_leon_need_fixup())
> +			pm_idle = pmc_leon_idle_fixup;
> +		else
> +			pm_idle = pmc_leon_idle;
>  
> -	printk(KERN_INFO "leon: power management initialized\n");
> +		printk(KERN_INFO "leon: power management initialized\n");
> +	}
>  
>  	return 0;
>  }

Why not simply invert the logic and save a level of indentation?

if (sparc_cpu_model != sparc_leon)
	return 0;

Possibly also return something like -EINVAL - but I don't know the caller's
MO offhand so the fake 0 might actually be better.

Patch

diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index 43af0d6..6cf591b 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -52,7 +52,7 @@  obj-y                   += of_device_$(BITS).o
 obj-$(CONFIG_SPARC64)   += prom_irqtrans.o
 
 obj-$(CONFIG_SPARC32)   += leon_kernel.o
-obj-$(CONFIG_SPARC_LEON)+= leon_pmc.o
+obj-$(CONFIG_SPARC32)   += leon_pmc.o
 
 obj-$(CONFIG_SPARC64)   += reboot.o
 obj-$(CONFIG_SPARC64)   += sysfs.o
diff --git a/arch/sparc/kernel/leon_pmc.c b/arch/sparc/kernel/leon_pmc.c
index 519ca92..4e17432 100644
--- a/arch/sparc/kernel/leon_pmc.c
+++ b/arch/sparc/kernel/leon_pmc.c
@@ -7,6 +7,7 @@ 
 #include <linux/pm.h>
 
 #include <asm/leon_amba.h>
+#include <asm/cpu_type.h>
 #include <asm/leon.h>
 
 /* List of Systems that need fixup instructions around power-down instruction */
@@ -65,13 +66,15 @@  void pmc_leon_idle(void)
 /* Install LEON Power Down function */
 static int __init leon_pmc_install(void)
 {
-	/* Assign power management IDLE handler */
-	if (pmc_leon_need_fixup())
-		pm_idle = pmc_leon_idle_fixup;
-	else
-		pm_idle = pmc_leon_idle;
+	if (sparc_cpu_model == sparc_leon) {
+		/* Assign power management IDLE handler */
+		if (pmc_leon_need_fixup())
+			pm_idle = pmc_leon_idle_fixup;
+		else
+			pm_idle = pmc_leon_idle;
 
-	printk(KERN_INFO "leon: power management initialized\n");
+		printk(KERN_INFO "leon: power management initialized\n");
+	}
 
 	return 0;
 }