diff mbox

[U-Boot,12/17] eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_BITS

Message ID 1447185213-5799-12-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
Implement default value of 8 for this macro and pull out all of
this macro out of the code. The default value of 8 actually does
implement exactly the same behavior as the previous code which
was in the #else clause of the ifdef.

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 | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

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

Am 10.11.2015 um 20:53 schrieb Marek Vasut:
> Implement default value of 8 for this macro and pull out all of
> this macro out of the code. The default value of 8 actually does
> implement exactly the same behavior as the previous code which
> was in the #else clause of the ifdef.
>
> 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 | 16 ++++++++--------
>   1 file changed, 8 insertions(+), 8 deletions(-)


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

bye,
Heiko
>
> diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
> index c38c534..162a05c 100644
> --- a/common/cmd_eeprom.c
> +++ b/common/cmd_eeprom.c
> @@ -33,6 +33,13 @@
>   #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	0
>   #endif
>
> +#ifndef CONFIG_SYS_EEPROM_PAGE_WRITE_BITS
> +#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	8
> +#endif
> +
> +#define	EEPROM_PAGE_SIZE	(1 << CONFIG_SYS_EEPROM_PAGE_WRITE_BITS)
> +#define	EEPROM_PAGE_OFFSET(x)	((x) & (EEPROM_PAGE_SIZE - 1))
> +
>   /*
>    * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 2 (16-bit EEPROM address) offset is
>    *   0x000nxxxx for EEPROM address selectors at n, offset xxxx in EEPROM.
> @@ -194,15 +201,8 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
>   		 */
>   #if !defined(CONFIG_SYS_I2C_FRAM)
>
> -#if defined(CONFIG_SYS_EEPROM_PAGE_WRITE_BITS)
> -
> -#define	EEPROM_PAGE_SIZE	(1 << CONFIG_SYS_EEPROM_PAGE_WRITE_BITS)
> -#define	EEPROM_PAGE_OFFSET(x)	((x) & (EEPROM_PAGE_SIZE - 1))
> -
>   		maxlen = EEPROM_PAGE_SIZE - EEPROM_PAGE_OFFSET(blk_off);
> -#else
> -		maxlen = 0x100 - blk_off;
> -#endif
> +
>   		if (maxlen > I2C_RXTX_LEN)
>   			maxlen = I2C_RXTX_LEN;
>
>
Tom Rini Nov. 22, 2015, 3:54 p.m. UTC | #2
On Tue, Nov 10, 2015 at 08:53:28PM +0100, Marek Vasut wrote:

> Implement default value of 8 for this macro and pull out all of
> this macro out of the code. The default value of 8 actually does
> implement exactly the same behavior as the previous code which
> was in the #else clause of the ifdef.
> 
> 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 c38c534..162a05c 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -33,6 +33,13 @@ 
 #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	0
 #endif
 
+#ifndef CONFIG_SYS_EEPROM_PAGE_WRITE_BITS
+#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	8
+#endif
+
+#define	EEPROM_PAGE_SIZE	(1 << CONFIG_SYS_EEPROM_PAGE_WRITE_BITS)
+#define	EEPROM_PAGE_OFFSET(x)	((x) & (EEPROM_PAGE_SIZE - 1))
+
 /*
  * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 2 (16-bit EEPROM address) offset is
  *   0x000nxxxx for EEPROM address selectors at n, offset xxxx in EEPROM.
@@ -194,15 +201,8 @@  int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
 		 */
 #if !defined(CONFIG_SYS_I2C_FRAM)
 
-#if defined(CONFIG_SYS_EEPROM_PAGE_WRITE_BITS)
-
-#define	EEPROM_PAGE_SIZE	(1 << CONFIG_SYS_EEPROM_PAGE_WRITE_BITS)
-#define	EEPROM_PAGE_OFFSET(x)	((x) & (EEPROM_PAGE_SIZE - 1))
-
 		maxlen = EEPROM_PAGE_SIZE - EEPROM_PAGE_OFFSET(blk_off);
-#else
-		maxlen = 0x100 - blk_off;
-#endif
+
 		if (maxlen > I2C_RXTX_LEN)
 			maxlen = I2C_RXTX_LEN;