Skip to content

Commit

Permalink
eeprom: Pull out CONFIG_SYS_EEPROM_PAGE_WRITE_BITS
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Heiko Schocher <[email protected]>
Reviewed-by: Heiko Schocher <[email protected]>
  • Loading branch information
Marek Vasut authored and trini committed Nov 22, 2015
1 parent 8eee40a commit 6717e3c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions common/cmd_eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 6717e3c

Please sign in to comment.