mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Lucas Stach <dev@lynxeye.de>
To: Jan Luebbe <jlu@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/4] am33xx_generic: convert from switch to if/else
Date: Wed, 02 Oct 2013 21:45:42 +0200	[thread overview]
Message-ID: <1380743142.14068.2.camel@tellur> (raw)
In-Reply-To: <1380742211-2731-2-git-send-email-jlu@pengutronix.de>

Am Mittwoch, den 02.10.2013, 21:30 +0200 schrieb Jan Luebbe:
> The function am33xx_get_cpu_rev may be called before barebox_arm_entry(),
> so we need to avoid switch statements. 

Uhm, could you please be more verbose on _why_ we need to avoid switch
statements at this stage? I might be running into the same failure with
Tegra at some point if there's a real issue.

Thanks,
Lucas

> 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>
> ---
>  arch/arm/mach-omap/am33xx_generic.c |   31 +++++++++++--------------------
>  1 file changed, 11 insertions(+), 20 deletions(-)
> 
> diff --git a/arch/arm/mach-omap/am33xx_generic.c b/arch/arm/mach-omap/am33xx_generic.c
> index 3690ce1..251c8d4 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;
>  }
>  
>  /**



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2013-10-02 19:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-02 19:30 BeagleBone fixes & cleanup Jan Luebbe
2013-10-02 19:30 ` [PATCH 1/4] am33xx_generic: convert from switch to if/else Jan Luebbe
2013-10-02 19:45   ` Lucas Stach [this message]
2013-10-02 20:04     ` Jan Lübbe
2013-10-02 20:16       ` Lucas Stach
2013-10-02 19:30 ` [PATCH 2/4] arm: mmu: be more verbose if ttb setup fails Jan Luebbe
2013-10-02 19:30 ` [PATCH 3/4] arm: omap: am33xx_generic: fix DDR setup for DDR2 Jan Luebbe
2013-10-02 19:30 ` [PATCH 4/4] beaglebone: use most recent timings for white variant Jan Luebbe
2013-10-06 11:15 ` BeagleBone fixes & cleanup Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1380743142.14068.2.camel@tellur \
    --to=dev@lynxeye.de \
    --cc=barebox@lists.infradead.org \
    --cc=jlu@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox