[U-Boot] net: execute "miiphy_init" if CONFIG_PHYLIB defined

Submitted by Alexey Brodkin on Jan. 10, 2014, 3:58 p.m.

Details

Message ID 1389369491-9418-1-git-send-email-abrodkin@synopsys.com
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Alexey Brodkin Jan. 10, 2014, 3:58 p.m.
In "common/Makefile" "miiphyutil.o" gets built if any of the following
items enabled:
 * CONFIG_PHYLIB
 * CONFIG_MII
 * CONFIG_CMD_MII

So it's possible to not define CONFIG_MII or CONFIG_CMD_MII and still
use functions like "miiphy_get_dev_by_name".

In its turn "miiphy_get_dev_by_name" traverses "mii_devs" list which is
not initialized because "miiphy_init" never got called.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>

Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Wolfgang Denk <wd@denx.de>
---
 net/eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Joe Hershberger Jan. 10, 2014, 8:14 p.m.
On Fri, Jan 10, 2014 at 9:58 AM, Alexey Brodkin
<Alexey.Brodkin@synopsys.com> wrote:
> In "common/Makefile" "miiphyutil.o" gets built if any of the following
> items enabled:
>  * CONFIG_PHYLIB
>  * CONFIG_MII
>  * CONFIG_CMD_MII
>
> So it's possible to not define CONFIG_MII or CONFIG_CMD_MII and still
> use functions like "miiphy_get_dev_by_name".
>
> In its turn "miiphy_get_dev_by_name" traverses "mii_devs" list which is
> not initialized because "miiphy_init" never got called.
>
> Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Wolfgang Denk <wd@denx.de>
> ---

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Tom Rini Feb. 7, 2014, 2:21 p.m.
On Fri, Jan 10, 2014 at 07:58:11PM +0400, Alexey Brodkin wrote:

> In "common/Makefile" "miiphyutil.o" gets built if any of the following
> items enabled:
>  * CONFIG_PHYLIB
>  * CONFIG_MII
>  * CONFIG_CMD_MII
> 
> So it's possible to not define CONFIG_MII or CONFIG_CMD_MII and still
> use functions like "miiphy_get_dev_by_name".
> 
> In its turn "miiphy_get_dev_by_name" traverses "mii_devs" list which is
> not initialized because "miiphy_init" never got called.
> 
> Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
> 
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Wolfgang Denk <wd@denx.de>
> Acked-by: Joe Hershberger <joe.hershberger@ni.com>

Applied to u-boot/master, thanks!

Patch hide | download patch | download mbox

diff --git a/net/eth.c b/net/eth.c
index c96e767..32bd10c 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -279,7 +279,7 @@  int eth_initialize(bd_t *bis)
 	eth_current = NULL;
 
 	bootstage_mark(BOOTSTAGE_ID_NET_ETH_START);
-#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB)
 	miiphy_init();
 #endif