mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] at91sam9260/9g20ek: cleanup and optimization
@ 2013-02-15 10:41 Fabio Porcedda
  2013-02-15 10:41 ` [PATCH 1/2] at91sam9260/9g20ek: use IS_ENABLED instead of #if/#ifdef Fabio Porcedda
  2013-02-15 10:41 ` [PATCH 2/2] at91sam9260/9g20ek: remove #ifdef for ek_usb_add_device_mci() Fabio Porcedda
  0 siblings, 2 replies; 7+ messages in thread
From: Fabio Porcedda @ 2013-02-15 10:41 UTC (permalink / raw)
  To: barebox

Some cleanup and optimization removing #if/#ifdef and using IS_ENABLED.

Best regards

Fabio Porcedda (2):
  at91sam9260/9g20ek: use IS_ENABLED instead of #if/#ifdef
  at91sam9260/9g20ek: remove #ifdef for ek_usb_add_device_mci()

 arch/arm/boards/at91sam9260ek/init.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

-- 
1.8.1.1


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] at91sam9260/9g20ek: use IS_ENABLED instead of #if/#ifdef
  2013-02-15 10:41 [PATCH 0/2] at91sam9260/9g20ek: cleanup and optimization Fabio Porcedda
@ 2013-02-15 10:41 ` Fabio Porcedda
  2013-02-15 10:47   ` Fabio Porcedda
  2013-02-15 10:41 ` [PATCH 2/2] at91sam9260/9g20ek: remove #ifdef for ek_usb_add_device_mci() Fabio Porcedda
  1 sibling, 1 reply; 7+ messages in thread
From: Fabio Porcedda @ 2013-02-15 10:41 UTC (permalink / raw)
  To: barebox

Using IS_ENABLED instead of #if/#ifdef the compiler can check
all the code.
Using IS_ENABLED for configuring smc->mode is an optimization,
reduce init.o text from 905 to 877.

Signed-off-by: Fabio Porcedda <fabio.porcedda@gmail.com>
Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/at91sam9260ek/init.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/arch/arm/boards/at91sam9260ek/init.c b/arch/arm/boards/at91sam9260ek/init.c
index 06a53f2..bb0025d 100644
--- a/arch/arm/boards/at91sam9260ek/init.c
+++ b/arch/arm/boards/at91sam9260ek/init.c
@@ -37,9 +37,8 @@ static void ek_set_board_type(void)
 {
 	if (machine_is_at91sam9g20ek()) {
 		armlinux_set_architecture(MACH_TYPE_AT91SAM9G20EK);
-#ifdef CONFIG_AT91_HAVE_2MMC
-		armlinux_set_revision(HAVE_2MMC);
-#endif
+		if (IS_ENABLED(CONFIG_AT91_HAVE_2MMC))
+			armlinux_set_revision(HAVE_2MMC);
 	} else {
 		armlinux_set_architecture(MACH_TYPE_AT91SAM9260EK);
 	}
@@ -107,10 +106,12 @@ static void ek_add_device_nand(void)
 		smc = &ek_9260_nand_smc_config;
 
 	/* setup bus-width (8 or 16) */
-	if (nand_pdata.bus_width_16)
+	if (IS_ENABLED(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)) {
+		nand_pdata.bus_width_16 = 1;
 		smc->mode |= AT91_SMC_DBW_16;
-	else
+	} else {
 		smc->mode |= AT91_SMC_DBW_8;
+	}
 
 	/* configure chip-select 3 (NAND) */
 	sam9_smc_configure(0, 3, smc);
@@ -209,10 +210,10 @@ static void __init ek_add_led(void)
 {
 	int i;
 
-#ifdef CONFIG_AT91_HAVE_2MMC
-	leds[0].gpio = AT91_PIN_PB8;
-	leds[1].gpio = AT91_PIN_PB9;
-#endif
+	if (IS_ENABLED(CONFIG_AT91_HAVE_2MMC)) {
+		leds[0].gpio = AT91_PIN_PB8;
+		leds[1].gpio = AT91_PIN_PB9;
+	}
 
 	for (i = 0; i < ARRAY_SIZE(leds); i++) {
 		at91_set_gpio_output(leds[i].gpio, leds[i].active_low);
-- 
1.8.1.1


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/2] at91sam9260/9g20ek: remove #ifdef for ek_usb_add_device_mci()
  2013-02-15 10:41 [PATCH 0/2] at91sam9260/9g20ek: cleanup and optimization Fabio Porcedda
  2013-02-15 10:41 ` [PATCH 1/2] at91sam9260/9g20ek: use IS_ENABLED instead of #if/#ifdef Fabio Porcedda
