Patchwork [U-Boot] common: env_mmc: Use __weak annotation to simplify code

login
register
mail settings
Submitter Fabio Estevam
Date Jan. 8, 2013, 3:36 p.m.
Message ID <1357659371-25513-1-git-send-email-fabio.estevam@freescale.com>
Download mbox | patch
Permalink /patch/210424/
State Accepted
Delegated to: Stefano Babic
Headers show

Comments

Fabio Estevam - Jan. 8, 2013, 3:36 p.m.
Using the __weak annotation can make the code cleaner.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 common/env_mmc.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
Marek Vasut - Jan. 8, 2013, 3:57 p.m.
Dear Fabio Estevam,

> Using the __weak annotation can make the code cleaner.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Just a quickie -- have you checked that noone is using the "default" versions of 
all these functions you annotate with __weak?

Other than that:

Acked-by: Marek Vasut <marex@denx.de>

> ---
>  common/env_mmc.c |    4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/common/env_mmc.c b/common/env_mmc.c
> index ce21671..02bd5ae 100644
> --- a/common/env_mmc.c
> +++ b/common/env_mmc.c
> @@ -46,13 +46,11 @@ DECLARE_GLOBAL_DATA_PTR;
>  #define CONFIG_ENV_OFFSET 0
>  #endif
> 
> -static int __mmc_get_env_addr(struct mmc *mmc, u32 *env_addr)
> +__weak int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr)
>  {
>  	*env_addr = CONFIG_ENV_OFFSET;
>  	return 0;
>  }
> -int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr)
> -	__attribute__((weak, alias("__mmc_get_env_addr")));
> 
>  int env_init(void)
>  {

Best regards,
Marek Vasut
Stefano Babic - Jan. 28, 2013, 5:54 a.m.
On 08/01/2013 16:36, Fabio Estevam wrote:
> Using the __weak annotation can make the code cleaner.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic
Tom Rini - Feb. 4, 2013, 4:37 p.m.
On Tue, Jan 08, 2013 at 05:36:11AM -0000, Fabio Estevam wrote:

> Using the __weak annotation can make the code cleaner.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> Acked-by: Marek Vasut <marex@denx.de>

Applied to u-boot/master, thanks!

Patch

diff --git a/common/env_mmc.c b/common/env_mmc.c
index ce21671..02bd5ae 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -46,13 +46,11 @@  DECLARE_GLOBAL_DATA_PTR;
 #define CONFIG_ENV_OFFSET 0
 #endif
 
-static int __mmc_get_env_addr(struct mmc *mmc, u32 *env_addr)
+__weak int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr)
 {
 	*env_addr = CONFIG_ENV_OFFSET;
 	return 0;
 }
-int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr)
-	__attribute__((weak, alias("__mmc_get_env_addr")));
 
 int env_init(void)
 {