Commit 6a45e384955262882375a2785426dc65aeb636c4

Authored by Dirk Behme
Committed by Wolfgang Denk
1 parent 2740544881

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.

Signed-off-by: Dirk Behme <dirk.behme@googlemail.com>
Acked-by: Ben Warren <biggerbadderben@gmail.com>

Showing 5 changed files with 58 additions and 29 deletions Side-by-side Diff

... ... @@ -617,6 +617,13 @@
617 617 int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
618 618 int stoponerr, int offset);
619 619  
  620 +/* lib_generic/net_utils.c */
  621 +#include <net.h>
  622 +static inline IPaddr_t getenv_IPaddr (char *var)
  623 +{
  624 + return (string_to_ip(getenv(var)));
  625 +}
  626 +
620 627 /* lib_generic/time.c */
621 628 void udelay (unsigned long);
622 629  
... ... @@ -508,9 +508,6 @@
508 508 /* Convert a string to a vlan id */
509 509 extern ushort string_to_VLAN(char *s);
510 510  
511   -/* read an IP address from a environment variable */
512   -extern IPaddr_t getenv_IPaddr (char *);
513   -
514 511 /* read a VLAN id from an environment variable */
515 512 extern ushort getenv_VLAN(char *);
516 513  
lib_generic/Makefile
... ... @@ -41,6 +41,7 @@
41 41 COBJS-y += lmb.o
42 42 COBJS-y += ldiv.o
43 43 COBJS-$(CONFIG_MD5) += md5.o
  44 +COBJS-y += net_utils.o
44 45 COBJS-y += sha1.o
45 46 COBJS-$(CONFIG_SHA256) += sha256.o
46 47 COBJS-y += string.o
lib_generic/net_utils.c
  1 +/*
  2 + * Generic network code. Moved from net.c
  3 + *
  4 + * Copyright 1994 - 2000 Neil Russell.
  5 + * Copyright 2000 Roland Borde
  6 + * Copyright 2000 Paolo Scaffardi
  7 + * Copyright 2000-2002 Wolfgang Denk, wd@denx.de
  8 + * Copyright 2009 Dirk Behme, dirk.behme@googlemail.com
  9 + *
  10 + * See file CREDITS for list of people who contributed to this
  11 + * project.
  12 + *
  13 + * This program is free software; you can redistribute it and/or
  14 + * modify it under the terms of the GNU General Public License as
  15 + * published by the Free Software Foundation; either version 2 of
  16 + * the License, or (at your option) any later version.
  17 + *
  18 + * This program is distributed in the hope that it will be useful,
  19 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21 + * GNU General Public License for more details.
  22 + *
  23 + * You should have received a copy of the GNU General Public License
  24 + * along with this program; if not, write to the Free Software
  25 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  26 + * MA 02111-1307 USA
  27 + */
  28 +
  29 +#include <common.h>
  30 +
  31 +IPaddr_t string_to_ip(char *s)
  32 +{
  33 + IPaddr_t addr;
  34 + char *e;
  35 + int i;
  36 +
  37 + if (s == NULL)
  38 + return(0);
  39 +
  40 + for (addr=0, i=0; i<4; ++i) {
  41 + ulong val = s ? simple_strtoul(s, &e, 10) : 0;
  42 + addr <<= 8;
  43 + addr |= (val & 0xFF);
  44 + if (s) {
  45 + s = (*e) ? e+1 : e;
  46 + }
  47 + }
  48 +
  49 + return (htonl(addr));
  50 +}
... ... @@ -1890,27 +1890,6 @@
1890 1890 );
1891 1891 }
1892 1892  
1893   -IPaddr_t string_to_ip(char *s)
1894   -{
1895   - IPaddr_t addr;
1896   - char *e;
1897   - int i;
1898   -
1899   - if (s == NULL)
1900   - return(0);
1901   -
1902   - for (addr=0, i=0; i<4; ++i) {
1903   - ulong val = s ? simple_strtoul(s, &e, 10) : 0;
1904   - addr <<= 8;
1905   - addr |= (val & 0xFF);
1906   - if (s) {
1907   - s = (*e) ? e+1 : e;
1908   - }
1909   - }
1910   -
1911   - return (htonl(addr));
1912   -}
1913   -
1914 1893 void VLAN_to_string(ushort x, char *s)
1915 1894 {
1916 1895 x = ntohs(x);
... ... @@ -1937,11 +1916,6 @@
1937 1916 id = (ushort)simple_strtoul(s, NULL, 10);
1938 1917  
1939 1918 return htons(id);
1940   -}
1941   -
1942   -IPaddr_t getenv_IPaddr (char *var)
1943   -{
1944   - return (string_to_ip(getenv(var)));
1945 1919 }
1946 1920  
1947 1921 ushort getenv_VLAN(char *var)