Message ID | 1336671134-16342-4-git-send-email-michael@walle.cc |
---|---|
State | Superseded |
Delegated to: | Prafulla Wadaskar |
Headers | show |
Dear Michael Walle, In message <1336671134-16342-4-git-send-email-michael@walle.cc> you wrote: > Signed-off-by: Michael Walle <michael@walle.cc> How many boards will be using this code? Eventually this should be made configurable? > + sprintf(enetvar, index ? "%s%daddr" : "%saddr", base_name, index); This should generate a warning: too many arguments for format. Please fix. Best regards, Wolfgang Denk
Am Freitag 11 Mai 2012, 21:25:27 schrieb Wolfgang Denk: > Dear Michael Walle, > > In message <1336671134-16342-4-git-send-email-michael@walle.cc> you wrote: > > Signed-off-by: Michael Walle <michael@walle.cc> > > How many boards will be using this code? Hopefully more boars will use this function in the future, instead of messing around with the variable names themselves. > Eventually this should be made configurable? Given the above, i would keep it non-configurable if youre fine with that. > > > + sprintf(enetvar, index ? "%s%daddr" : "%saddr", base_name, index); > > This should generate a warning: too many arguments for format. Mh, nice catch. That was just copied from the eth_getenv_enetaddr_by_index() function. I'll fix all of them.
Dear Michael Walle, In message <201205112301.50311.michael@walle.cc> you wrote: > > > Eventually this should be made configurable? > Given the above, i would keep it non-configurable if youre fine with that. Only if the code size for the existing boards that don't need this does not grow. Best regards, Wolfgang Denk
Am Freitag 11 Mai 2012, 23:16:02 schrieb Wolfgang Denk: > Dear Michael Walle, > > In message <201205112301.50311.michael@walle.cc> you wrote: > > > Eventually this should be made configurable? > > > > Given the above, i would keep it non-configurable if youre fine with > > that. > > Only if the code size for the existing boards that don't need this > does not grow. Well i can't add a new function without increasing the filesize, can i? Using inline functions would be one option, but that would be inconsistend with the eth_getenv_enetaddr_by_index(). phew, i wonder how the eth_getenv_enetaddr_by_index() made it into uboot ;)
diff --git a/include/net.h b/include/net.h index 0da5679..eec846b 100644 --- a/include/net.h +++ b/include/net.h @@ -119,6 +119,18 @@ extern int eth_getenv_enetaddr_by_index(const char *base_name, int index, uchar *enetaddr); /* + * Set the hardware address for an ethernet interface . + * Args: + * base_name - base name for device (normally "eth") + * index - device index number (0 for first) + * enetaddr - returns 6 byte hardware address + * Returns: + * 0 on success, else 1. + */ +extern int eth_setenv_enetaddr_by_index(const char *base_name, int index, + const uchar *enetaddr); + +/* * The u-boot policy does not allow hardcoded ethernet addresses. Under the * following circumstances a random generated address is allowed: * - in emergency cases, where you need a working network connection to set diff --git a/net/eth.c b/net/eth.c index 3623825..79b81a2 100644 --- a/net/eth.c +++ b/net/eth.c @@ -62,6 +62,14 @@ int eth_getenv_enetaddr_by_index(const char *base_name, int index, return eth_getenv_enetaddr(enetvar, enetaddr); } +int eth_setenv_enetaddr_by_index(const char *base_name, int index, + const uchar *enetaddr) +{ + char enetvar[32]; + sprintf(enetvar, index ? "%s%daddr" : "%saddr", base_name, index); + return eth_setenv_enetaddr(enetvar, enetaddr); +} + static int eth_mac_skip(int index) { char enetvar[15];
Signed-off-by: Michael Walle <michael@walle.cc> --- include/net.h | 12 ++++++++++++ net/eth.c | 8 ++++++++ 2 files changed, 20 insertions(+), 0 deletions(-)