@ 2013-02-15 10:41 ` Fabio Porcedda
  2013-02-15 10:44   ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 1 reply; 7+ messages in thread
From: Fabio Porcedda @ 2013-02-15 10:41 UTC (permalink / raw)
  To: barebox

Remove #ifdef for ek_usb_add_device_mci() because there is already
the #ifdef inside at91_add_device_mci(), this way the compiler can check
always the code without any penality.

Signed-off-by: Fabio Porcedda <fabio.porcedda@gmail.com>
Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/at91sam9260ek/init.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/arch/arm/boards/at91sam9260ek/init.c b/arch/arm/boards/at91sam9260ek/init.c
index bb0025d..e6de72f 100644
--- a/arch/arm/boards/at91sam9260ek/init.c
+++ b/arch/arm/boards/at91sam9260ek/init.c
@@ -158,7 +158,6 @@ static void at91sam9260ek_phy_reset(void)
 /*
  * MCI (SD/MMC)
  */
-#if defined(CONFIG_MCI_ATMEL)
 static struct atmel_mci_platform_data __initdata ek_mci_data = {
 	.bus_width	= 4,
 	.slot_b		= 1,
@@ -171,9 +170,6 @@ static void ek_usb_add_device_mci(void)
 
 	at91_add_device_mci(0, &ek_mci_data);
 }
-#else
-static void ek_usb_add_device_mci(void) {}
-#endif
 
 /*
  * USB Host port
-- 
1.8.1.1


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] at91sam9260/9g20ek: remove #ifdef for ek_usb_add_device_mci()
  2013-02-15 10:41 ` [PATCH 2/2] at91sam9260/9g20ek: remove #ifdef for ek_usb_add_device_mci() Fabio Porcedda
@ 2013-02-15 10:44   ` Jean-Christophe PLAGNIOL-VILLARD
  2013-02-15 10:52     ` Fabio Porcedda
  0 siblings, 1 reply; 7+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-15 10:44 UTC (permalink / raw)
  To: Fabio Porcedda; +Cc: barebox

On 11:41 Fri 15 Feb     , Fabio Porcedda wrote:
> Remove #ifdef for ek_usb_add_device_mci() because there is already
> the #ifdef inside at91_add_device_mci(), this way the compiler can check
> always the code without any penality.
 it's not the struct will be keep

 keep the ifdef

Best Regards,
J.

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] at91sam9260/9g20ek: use IS_ENABLED instead of #if/#ifdef
  2013-02-15 10:41 ` [PATCH 1/2] at91sam9260/9g20ek: use IS_ENABLED instead of #if/#ifdef Fabio Porcedda
@ 2013-02-15 10:47   ` Fabio Porcedda
  0 siblings, 0 replies; 7+ messages in thread
From: Fabio Porcedda @ 2013-02-15 10:47 UTC (permalink / raw)
  To: barebox

