mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Fabio Porcedda <fabio.porcedda@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] at91sam9260/9g20ek: refactor init_board script
Date: Tue, 19 Feb 2013 08:56:35 +0100	[thread overview]
Message-ID: <20130219075635.GW1906@pengutronix.de> (raw)
In-Reply-To: <1361186535-14811-1-git-send-email-fabio.porcedda@gmail.com>

On Mon, Feb 18, 2013 at 12:22:15PM +0100, Fabio Porcedda wrote:
> Refactor to remove duplicated code without changing functionality.
> Put "then" on the same line of "if", because:
>  - is the most used style in barebox
>  - is like c code style
>  - is more compact
> 
> Reduce the number of lines from 50 to 40.

Applied, thanks

Sascha

> 
> Tested on at91sam9260ek.
> 
> Signed-off-by: Fabio Porcedda <fabio.porcedda@gmail.com>
> Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  arch/arm/boards/at91sam9260ek/env/bin/init_board | 54 ++++++++++--------------
>  1 file changed, 22 insertions(+), 32 deletions(-)
> 
> diff --git a/arch/arm/boards/at91sam9260ek/env/bin/init_board b/arch/arm/boards/at91sam9260ek/env/bin/init_board
> index 977430d..27d767d 100644
> --- a/arch/arm/boards/at91sam9260ek/env/bin/init_board
> +++ b/arch/arm/boards/at91sam9260ek/env/bin/init_board
> @@ -8,43 +8,33 @@ vendor_id=0x4321
>  
>  dfu_config="/dev/nand0.barebox.bb(barebox)sr,/dev/nand0.kernel.bb(kernel)r,/dev/nand0.rootfs.bb(rootfs)r"
>  
> -if [ $at91_udc0.vbus != 1 ]
> -then
> +if [ $at91_udc0.vbus != 1 ]; then
>  	echo "No USB Device cable plugged, normal boot"
>  	exit
>  fi
>  
>  gpio_get_value ${dfu_button}
> -if [ $? != 0 ]
> -then
> -	autoboot_timeout=16
> -	echo "enable tty over USB Device, increase the boot delay to ${autoboot_timeout}s"
> -	usbserial
> -	exit
> -fi
> -
> -echo "${button_name} pressed detected wait ${button_wait}s"
> -timeout -s -a ${button_wait}
> -
> -if [ $at91_udc0.vbus != 1 ]
> -then
> -	echo "No USB Device cable plugged, normal boot"
> -	exit
> -fi
> -
> -gpio_get_value ${dfu_button}
> -if [ $? != 0 ]
> -then
> +if [ $? = 0 ]; then
> +	echo "${button_name} pressed detected wait ${button_wait}s"
> +	timeout -s -a ${button_wait}
> +
> +	if [ $at91_udc0.vbus != 1 ]; then
> +		echo "No USB Device cable plugged, normal boot"
> +		exit
> +	fi
> +
> +	gpio_get_value ${dfu_button}
> +	if [ $? = 0 ]; then
> +		echo ""
> +		echo "Start DFU Mode"
> +		echo ""
> +		led ds5 1
> +		dfu ${dfu_config} -P ${product_id} -V ${vendor_id}
> +		exit
> +	fi
>  	echo "${button_name} released, normal boot"
> -	autoboot_timeout=16
> -	echo "enable tty over USB Device, increase the boot delay to ${autoboot_timeout}s"
> -	usbserial
> -	exit
>  fi
>  
> -echo ""
> -echo "Start DFU Mode"
> -echo ""
> -
> -led ds5 1
> -dfu ${dfu_config} -P ${product_id} -V ${vendor_id}
> +autoboot_timeout=16
> +echo "enable tty over USB Device, increase the boot delay to ${autoboot_timeout}s"
> +usbserial
> -- 
> 1.8.1.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

      reply	other threads:[~2013-02-19  7:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-18 11:22 Fabio Porcedda
2013-02-19  7:56 ` Sascha Hauer [this message]

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=20130219075635.GW1906@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=fabio.porcedda@gmail.com \
    /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