dm: eth: Test 'ethrotate' before changing current ethernet device
PATCH 1/2 dm: eth: Test 'ethrotate' before changing current ethernet device
In eth_current_changed(), the call to eth_get_dev() below has a side effect of rotating ethernet device if uc_priv->current == NULL. This is not what we want when 'ethrotate' variable is 'no'.
---
net/eth.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
net/eth.c +11 -0
@@ -1039,6 +1039,17 @@ int eth_receive(void *packet, int length)static void eth_current_changed (void ) {char *act =getenv ("ethact" ); +char *ethrotate; + +/* +* The call to eth_get_dev() below has a side effect of rotating +* ethernet device if uc_priv->current == NULL. This is not what +* we want when 'ethrotate' variable is 'no'. +*/ + ethrotate =getenv ("ethrotate" ); +if ((ethrotate !=NULL ) && (strcmp (ethrotate,"no" ) ==0 )) +return ; +/* update current ethernet name */ if (eth_get_dev ()) {if (act ==NULL ||strcmp (act,eth_get_name ()) !=0 )
Signature · 1 line
1.8.2.1
PATCH 2/2 dm: eth: Stick to 'ethact' when 'ethrotate' is 'no' in eth_init()
When 'ethrotate' variable is set to 'no' and 'ethact' variable is already set to an ethernet device, we should stick to 'ethact'.
---
net/eth.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
net/eth.c +20 -4
@@ -337,14 +337,30 @@ U_BOOT_ENV_CALLBACK(ethaddr, on_ethaddr);int eth_init (void ) { -struct udevice *current; +char *ethact =getenv ("ethact" ); +char *ethrotate =getenv ("ethrotate" ); +struct udevice *current =NULL ;struct udevice *old_current;int ret = -ENODEV ; - current =eth_get_dev (); +/* +* When 'ethrotate' variable is set to 'no' and 'ethact' variable +* is already set to an ethernet device, we should stick to 'ethact'. +*/ +if ((ethrotate !=NULL ) && (strcmp (ethrotate,"no" ) ==0 )) { +if (ethact) { + current =eth_get_dev_by_name (ethact); +if (!current) +return -EINVAL ; + } + } +if (!current) { -printf ("No ethernet found.\n" ); -return -ENODEV ; + current =eth_get_dev (); +if (!current) { +printf ("No ethernet found.\n" ); +return -ENODEV ; + } } old_current = current;
Signature · 1 line
1.8.2.1
PATCH 2/2 dm: eth: Stick to 'ethact' when 'ethrotate' is 'no' in eth_init()
Quoted 4 lines · Bin Meng
When 'ethrotate' variable is set to 'no' and 'ethact' variable is already set to an ethernet device, we should stick to 'ethact'.
Signed-off-by Bin Meng <[email protected]>
PATCH 2/2 dm: eth: Stick to 'ethact' when 'ethrotate' is 'no' in eth_init()
Quoted 7 lines · Joe Hershberger
Quoted 4 lines · Bin Meng
When 'ethrotate' variable is set to 'no' and 'ethact' variable is already set to an ethernet device, we should stick to 'ethact'.
Signed-off-by Bin Meng <[email protected]>Acked-by Joe Hershberger <[email protected]>
Tested on sandbox:
PATCH 2/2 dm: eth: Stick to 'ethact' when 'ethrotate' is 'no' in eth_init()
Quoted 5 lines · Simon Glass
Quoted 4 lines · Joe Hershberger
Quoted 3 lines · Bin Meng
When 'ethrotate' variable is set to 'no' and 'ethact' variable is already set to an ethernet device, we should stick to 'ethact'.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Bin Meng <[email protected]>Acked-by Joe Hershberger <[email protected]>Acked-by Simon Glass <[email protected]>Tested on sandbox:
Tested-by Simon Glass <[email protected]>
Applied to u-boot-dm/master, thanks!
PATCH 1/2 dm: eth: Test 'ethrotate' before changing current ethernet device
In reply to Bin MengQuoted 5 lines · Bin Meng
In
eth_current_changed(), the call toeth_get_dev()below has a side effect of rotating ethernet device ifuc_priv->current== NULL. This is not what we want when 'ethrotate' variable is 'no'.Signed-off-by Bin Meng <[email protected]>
PATCH 1/2 dm: eth: Test 'ethrotate' before changing current ethernet device
Quoted 8 lines · Joe Hershberger
Quoted 5 lines · Bin Meng
In
eth_current_changed(), the call toeth_get_dev()below has a side effect of rotating ethernet device ifuc_priv->current== NULL. This is not what we want when 'ethrotate' variable is 'no'.Signed-off-by Bin Meng <[email protected]>Acked-by Joe Hershberger <[email protected]>
Tested on sandbox:
PATCH 1/2 dm: eth: Test 'ethrotate' before changing current ethernet device
Quoted 6 lines · Simon Glass
Quoted 5 lines · Joe Hershberger
Quoted 4 lines · Bin Meng
In
eth_current_changed(), the call toeth_get_dev()below has a side effect of rotating ethernet device ifuc_priv->current== NULL. This is not what we want when 'ethrotate' variable is 'no'.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Bin Meng <[email protected]>Acked-by Joe Hershberger <[email protected]>Acked-by Simon Glass <[email protected]>Tested on sandbox:
Tested-by Simon Glass <[email protected]>
Applied to u-boot-dm/master, thanks!