Skip to content

Commit

Permalink
net: move bootfile init into eth_initialize
Browse files Browse the repository at this point in the history
All arches init this the same way, so move the logic into the core
net code to avoid duplicating it everywhere else.

Signed-off-by: Mike Frysinger <[email protected]>
Reviewed-by: Joe Hershberger <[email protected]>
  • Loading branch information
vapier authored and jhershbe committed May 15, 2012
1 parent 50a47d0 commit de30122
Show file tree
Hide file tree
Showing 14 changed files with 13 additions and 78 deletions.
8 changes: 0 additions & 8 deletions arch/arm/lib/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,14 +592,6 @@ void board_init_r(gd_t *id, ulong dest_addr)

/* Initialize from environment */
load_addr = getenv_ulong("loadaddr", 16, load_addr);
#if defined(CONFIG_CMD_NET)
{
char *s = getenv("bootfile");

if (s != NULL)
copy_filename(BootFile, s, sizeof(BootFile));
}
#endif

#ifdef CONFIG_BOARD_LATE_INIT
board_late_init();
Expand Down
3 changes: 0 additions & 3 deletions arch/avr32/lib/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,6 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
bb_miiphy_init();
#endif
#if defined(CONFIG_CMD_NET)
s = getenv("bootfile");
if (s)
copy_filename(BootFile, s, sizeof(BootFile));
puts("Net: ");
eth_initialize(gd->bd);
#endif
Expand Down
7 changes: 1 addition & 6 deletions arch/blackfin/lib/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,8 @@ static void board_net_init_r(bd_t *bd)
bb_miiphy_init();
#endif
#ifdef CONFIG_CMD_NET
char *s;

if ((s = getenv("bootfile")) != NULL)
copy_filename(BootFile, s, sizeof(BootFile));

printf("Net: ");
eth_initialize(gd->bd);
eth_initialize(bd);
#endif
}

Expand Down
5 changes: 0 additions & 5 deletions arch/m68k/lib/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,11 +559,6 @@ void board_init_r (gd_t *id, ulong dest_addr)

/* Initialize from environment */
load_addr = getenv_ulong("loadaddr", 16, load_addr);
#if defined(CONFIG_CMD_NET)
if ((s = getenv ("bootfile")) != NULL) {
copy_filename (BootFile, s, sizeof (BootFile));
}
#endif

WATCHDOG_RESET ();

Expand Down
4 changes: 0 additions & 4 deletions arch/microblaze/lib/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,6 @@ void board_init (void)
uchar enetaddr[6];
eth_getenv_enetaddr("ethaddr", enetaddr);
printf("MAC: %pM\n", enetaddr);

s = getenv("bootfile");
if (s != NULL)
copy_filename(BootFile, s, sizeof(BootFile));
#endif

/* main_loop */
Expand Down
8 changes: 0 additions & 8 deletions arch/mips/lib/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,6 @@ void board_init_r(gd_t *id, ulong dest_addr)

/* Initialize from environment */
load_addr = getenv_ulong("loadaddr", 16, load_addr);
#if defined(CONFIG_CMD_NET)
{
char *s = getenv("bootfile");

if (s != NULL)
copy_filename(BootFile, s, sizeof(BootFile));
}
#endif

#ifdef CONFIG_CMD_SPI
puts("SPI: ");
Expand Down
6 changes: 0 additions & 6 deletions arch/nds32/lib/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
/* Initialize from environment */
load_addr = getenv_ulong("loadaddr", 16, load_addr);

#if defined(CONFIG_CMD_NET)
s = getenv("bootfile");
if (s != NULL)
copy_filename(BootFile, s, sizeof(BootFile));
#endif

#ifdef BOARD_LATE_INIT
board_late_init();
#endif
Expand Down
8 changes: 0 additions & 8 deletions arch/powerpc/lib/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -932,14 +932,6 @@ void board_init_r(gd_t *id, ulong dest_addr)

/* Initialize from environment */
load_addr = getenv_ulong("loadaddr", 16, load_addr);
#if defined(CONFIG_CMD_NET)
{
char *s = getenv("bootfile");

if (s != NULL)
copy_filename(BootFile, s, sizeof(BootFile));
}
#endif

WATCHDOG_RESET();

Expand Down
11 changes: 2 additions & 9 deletions arch/sh/lib/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,8 @@ void sh_generic_init(void)
bb_miiphy_init();
#endif
#if defined(CONFIG_CMD_NET)
{
char *s;
puts("Net: ");
eth_initialize(gd->bd);

s = getenv("bootfile");
if (s != NULL)
copy_filename(BootFile, s, sizeof(BootFile));
}
puts("Net: ");
eth_initialize(gd->bd);
#endif /* CONFIG_CMD_NET */

while (1) {
Expand Down
5 changes: 0 additions & 5 deletions arch/sparc/lib/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,6 @@ void board_init_f(ulong bootflag)

/* Initialize from environment */
load_addr = getenv_ulong("loadaddr", 16, load_addr);
#if defined(CONFIG_CMD_NET)
if ((s = getenv("bootfile")) != NULL) {
copy_filename(BootFile, s, sizeof(BootFile));
}
#endif /* CONFIG_CMD_NET */

WATCHDOG_RESET();

Expand Down
1 change: 0 additions & 1 deletion arch/x86/include/asm/init_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ int mem_malloc_init_r(void);
int init_bd_struct_r(void);
int flash_init_r(void);
int status_led_set_r(void);
int set_bootfile_r(void);
int set_load_addr_r(void);

#endif /* !_INIT_HELPERS_H_ */
3 changes: 0 additions & 3 deletions arch/x86/lib/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,6 @@ init_fnc_t *init_sequence_r[] = {
status_led_set_r,
#endif
set_load_addr_r,
#if defined(CONFIG_CMD_NET)
set_bootfile_r,
#endif
#if defined(CONFIG_CMD_IDE)
ide_init_r,
#endif
Expand Down
12 changes: 0 additions & 12 deletions arch/x86/lib/init_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,6 @@ int status_led_set_r(void)
}
#endif

int set_bootfile_r(void)
{
char *s;

s = getenv("bootfile");

if (s != NULL)
copy_filename(BootFile, s, sizeof(BootFile));

return 0;
}

int set_load_addr_r(void)
{
/* Initialize from environment */
Expand Down
10 changes: 10 additions & 0 deletions net/eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ int eth_unregister(struct eth_device *dev)
return 0;
}

static void eth_env_init(bd_t *bis)
{
const char *s;

if ((s = getenv("bootfile")) != NULL)
copy_filename(BootFile, s, sizeof(BootFile));
}

int eth_initialize(bd_t *bis)
{
int num_devices = 0;
Expand All @@ -260,6 +268,8 @@ int eth_initialize(bd_t *bis)
phy_init();
#endif

eth_env_init(bis);

/*
* If board-specific initialization exists, call it.
* If not, call a CPU-specific one
Expand Down

0 comments on commit de30122

Please sign in to comment.