From: Marek Vasut Date: Mon, 20 Oct 2014 03:48:20 +0200 Subject: [U-Boot] [PATCH 19/25] eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_BITS In-Reply-To: <1413769706-8596-1-git-send-email-marex@denx.de> References: <1413769706-8596-1-git-send-email-marex@denx.de> Message-ID: <1413769706-8596-20-git-send-email-marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 Cc: Simon Glass Cc: Tom Rini Cc: Heiko Schocher --- common/cmd_eeprom.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c index 97747de..6f55306 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@n, offset xxxx in EEPROM. @@ -198,15 +205,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; -- 2.1.1