On Fri, Feb 15, 2013 at 11:41 AM, Fabio Porcedda
<fabio.porcedda@gmail.com> wrote:
> Using IS_ENABLED instead of #if/#ifdef the compiler can check
> all the code.
> Using IS_ENABLED for configuring smc->mode is an optimization,
> reduce init.o text from 905 to 877.
>
> Signed-off-by: Fabio Porcedda <fabio.porcedda@gmail.com>
> Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  arch/arm/boards/at91sam9260ek/init.c | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/arch/arm/boards/at91sam9260ek/init.c b/arch/arm/boards/at91sam9260ek/init.c
> index 06a53f2..bb0025d 100644
> --- a/arch/arm/boards/at91sam9260ek/init.c
> +++ b/arch/arm/boards/at91sam9260ek/init.c
> @@ -37,9 +37,8 @@ static void ek_set_board_type(void)
>  {
>         if (machine_is_at91sam9g20ek()) {
>                 armlinux_set_architecture(MACH_TYPE_AT91SAM9G20EK);
> -#ifdef CONFIG_AT91_HAVE_2MMC
> -               armlinux_set_revision(HAVE_2MMC);
> -#endif
> +               if (IS_ENABLED(CONFIG_AT91_HAVE_2MMC))
> +                       armlinux_set_revision(HAVE_2MMC);
>         } else {
>                 armlinux_set_architecture(MACH_TYPE_AT91SAM9260EK);
>         }
> @@ -107,10 +106,12 @@ static void ek_add_device_nand(void)
>                 smc = &ek_9260_nand_smc_config;
>
>         /* setup bus-width (8 or 16) */
> -       if (nand_pdata.bus_width_16)
> +       if (IS_ENABLED(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)) {
> +               nand_pdata.bus_width_16 = 1;
>                 smc->mode |= AT91_SMC_DBW_16;
> -       else
> +       } else {
>                 smc->mode |= AT91_SMC_DBW_8;
> +       }

I will push a v2 because the nand_pdata.bus_width_16 must be removed
in the struct definition.

>
>         /* configure chip-select 3 (NAND) */
>         sam9_smc_configure(0, 3, smc);
> @@ -209,10 +210,10 @@ static void __init ek_add_led(void)
>  {
>         int i;
>
> -#ifdef CONFIG_AT91_HAVE_2MMC
> -       leds[0].gpio = AT91_PIN_PB8;
> -       leds[1].gpio = AT91_PIN_PB9;
> -#endif
> +       if (IS_ENABLED(CONFIG_AT91_HAVE_2MMC)) {
> +               leds[0].gpio = AT91_PIN_PB8;
> +               leds[1].gpio = AT91_PIN_PB9;
> +       }
>
>         for (i = 0; i < ARRAY_SIZE(leds); i++) {
>                 at91_set_gpio_output(leds[i].gpio, leds[i].active_low);
> --
> 1.8.1.1
>



--
Fabio Porcedda

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] at91sam9260/9g20ek: remove #ifdef for ek_usb_add_device_mci()
  2013-02-15 10:44   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2013-02-15 10:52     ` Fabio Porcedda
  2013-02-15 11:14       ` Fabio Porcedda
  0 siblings, 1 reply; 7+ messages in thread
From: Fabio Porcedda @ 2013-02-15 10:52 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Fri, Feb 15, 2013 at 11:44 AM, Jean-Christophe PLAGNIOL-VILLARD
<plagnioj@jcrosoft.com> wrote:
> On 11:41 Fri 15 Feb     , Fabio Porcedda wrote:
>> Remove #ifdef for ek_usb_add_device_mci() because there is already
>> the #ifdef inside at91_add_device_mci(), this way the compiler can check
>> always the code without any penality.
>  it's not the struct will be keep

The struct isn't keep
without this patch:
  text       data        bss        dec        hex    filename
    877        192          0       1069        42d
arch/arm/boards/at91sam9260ek/init.o
with this patch:
 text       data        bss        dec        hex    filename
    877        192          0       1069        42d
arch/arm/boards/at91sam9260ek/init.o

>  keep the ifdef
> Best Regards,
> J.

Best regards
--
Fabio Porcedda

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] at91sam9260/9g20ek: remove #ifdef for ek_usb_add_device_mci()
  2013-02-15 10:52     ` Fabio Porcedda
@ 2013-02-15 11:14       ` Fabio Porcedda
  0 siblings, 0 replies; 7+ messages in thread
From: Fabio Porcedda @ 2013-02-15 11:14 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Fri, Feb 15, 2013 at 11:52 AM, Fabio Porcedda
<fabio.porcedda@gmail.com> wrote:
> On Fri, Feb 15, 2013 at 11:44 AM, Jean-Christophe PLAGNIOL-VILLARD
> <plagnioj@jcrosoft.com> wrote:
>> On 11:41 Fri 15 Feb     , Fabio Porcedda wrote:
>>> Remove #ifdef for ek_usb_add_device_mci() because there is already
>>> the #ifdef inside at91_add_device_mci(), this way the compiler can check
>>> always the code without any penality.
>>  it's not the struct will be keep
>
> The struct isn't keep
> without this patch:
>   text       data        bss        dec        hex    filename
>     877        192          0       1069        42d
> arch/arm/boards/at91sam9260ek/init.o
> with this patch:
>  text       data        bss        dec        hex    filename
>     877        192          0       1069        42d
> arch/arm/boards/at91sam9260ek/init.o


I'm sorry, you are right, i've made i mistake when checking.

  text       data        bss        dec        hex    filename
    861        176          0       1037        40d
arch/arm/boards/at91sam9260ek/init.o

  text       data        bss        dec        hex    filename
    877        192          0       1069        42d
arch/arm/boards/at91sam9260ek/init.o


>>  keep the ifdef
>> Best Regards,
>> J.
>
> Best regards
> --
> Fabio Porcedda



--
Fabio Porcedda

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-02-15 11:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-15 10:41 [PATCH 0/2] at91sam9260/9g20ek: cleanup and optimization Fabio Porcedda
2013-02-15 10:41 ` [PATCH 1/2] at91sam9260/9g20ek: use IS_ENABLED instead of #if/#ifdef Fabio Porcedda
2013-02-15 10:47   ` Fabio Porcedda
2013-02-15 10:41 ` [PATCH 2/2] at91sam9260/9g20ek: remove #ifdef for ek_usb_add_device_mci() Fabio Porcedda
2013-02-15 10:44   ` Jean-Christophe PLAGNIOL-VILLARD
2013-02-15 10:52     ` Fabio Porcedda
2013-02-15 11:14       ` Fabio Porcedda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox