diff options
author | Holger Brunck <holger.brunck@keymile.com> | 2013-01-21 03:55:17 +0000 |
---|---|---|
committer | Kim Phillips <kim.phillips@freescale.com> | 2013-02-15 17:47:19 -0600 |
commit | 322bb2056ba90d55603f081ae57a652a06357bac (patch) | |
tree | c24cb45c4674465ef01e978e319a98357fd98974 /board | |
parent | 1eb95ebe0d466d793fcf1f689fc20f6cc83c7fe1 (diff) | |
download | u-boot-imx-322bb2056ba90d55603f081ae57a652a06357bac.zip u-boot-imx-322bb2056ba90d55603f081ae57a652a06357bac.tar.gz u-boot-imx-322bb2056ba90d55603f081ae57a652a06357bac.tar.bz2 |
km/common/ivm: rework piggy mac adress offset generation
For the the kmvect1 board we will also need a functionality to add an
offset to the IVMs MAC address, because these board will have two valid
ethernet ports for debugging purpose. So move the code to an own
function.
Signed-off-by: Holger Brunck <holger.brunck@keymile.com>
Diffstat (limited to 'board')
-rw-r--r-- | board/keymile/common/ivm.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/board/keymile/common/ivm.c b/board/keymile/common/ivm.c index 607daa6..d568fd9 100644 --- a/board/keymile/common/ivm.c +++ b/board/keymile/common/ivm.c @@ -201,6 +201,22 @@ static int ivm_check_crc(unsigned char *buf, int block) return 0; } +static int calculate_mac_offset(unsigned char *valbuf, unsigned char *buf, + int offset) +{ + unsigned long val = (buf[4] << 16) + (buf[5] << 8) + buf[6]; + + if (offset == 0) + return 0; + + val += offset; + buf[4] = (val >> 16) & 0xff; + buf[5] = (val >> 8) & 0xff; + buf[6] = val & 0xff; + sprintf((char *)valbuf, "%pM", buf + 1); + return 0; +} + static int ivm_analyze_block2(unsigned char *buf, int len) { unsigned char valbuf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN]; @@ -210,17 +226,7 @@ static int ivm_analyze_block2(unsigned char *buf, int len) sprintf((char *)valbuf, "%pM", buf + 1); ivm_set_value("IVM_MacAddress", (char *)valbuf); /* if an offset is defined, add it */ -#if defined(CONFIG_PIGGY_MAC_ADRESS_OFFSET) - if (CONFIG_PIGGY_MAC_ADRESS_OFFSET > 0) { - unsigned long val = (buf[4] << 16) + (buf[5] << 8) + buf[6]; - - val += CONFIG_PIGGY_MAC_ADRESS_OFFSET; - buf[4] = (val >> 16) & 0xff; - buf[5] = (val >> 8) & 0xff; - buf[6] = val & 0xff; - sprintf((char *)valbuf, "%pM", buf + 1); - } -#endif + calculate_mac_offset(buf, valbuf, CONFIG_PIGGY_MAC_ADRESS_OFFSET); #ifdef MACH_TYPE_KM_KIRKWOOD setenv((char *)"ethaddr", (char *)valbuf); #else |