Make getenv_IPaddr() global
PATCH 1/1 Make getenv_IPaddr() global
There are boards out there that do not have network support in U-Boot (CONFIG_CMD_NET not set), but they do so in Linux. This makes it desirable to be able to port network configuration (like the IP address) to the Linux kernel.
We should not make the passing of the IP configuration to Linux dependent on U-Boot features / settings.
For this, make getenv_IPaddr() global. This fixes build error
u-boot/lib_xxx/board.c:360: undefined reference to `getenv_IPaddr'
on various architectures.
---
This makes other patches trying to fix this issue obsolete. E.g.
http://lists.denx.de/pipermail/u-boot/2009-December/065809.html
http://lists.denx.de/pipermail/u-boot/2009-December/065810.html
http://lists.denx.de/pipermail/u-boot/2009-December/065822.html
See
http://lists.denx.de/pipermail/u-boot/2009-December/065833.html
http://lists.denx.de/pipermail/u-boot/2009-December/065847.html
http://lists.denx.de/pipermail/u-boot/2009-December/065848.html
for further details.
lib_generic/Makefile | 1 lib_generic/net_utils.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ net/net.c | 26 --------------------- 3 files changed, 58 insertions(+), 26 deletions(-)
lib_generic/Makefile +1 -0
@@ -41,6 +41,7 @@ COBJS-y += gunzip.o COBJS-y += lmb.o COBJS-y += ldiv.o COBJS-$(CONFIG_MD5) += md5.o +COBJS-y += net_utils.o COBJS-y += sha1.o COBJS-$(CONFIG_SHA256) += sha256.o COBJS-y += string.o
lib_generic/net_utils.c new file +57 -0
57 lines not on this page · raw message
net/net.c +0 -26
@@ -1890,27 +1890,6 @@ void ip_to_string (IPaddr_t x, char *s) ); } -IPaddr_t string_to_ip (char *s) -{ -IPaddr_t addr; -char *e; -int i; - -if (s ==NULL ) -return (0 ); - -for (addr=0 , i=0 ; i<4 ; ++i) { -ulong val = s ?simple_strtoul (s, &e,10 ) :0 ; - addr <<=8 ; - addr |= (val &0xFF ); -if (s) { - s = (*e) ? e+1 : e; - } - } - -return (htonl (addr)); -} -void VLAN_to_string (ushort x,char *s) { x =ntohs (x);
@@ -1939,11 +1918,6 @@ ushort string_to_VLAN(char *s)return htons (id); } -IPaddr_t getenv_IPaddr (char *var) -{ -return (string_to_ip (getenv (var))); -} -ushort getenv_VLAN (char *var) {return (string_to_VLAN (getenv (var)));
PATCH 1/1 Make getenv_IPaddr() global
Hi Dirk,
lib_generic/net_utils.c
Quoted 55 lines · Dirk Behme
There are boards out there that do not have network support in U-Boot (
CONFIG_CMD_NETnot set), but they do so in Linux. This makes it desirable to be able to port network configuration (like the IP address) to the Linux kernel.We should not make the passing of the IP configuration to Linux dependent on U-Boot features / settings.
For this, make
getenv_IPaddr()global. This fixes build error
u-boot/lib_xxx/board.c:360: undefined reference to `getenv_IPaddr'on various architectures.
Signed-off-by Dirk Behme <[email protected]>---
This makes other patches trying to fix this issue obsolete. E.g.
http://lists.denx.de/pipermail/u-boot/2009-December/065809.html
http://lists.denx.de/pipermail/u-boot/2009-December/065810.html
http://lists.denx.de/pipermail/u-boot/2009-December/065822.htmlSee
http://lists.denx.de/pipermail/u-boot/2009-December/065833.html
http://lists.denx.de/pipermail/u-boot/2009-December/065847.html
http://lists.denx.de/pipermail/u-boot/2009-December/065848.htmlfor further details.
lib_generic/Makefile | 1 lib_generic/net_utils.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ net/net.c | 26 --------------------- 3 files changed, 58 insertions(+), 26 deletions(-)Index: u-boot-main/lib_generic/Makefile
===================================================================lib_generic/Makefile +1
-0@@ -41,6 +41,7 @@ COBJS-y += gunzip.o COBJS-y += lmb.o COBJS-y += ldiv.o COBJS-$(CONFIG_MD5) += md5.o +COBJS-y += net_utils.o COBJS-y += sha1.o COBJS-$(CONFIG_SHA256) += sha256.o COBJS-y += string.oIndex:
u-boot-main/lib_generic/net_utils.c
===================================================================lib_generic/net_utils.c new file +0
-0
I agree that this function should be generic, but it's more of an environment function than a networking one. Why not put this somewhere like common/env_common.c or create a new file called common/env_net.c?
regards,
Ben
PATCH 1/1 Make getenv_IPaddr() global
Quoted 55 lines · Ben Warren
Hi Dirk,
Quoted 51 lines · Dirk Behme
There are boards out there that do not have network support in U-Boot (
CONFIG_CMD_NETnot set), but they do so in Linux. This makes it desirable to be able to port network configuration (like the IP address) to the Linux kernel.We should not make the passing of the IP configuration to Linux dependent on U-Boot features / settings.
For this, make
getenv_IPaddr()global. This fixes build error
u-boot/lib_xxx/board.c:360: undefined reference to `getenv_IPaddr'on various architectures.
Signed-off-by Dirk Behme<[email protected]>---
This makes other patches trying to fix this issue obsolete. E.g.
http://lists.denx.de/pipermail/u-boot/2009-December/065809.html
http://lists.denx.de/pipermail/u-boot/2009-December/065810.html
http://lists.denx.de/pipermail/u-boot/2009-December/065822.htmlSee
http://lists.denx.de/pipermail/u-boot/2009-December/065833.html
http://lists.denx.de/pipermail/u-boot/2009-December/065847.html
http://lists.denx.de/pipermail/u-boot/2009-December/065848.htmlfor further details.
lib_generic/Makefile | 1 lib_generic/net_utils.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ net/net.c | 26 --------------------- 3 files changed, 58 insertions(+), 26 deletions(-)Index: u-boot-main/lib_generic/Makefile
===================================================================lib_generic/Makefile +1
-0@@ -41,6 +41,7 @@ COBJS-y += gunzip.o COBJS-y += lmb.o COBJS-y += ldiv.o COBJS-$(CONFIG_MD5) += md5.o +COBJS-y += net_utils.o COBJS-y += sha1.o COBJS-$(CONFIG_SHA256) += sha256.o COBJS-y += string.oIndex:
u-boot-main/lib_generic/net_utils.c
Quoted 8 lines
lib_generic/net_utils.c
Quoted 4 lines
===================================================================
lib_generic/net_utils.c new file +0
-0I agree that this function should be generic, but it's more of an environment function than a networking one. Why not put this somewhere like
common/env_common.cor create a new file calledcommon/env_net.c?
Because Wolfgang proposed lib_generic/net_utils.c
http://lists.denx.de/pipermail/u-boot/2009-December/065848.html
I don't care where to put it, please discuss this with Wolfgang ;)
Best regards
Dirk
PATCH 1/1 Make getenv_IPaddr() global
In reply to Ben WarrenDear Ben,
Quoted 7 lines · In message <[email protected]> you…
Quoted 7 lines
We should not make the passing of the IP configuration to Linux dependent on U-Boot features / settings.
For this, make
getenv_IPaddr()global. This fixes build error
u-boot/lib_xxx/board.c:360: undefined reference to `getenv_IPaddr'
...
Quoted 3 lines
I agree that this function should be generic, but it's more of an environment function than a networking one. Why not put this somewhere like
common/env_common.cor create a new file calledcommon/env_net.c?
After re-thinking what I wrote before, I still think that lib_generic/ is the right place. The code defines two functions:
IPaddr_t string_to_ip(char *s)
and
IPaddr_t getenv_IPaddr (char *var)
The former does all the actual work and has nothing to do with environment things, and the latter should eventually be moved as a "static inline" to some header file.
I'm not sure how to interpret your comment - was it just a question, or was it intended to be a NAK ?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de An expert is a person who avoids the small errors while sweeping on to the grand fallacy.
PATCH 1/1 Make getenv_IPaddr() global
Hi Wolfgang and Happy New Year to all,
Quoted 25 lines · Wolfgang Denk
Dear Ben,
In message <[email protected]>
Quoted 7 lines · you
Quoted 7 lines
We should not make the passing of the IP configuration to Linux dependent on U-Boot features / settings.
For this, make
getenv_IPaddr()global. This fixes build error
u-boot/lib_xxx/board.c:360: undefined reference to `getenv_IPaddr'...
Quoted 2 lines
I agree that this function should be generic, but it's more of an environment function than a networking one. Why not put this somewhere
like
Quoted 1 line
common/env_common.cor create a new file calledcommon/env_net.c?After re-thinking what I wrote before, I still think that lib_generic/ is the right place. The code defines two functions:
IPaddr_tstring_to_ip(char *s)
and
IPaddr_tgetenv_IPaddr(char *var)
Quoted 8 lines
The former does all the actual work and has nothing to do with environment things, and the latter should eventually be moved as a "static inline" to some header file.
I'm not sure how to interpret your comment - was it just a question, or was it intended to be a NAK ?
Not a firm NAK, I'm just not a fan of creating a new file for a single
function. The important thing is that the code gets linked in to everything, and both solutions fit that requirement.
Quoted 5 lines
Best regards,
Wolfgang Denk
regards,
Ben