diff mbox

[U-Boot,09/17] eeprom: Make eeprom_write_enable() weak

Message ID 1447185213-5799-9-git-send-email-marex@denx.de
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Marek Vasut Nov. 10, 2015, 7:53 p.m. UTC
Make this function weak and implement it's weak implementation
so that the boards can just reimplement it. This zaps the horrid
CONFIG_SYS_EEPROM_WREN macro.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Heiko Schocher <hs@denx.de>
---
 common/cmd_eeprom.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Comments

Heiko Schocher Nov. 16, 2015, 11:28 a.m. UTC | #1
Hello Marek,

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> Make this function weak and implement it's weak implementation
> so that the boards can just reimplement it. This zaps the horrid
> CONFIG_SYS_EEPROM_WREN macro.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> ---
>   common/cmd_eeprom.c | 18 +++++++++---------
>   1 file changed, 9 insertions(+), 9 deletions(-)


Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index 5979993..040ab5f 100644
> --- a/common/cmd_eeprom.c
> +++ b/common/cmd_eeprom.c
> @@ -44,9 +44,10 @@
>   #endif
>   #endif
>
> -#if defined(CONFIG_SYS_EEPROM_WREN)
> -extern int eeprom_write_enable (unsigned dev_addr, int state);
> -#endif
> +__weak int eeprom_write_enable(unsigned dev_addr, int state)
> +{
> +	return 0;
> +}
>
>   void eeprom_init(void)
>   {
> @@ -163,9 +164,8 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>   	int rcode = 0;
>   	uchar addr[3];
>
> -#if defined(CONFIG_SYS_EEPROM_WREN)
> -	eeprom_write_enable (dev_addr,1);
> -#endif
> +	eeprom_write_enable(dev_addr, 1);
> +
>   	/*
>   	 * Write data until done or would cross a write page boundary.
>   	 * We must write the address again when changing pages
> @@ -215,9 +215,9 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>   		udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
>   #endif
>   	}
> -#if defined(CONFIG_SYS_EEPROM_WREN)
> -	eeprom_write_enable (dev_addr,0);
> -#endif
> +
> +	eeprom_write_enable(dev_addr, 0);
> +
>   	return rcode;
>   }
>
>
Tom Rini Nov. 22, 2015, 3:54 p.m. UTC | #2
On Tue, Nov 10, 2015 at 08:53:25PM +0100, Marek Vasut wrote:

> Make this function weak and implement it's weak implementation
> so that the boards can just reimplement it. This zaps the horrid
> CONFIG_SYS_EEPROM_WREN macro.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Heiko Schocher <hs@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index 5979993..040ab5f 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -44,9 +44,10 @@ 
 #endif
 #endif
 
-#if defined(CONFIG_SYS_EEPROM_WREN)
-extern int eeprom_write_enable (unsigned dev_addr, int state);
-#endif
+__weak int eeprom_write_enable(unsigned dev_addr, int state)
+{
+	return 0;
+}
 
 void eeprom_init(void)
 {
@@ -163,9 +164,8 @@  int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 	int rcode = 0;
 	uchar addr[3];
 
-#if defined(CONFIG_SYS_EEPROM_WREN)
-	eeprom_write_enable (dev_addr,1);
-#endif
+	eeprom_write_enable(dev_addr, 1);
+
 	/*
 	 * Write data until done or would cross a write page boundary.
 	 * We must write the address again when changing pages
@@ -215,9 +215,9 @@  int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 		udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
 #endif
 	}
-#if defined(CONFIG_SYS_EEPROM_WREN)
-	eeprom_write_enable (dev_addr,0);
-#endif
+
+	eeprom_write_enable(dev_addr, 0);
+
 	return rcode;
 }