[U-Boot] [PATCH v5 09/27] net: Remove the bd* parameter from net stack functions

Joe Hershberger joe.hershberger at ni.com
Wed Mar 4 03:41:03 CET 2015


This value is not used by the network stack and is available in the
global data, so stop passing it around.  For the one legacy function
that still expects it (init op on old Ethernet drivers) pass in the
global pointer version directly to avoid changing that interface.

Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
Reported-by: Simon Glass <sjg at chromium.org>
Reviewed-by: Simon Glass <sjg at chromium.org>

---

Changes in v5: None
Changes in v4:
-New to v4

Changes in v3: None
Changes in v2: None

 common/board_r.c         |  2 +-
 drivers/net/netconsole.c |  4 ++--
 include/net.h            |  6 +++---
 net/eth.c                | 12 +++++++-----
 net/net.c                |  7 +++----
 5 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/common/board_r.c b/common/board_r.c
index af0f274..b882d9b 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -585,7 +585,7 @@ static int initr_bbmii(void)
 static int initr_net(void)
 {
 	puts("Net:   ");
-	eth_initialize(gd->bd);
+	eth_initialize();
 #if defined(CONFIG_RESET_PHY_R)
 	debug("Reset Ethernet PHY\n");
 	reset_phy();
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 677c89f..87cea7a 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -193,11 +193,11 @@ static void nc_send_packet(const char *buf, int len)
 
 	if (eth->state != ETH_STATE_ACTIVE) {
 		if (eth_is_on_demand_init()) {
-			if (eth_init(gd->bd) < 0)
+			if (eth_init() < 0)
 				return;
 			eth_set_last_protocol(NETCONS);
 		} else
-			eth_init_state_only(gd->bd);
+			eth_init_state_only();
 
 		inited = 1;
 	}
diff --git a/include/net.h b/include/net.h
index ad20145..10d38f8 100644
--- a/include/net.h
+++ b/include/net.h
@@ -119,7 +119,7 @@ static inline unsigned char *eth_get_ethaddr(void)
 }
 
 /* Set active state */
-static inline __attribute__((always_inline)) int eth_init_state_only(bd_t *bis)
+static inline __attribute__((always_inline)) int eth_init_state_only(void)
 {
 	eth_get_dev()->state = ETH_STATE_ACTIVE;
 
@@ -145,7 +145,7 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
 
 int usb_eth_initialize(bd_t *bi);
 
-int eth_initialize(bd_t *bis);	/* Initialize network subsystem */
+int eth_initialize(void);		/* Initialize network subsystem */
 void eth_try_another(int first_restart);	/* Change the device */
 void eth_set_current(void);		/* set nterface to ethcur var */
 
@@ -166,7 +166,7 @@ int eth_setenv_enetaddr(char *name, const uchar *enetaddr);
 int eth_getenv_enetaddr_by_index(const char *base_name, int index,
 				 uchar *enetaddr);
 
-int eth_init(bd_t *bis);			/* Initialize the device */
+int eth_init(void);			/* Initialize the device */
 int eth_send(void *packet, int length);	   /* Send a packet */
 
 #ifdef CONFIG_API
diff --git a/net/eth.c b/net/eth.c
index b86994e..66ecb79 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -12,6 +12,8 @@
 #include <phy.h>
 #include <asm/errno.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 void eth_parse_enetaddr(const char *addr, uchar *enetaddr)
 {
 	char *end;
@@ -250,7 +252,7 @@ int eth_unregister(struct eth_device *dev)
 	return 0;
 }
 
-int eth_initialize(bd_t *bis)
+int eth_initialize(void)
 {
 	int num_devices = 0;
 	eth_devices = NULL;
@@ -272,10 +274,10 @@ int eth_initialize(bd_t *bis)
 	 * If not, call a CPU-specific one
 	 */
 	if (board_eth_init != __def_eth_init) {
-		if (board_eth_init(bis) < 0)
+		if (board_eth_init(gd->bd) < 0)
 			printf("Board Net Initialization Failed\n");
 	} else if (cpu_eth_init != __def_eth_init) {
-		if (cpu_eth_init(bis) < 0)
+		if (cpu_eth_init(gd->bd) < 0)
 			printf("CPU Net Initialization Failed\n");
 	} else
 		printf("Net Initialization Skipped\n");
@@ -362,7 +364,7 @@ u32 ether_crc(size_t len, unsigned char const *p)
 #endif
 
 
-int eth_init(bd_t *bis)
+int eth_init(void)
 {
 	struct eth_device *old_current, *dev;
 
@@ -387,7 +389,7 @@ int eth_init(bd_t *bis)
 	do {
 		debug("Trying %s\n", eth_current->name);
 
-		if (eth_current->init(eth_current, bis) >= 0) {
+		if (eth_current->init(eth_current, gd->bd) >= 0) {
 			eth_current->state = ETH_STATE_ACTIVE;
 
 			return 0;
diff --git a/net/net.c b/net/net.c
index 4b3c90e..e5ab07c 100644
--- a/net/net.c
+++ b/net/net.c
@@ -324,7 +324,6 @@ void net_init(void)
 
 int NetLoop(enum proto_t protocol)
 {
-	bd_t *bd = gd->bd;
 	int ret = -1;
 
 	NetRestarted = 0;
@@ -337,12 +336,12 @@ int NetLoop(enum proto_t protocol)
 	if (eth_is_on_demand_init() || protocol != NETCONS) {
 		eth_halt();
 		eth_set_current();
-		if (eth_init(bd) < 0) {
+		if (eth_init() < 0) {
 			eth_halt();
 			return -1;
 		}
 	} else
-		eth_init_state_only(bd);
+		eth_init_state_only();
 
 restart:
 #ifdef CONFIG_USB_KEYBOARD
@@ -618,7 +617,7 @@ void NetStartAgain(void)
 #if !defined(CONFIG_NET_DO_NOT_TRY_ANOTHER)
 	eth_try_another(!NetRestarted);
 #endif
-	eth_init(gd->bd);
+	eth_init();
 	if (NetRestartWrap) {
 		NetRestartWrap = 0;
 		if (NetDevExists) {
-- 
1.7.11.5



More information about the U-Boot mailing list