summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Luebbe <jlu@pengutronix.de>2013-10-02 21:30:08 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-10-06 13:13:53 +0200
commit45b1e9c274a5cd0f339fcb8bf383e0f340fae584 (patch)
tree43746a39ab1eb3b99995d20f776a0effd7e48943
parent363843eba770c17ccd882d5ae0f3c5e747ae256f (diff)
downloadbarebox-45b1e9c274a5cd0f339fcb8bf383e0f340fae584.tar.gz
barebox-45b1e9c274a5cd0f339fcb8bf383e0f340fae584.tar.xz
am33xx_generic: convert from switch to if/else
The function am33xx_get_cpu_rev may be called before barebox_arm_entry(), so we need to avoid switch statements. One example is the BeagleBone, where we use this function to differenciate between the white and black variants. Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/arm/mach-omap/am33xx_generic.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/arch/arm/mach-omap/am33xx_generic.c b/arch/arm/mach-omap/am33xx_generic.c
index 3690ce1438..251c8d4876 100644
--- a/arch/arm/mach-omap/am33xx_generic.c
+++ b/arch/arm/mach-omap/am33xx_generic.c
@@ -43,30 +43,21 @@ void __noreturn reset_cpu(unsigned long addr)
* The significance of the CPU revision depends upon the cpu type.
* Latest known revision is considered default.
*
+ * This function is called before barebox_arm_entry(), so avoid switch
+ * statements.
+ *
* @return silicon version
*/
u32 am33xx_get_cpu_rev(void)
{
- u32 version, retval;
-
- version = (readl(AM33XX_IDCODE_REG) >> 28) & 0xF;
-
- switch (version) {
- case 0:
- retval = AM335X_ES1_0;
- break;
- case 1:
- retval = AM335X_ES2_0;
- break;
- case 2:
- /*
- * Fall through the default case.
- */
- default:
- retval = AM335X_ES2_1;
- }
-
- return retval;
+ u32 version = (readl(AM33XX_IDCODE_REG) >> 28) & 0xF;
+
+ if (version == 0)
+ return AM335X_ES1_0;
+ else if (version == 1)
+ return AM335X_ES2_0;
+ else
+ return AM335X_ES2_1;
}
/**