net: abort network initialization if the PHY driver fails
Subsystems (2)
PATCH v3 2/2 net: abort network initialization if the PHY driver fails
Now that phy_startup() can return an actual error code, check for that error code and abort network initialization if the PHY fails.
--- drivers/net/fec_mxc.c | 8 +++++++- drivers/net/fm/eth.c | 9 ++++++++- drivers/net/sh_eth.c | 6 +++++- drivers/net/tsec.c | 8 +++++++- drivers/net/xilinx_axi_emac.c | 6 +++++- drivers/net/xilinx_ll_temac.c | 8 +++++++- 6 files changed, 39 insertions(+), 6 deletions(-)
drivers/net/fec_mxc.c +7 -1
@@ -510,7 +510,13 @@ static int fec_open(struct eth_device *edev)fec_eth_phy_config (edev);if (fec->phydev) {/* Start up the PHY */ -phy_startup (fec->phydev); +int ret =phy_startup (fec->phydev); + +if (ret) { +printf ("Could not initialize PHY %s\n" , + fec->phydev->dev->name); +return ret; + } speed = fec->phydev->speed; }else { speed = _100BASET;
drivers/net/fm/eth.c +8 -1
@@ -363,6 +363,9 @@ static int fm_eth_open(struct eth_device *dev, bd_t *bd) {struct fm_eth *fm_eth;struct fsl_enet_mac *mac; +#ifdef CONFIG_PHYLIB +int ret; +#endif fm_eth = (struct fm_eth *)dev->priv; mac = fm_eth->mac;
@@ -384,7 +387,11 @@ static int fm_eth_open(struct eth_device *dev, bd_t *bd)fmc_tx_port_graceful_stop_disable (fm_eth);#ifdef CONFIG_PHYLIB -phy_startup (fm_eth->phydev); + ret =phy_startup (fm_eth->phydev); +if (ret) { +printf ("%s: Could not initialize\n" , fm_eth->phydev->dev->name); +return ret; + }#else fm_eth->phydev->speed =SPEED_1000 ; fm_eth->phydev->link =1 ;
drivers/net/sh_eth.c +5 -1
@@ -415,7 +415,11 @@ static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd) goto err_phy_cfg; } phy = port_info->phydev; -phy_startup (phy); + ret =phy_startup (phy); +if (ret) { +printf (SHETHER_NAME ": phy startup failure\n" ); +return ret; + } val =0 ;
drivers/net/tsec.c +7 -1
@@ -480,6 +480,7 @@ static int tsec_init(struct eth_device *dev, bd_t * bd)int i;struct tsec_private *priv = (struct tsec_private *)dev->priv;tsec_t *regs = priv->regs; +int ret;/* Make sure the controller is stopped */ tsec_halt (dev);
@@ -511,7 +512,12 @@ static int tsec_init(struct eth_device *dev, bd_t * bd)startup_tsec (dev);/* Start up the PHY */ -phy_startup (priv->phydev); + ret =phy_startup (priv->phydev); +if (ret) { +printf ("Could not initialize PHY %s\n" , + priv->phydev->dev->name); +return ret; + }adjust_link (priv, priv->phydev);
drivers/net/xilinx_axi_emac.c +5 -1
@@ -272,7 +272,11 @@ static int setup_phy(struct eth_device *dev) phydev->advertising = phydev->supported; priv->phydev = phydev;phy_config (phydev); -phy_startup (phydev); +if (phy_startup (phydev)) { +printf ("axiemac: could not initialize PHY %s\n" , + phydev->dev->name); +return 0 ; + }switch (phydev->speed) {case 1000 :
drivers/net/xilinx_ll_temac.c +7 -1
@@ -232,6 +232,7 @@ static void ll_temac_halt(struct eth_device *dev)static int ll_temac_init (struct eth_device *dev,bd_t *bis) {struct ll_temac *ll_temac = dev->priv; +int ret;printf ("%s: Xilinx XPS LocalLink Tri-Mode Ether MAC #%d at 0x%08X.\n" , dev->name, dev->index, dev->iobase);
@@ -240,7 +241,12 @@ static int ll_temac_init(struct eth_device *dev, bd_t *bis)return -1 ;/* Start up the PHY */ -phy_startup (ll_temac->phydev); + ret =phy_startup (ll_temac->phydev); +if (ret) { +printf ("%s: Could not initialize PHY %s\n" , + dev->name, ll_temac->phydev->dev->name); +return ret; + }if (!ll_temac_adjust_link (dev)) {ll_temac_halt (dev);
Signature · 1 line
1.7.3.4
PATCH v3 2/2 net: abort network initialization if the PHY driver fails
Dear Timur Tabi,
drivers/net/fec_mxc.c
Quoted 19 lines
Now that
phy_startup()can return an actual error code, check for that error code and abort network initialization if the PHY fails.Signed-off-by Timur Tabi <[email protected]>part) Acked-by: Stephan Linz <[email protected]> (Xilinx part,
xilinx_axi_emacandxilinx_ll_temac) Reviewed-by: Marek Vasut <[email protected]> (FEC part)--- drivers/net/fec_mxc.c | 8 +++++++- drivers/net/fm/eth.c | 9 ++++++++- drivers/net/sh_eth.c | 6 +++++- drivers/net/tsec.c | 8 +++++++- drivers/net/xilinx_axi_emac.c | 6 +++++- drivers/net/xilinx_ll_temac.c | 8 +++++++- 6 files changed, 39 insertions(+), 6 deletions(-)drivers/net/fec_mxc.c +0
-0
A whining remark ... please keep changelog in here ;-)
[...]
Best regards,
Marek Vasut
PATCH v3 2/2 net: abort network initialization if the PHY driver fails
In reply to Timur TabiHi Timur Tabi,
Quoted 21 lines · Timur Tabi
Now that
phy_startup()can return an actual error code, check for that error code and abort network initialization if the PHY fails.Signed-off-by Timur Tabi <[email protected]>Reviewed-by Marek Vasut <[email protected]> (FEC part)--- drivers/net/fec_mxc.c | 8 +++++++- drivers/net/fm/eth.c | 9 ++++++++- drivers/net/sh_eth.c | 6 +++++- drivers/net/tsec.c | 8 +++++++- drivers/net/xilinx_axi_emac.c | 6 +++++- drivers/net/xilinx_ll_temac.c | 8 +++++++- 6 files changed, 39 insertions(+), 6 deletions(-)drivers/net/fec_mxc.c +0
-0
drivers/net/fec_mxc.c static int fec_open(struct eth_device *edev) · line 514
Quoted 6 lines
drivers/net/fec_mxc.c +2
-1@@ -510,7 +510,13 @@ static int fec_open(struct eth_device *edev)fec_eth_phy_config (edev);if (fec->phydev) {/* Start up the PHY */ -phy_startup (fec->phydev); +int ret =phy_startup (fec->phydev); +
Why a blank line here when it isn't in the rest of the implementations?
Quoted 23 lines
drivers/net/fec_mxc.c +5
-0+if (ret) { +printf ("Could not initialize PHY %s\n" , + fec->phydev->dev->name); +return ret; + } speed = fec->phydev->speed; }else { speed = _100BASET;drivers/net/fm/eth.c +3
-0@@ -363,6 +363,9 @@ static int fm_eth_open(struct eth_device *dev, bd_t *bd) {struct fm_eth *fm_eth;struct fsl_enet_mac *mac; +#ifdef CONFIG_PHYLIB +int ret; +#endif fm_eth = (struct fm_eth *)dev->priv; mac = fm_eth->mac;
drivers/net/fm/eth.c static int fm_eth_open(struct eth_device *dev, bd_t *bd) · line 392
Quoted 7 lines
drivers/net/fm/eth.c +3
-1@@ -384,7 +387,11 @@ static int fm_eth_open(struct eth_device *dev, bd_t *bd)fmc_tx_port_graceful_stop_disable (fm_eth);#ifdef CONFIG_PHYLIB -phy_startup (fm_eth->phydev); + ret =phy_startup (fm_eth->phydev); +if (ret) { +printf ("%s: Could not initialize\n" , fm_eth->phydev->dev->name);
Why is this string different from the others? Consistency?
Quoted 10 lines
drivers/net/fm/eth.c +2
-0+ return ret; + }#else fm_eth->phydev->speed =SPEED_1000 ; fm_eth->phydev->link =1 ;drivers/net/sh_eth.c +0
-0
drivers/net/sh_eth.c static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd) · line 420
Quoted 7 lines
drivers/net/sh_eth.c +3
-1@@ -415,7 +415,11 @@ static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd) goto err_phy_cfg; } phy = port_info->phydev; -phy_startup (phy); + ret =phy_startup (phy); +if (ret) { +printf (SHETHER_NAME ": phy startup failure\n" );
Why is this string different from the others? Consistency?
Quoted 36 lines
drivers/net/sh_eth.c +2
-0+return ret; + } val =0 ;drivers/net/tsec.c +7
-1@@ -480,6 +480,7 @@ static int tsec_init(struct eth_device *dev, bd_t * bd)int i;struct tsec_private *priv = (struct tsec_private *)dev->priv;tsec_t *regs = priv->regs; +int ret;/* Make sure the controller is stopped */ tsec_halt (dev);@@ -511,7 +512,12 @@ static int tsec_init(struct eth_device *dev, bd_t * bd)startup_tsec (dev);/* Start up the PHY */ -phy_startup (priv->phydev); + ret =phy_startup (priv->phydev); +if (ret) { +printf ("Could not initialize PHY %s\n" , + priv->phydev->dev->name); +return ret; + }adjust_link (priv, priv->phydev);drivers/net/xilinx_axi_emac.c +0
-0
drivers/net/xilinx_axi_emac.c static int setup_phy(struct eth_device *dev) · line 276
Quoted 6 lines
drivers/net/xilinx_axi_emac.c +2
-1@@ -272,7 +272,11 @@ static int setup_phy(struct eth_device *dev) phydev->advertising = phydev->supported; priv->phydev = phydev;phy_config (phydev); -phy_startup (phydev); +if (phy_startup (phydev)) { + printf("axiemac: could not initialize PHY %s\n",
Lower-case "could" in string? Consistency?
drivers/net/xilinx_axi_emac.c static int setup_phy(struct eth_device *dev) · line 278
Quoted 2 lines
drivers/net/xilinx_axi_emac.c +2
-0+ phydev->dev->name); +return 0 ;
Why are you returning 0 here and not the return value from phy_startup()?
Quoted 20 lines
drivers/net/xilinx_axi_emac.c +1
-0+ }switch (phydev->speed) {case 1000 :drivers/net/xilinx_ll_temac.c +1
-0@@ -232,6 +232,7 @@ static void ll_temac_halt(struct eth_device *dev)static int ll_temac_init (struct eth_device *dev,bd_t *bis) {struct ll_temac *ll_temac = dev->priv; +int ret;printf ("%s: Xilinx XPS LocalLink Tri-Mode Ether MAC #%d at 0x%08X.\n" , dev->name, dev->index, dev->iobase);@@ -240,7 +241,12 @@ static int ll_temac_init(struct eth_device *dev, bd_t *bis)return -1 ;/* Start up the PHY */
drivers/net/xilinx_ll_temac.c static int ll_temac_init(struct eth_device *dev, bd_t *bis) · line 252
Quoted 10 lines
drivers/net/xilinx_ll_temac.c +6
-1-phy_startup (ll_temac->phydev); + ret =phy_startup (ll_temac->phydev); +if (ret) { +printf ("%s: Could not initialize PHY %s\n" , + dev->name, ll_temac->phydev->dev->name); +return ret; + }if (!ll_temac_adjust_link (dev)) {ll_temac_halt (dev);
-Joe
PATCH v3 2/2 net: abort network initialization if the PHY driver fails
Quoted 5 lines · Joe Hershberger
Quoted 5 lines
drivers/net/fec_mxc.c +0
-0@@ -510,7 +510,13 @@ static int fec_open(struct eth_device *edev)
Quoted 8 lines
drivers/net/fec_mxc.c static int fec_open(struct eth_device *edev) · line 514
Quoted 6 lines
drivers/net/fec_mxc.c +2
-1fec_eth_phy_config (edev);if (fec->phydev) {/* Start up the PHY */ -phy_startup (fec->phydev); +int ret =phy_startup (fec->phydev); +Why a blank line here when it isn't in the rest of the implementations?
The coding standard requires blank lines after variable declarations.
Quoted 25 lines
Quoted 25 lines
drivers/net/fec_mxc.c +5
-0+if (ret) { +printf ("Could not initialize PHY %s\n" , + fec->phydev->dev->name); +return ret; + } speed = fec->phydev->speed; }else { speed = _100BASET;drivers/net/fm/eth.c +3
-0@@ -363,6 +363,9 @@ static int fm_eth_open(struct eth_device *dev, bd_t *bd) {struct fm_eth *fm_eth;struct fsl_enet_mac *mac; +#ifdef CONFIG_PHYLIB +int ret; +#endif fm_eth = (struct fm_eth *)dev->priv; mac = fm_eth->mac;@@ -384,7 +387,11 @@ static int fm_eth_open(struct eth_device *dev, bd_t *bd)fmc_tx_port_graceful_stop_disable (fm_eth);
Quoted 7 lines
drivers/net/fm/eth.c static int fm_eth_open(struct eth_device *dev, bd_t *bd) · line 392
Quoted 5 lines
drivers/net/fm/eth.c +3
-1#ifdef CONFIG_PHYLIB -phy_startup (fm_eth->phydev); + ret =phy_startup (fm_eth->phydev); +if (ret) { +printf ("%s: Could not initialize\n" , fm_eth->phydev->dev->name);Why is this string different from the others? Consistency?
Yes. I tried to keep the messages consistent with the other messages in the function.
Quoted 12 lines
Quoted 12 lines
drivers/net/fm/eth.c +2
-0+ return ret; + }#else fm_eth->phydev->speed =SPEED_1000 ; fm_eth->phydev->link =1 ;drivers/net/sh_eth.c +0
-0@@ -415,7 +415,11 @@ static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd) goto err_phy_cfg;
Quoted 8 lines
drivers/net/sh_eth.c static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd) · line 420
Quoted 6 lines
drivers/net/sh_eth.c +3
-1} phy = port_info->phydev; -phy_startup (phy); + ret =phy_startup (phy); +if (ret) { +printf (SHETHER_NAME ": phy startup failure\n" );Why is this string different from the others? Consistency?
Yes, it looks like the other messages in sh_eth_config().
Quoted 5 lines
Quoted 5 lines
drivers/net/xilinx_axi_emac.c +0
-0@@ -272,7 +272,11 @@ static int setup_phy(struct eth_device *dev)
Quoted 8 lines
drivers/net/xilinx_axi_emac.c static int setup_phy(struct eth_device *dev) · line 276
Quoted 6 lines
drivers/net/xilinx_axi_emac.c +2
-1phydev->advertising = phydev->supported; priv->phydev = phydev;phy_config (phydev); -phy_startup (phydev); +if (phy_startup (phydev)) { + printf("axiemac: could not initialize PHY %s\n",Lower-case "could" in string? Consistency?
Yes, consistency. :-)
Quoted 5 lines
drivers/net/xilinx_axi_emac.c static int setup_phy(struct eth_device *dev) · line 278
Quoted 3 lines
drivers/net/xilinx_axi_emac.c +2
-0+ phydev->dev->name); +return 0 ;Why are you returning 0 here and not the return value from
phy_startup()?
I answered that in another email. This is what setup_phy() is supposed to return on failure.
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
PATCH v3 2/2 net: abort network initialization if the PHY driver fails
Hi Timur Tabi,
Quoted 51 lines · Timur Tabi
Quoted 5 lines · Joe Hershberger
Quoted 5 lines
drivers/net/fec_mxc.c +0
-0@@ -510,7 +510,13 @@ static int fec_open(struct eth_device *edev)Quoted 8 lines
drivers/net/fec_mxc.c static int fec_open(struct eth_device *edev) · line 514
Quoted 6 lines
drivers/net/fec_mxc.c +2
-1fec_eth_phy_config (edev);if (fec->phydev) {/* Start up the PHY */ -phy_startup (fec->phydev); +int ret =phy_startup (fec->phydev); +Why a blank line here when it isn't in the rest of the implementations?
The coding standard requires blank lines after variable declarations.
Quoted 25 lines
Quoted 25 lines
drivers/net/fec_mxc.c +5
-0+if (ret) { +printf ("Could not initialize PHY %s\n" , + fec->phydev->dev->name); +return ret; + } speed = fec->phydev->speed; }else { speed = _100BASET;drivers/net/fm/eth.c +3
-0@@ -363,6 +363,9 @@ static int fm_eth_open(struct eth_device *dev, bd_t *bd) {struct fm_eth *fm_eth;struct fsl_enet_mac *mac; +#ifdef CONFIG_PHYLIB +int ret; +#endif fm_eth = (struct fm_eth *)dev->priv; mac = fm_eth->mac;@@ -384,7 +387,11 @@ static int fm_eth_open(struct eth_device *dev, bd_t *bd)fmc_tx_port_graceful_stop_disable (fm_eth);Quoted 7 lines
drivers/net/fm/eth.c static int fm_eth_open(struct eth_device *dev, bd_t *bd) · line 392
Quoted 5 lines
drivers/net/fm/eth.c +3
-1#ifdef CONFIG_PHYLIB -phy_startup (fm_eth->phydev); + ret =phy_startup (fm_eth->phydev); +if (ret) { +printf ("%s: Could not initialize\n" , fm_eth->phydev->dev->name);Why is this string different from the others? Consistency?
Quoted 2 lines
Yes. I tried to keep the messages consistent with the other messages in the function.
Should you not at least keep the core message the same? "Could not initialize PHY"
Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
drivers/net/fm/eth.c +2
-0+ return ret; + }#else fm_eth->phydev->speed =SPEED_1000 ; fm_eth->phydev->link =1 ;drivers/net/sh_eth.c +0
-0@@ -415,7 +415,11 @@ static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd) goto err_phy_cfg;Quoted 8 lines
drivers/net/sh_eth.c static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd) · line 420
Quoted 6 lines
drivers/net/sh_eth.c +3
-1} phy = port_info->phydev; -phy_startup (phy); + ret =phy_startup (phy); +if (ret) { +printf (SHETHER_NAME ": phy startup failure\n" );Why is this string different from the others? Consistency?
Quoted 1 line
Yes, it looks like the other messages in
sh_eth_config().
Same here, at least the core message "Could not initialize PHY"
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
drivers/net/xilinx_axi_emac.c +0
-0@@ -272,7 +272,11 @@ static int setup_phy(struct eth_device *dev)Quoted 8 lines
drivers/net/xilinx_axi_emac.c static int setup_phy(struct eth_device *dev) · line 276
Quoted 6 lines
drivers/net/xilinx_axi_emac.c +2
-1phydev->advertising = phydev->supported; priv->phydev = phydev;phy_config (phydev); -phy_startup (phydev); +if (phy_startup (phydev)) { + printf("axiemac: could not initialize PHY %s\n",Lower-case "could" in string? Consistency?
Quoted 1 line
Yes, consistency. :-)
OK... I'm not sold, but I don't care enough.
Quoted 8 lines
Quoted 5 lines
drivers/net/xilinx_axi_emac.c static int setup_phy(struct eth_device *dev) · line 278
Quoted 3 lines
drivers/net/xilinx_axi_emac.c +2
-0+ phydev->dev->name); +return 0 ;Why are you returning 0 here and not the return value from
phy_startup()?I answered that in another email. This is what
setup_phy()is supposed to return on failure.
OK.
Thanks,
-Joe
PATCH v3 2/2 net: abort network initialization if the PHY driver fails
Quoted 11 lines · Joe Hershberger
Quoted 11 lines
Quoted 10 lines
drivers/net/fm/eth.c static int fm_eth_open(struct eth_device *dev, bd_t *bd) · line 392
Quoted 8 lines
drivers/net/fm/eth.c +3
-1@@ -384,7 +387,11 @@ static int fm_eth_open(struct eth_device *dev, bd_t *bd)fmc_tx_port_graceful_stop_disable (fm_eth);#ifdef CONFIG_PHYLIB -phy_startup (fm_eth->phydev); + ret =phy_startup (fm_eth->phydev); +if (ret) { +printf ("%s: Could not initialize\n" , fm_eth->phydev->dev->name);Why is this string different from the others? Consistency?
Quoted 5 lines
Quoted 2 lines
Yes. I tried to keep the messages consistent with the other messages in the function.
Should you not at least keep the core message the same? "Could not initialize PHY"
Well, I suppose I could add the word "PHY" here.
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
drivers/net/sh_eth.c static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd) · line 420
Quoted 12 lines
drivers/net/sh_eth.c +3
-1@@ -415,7 +415,11 @@ static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd) goto err_phy_cfg; } phy = port_info->phydev; -phy_startup (phy); + ret =phy_startup (phy); +if (ret) { +printf (SHETHER_NAME ": phy startup failure\n" );Why is this string different from the others? Consistency?
Quoted 3 lines
Quoted 1 line
Yes, it looks like the other messages in
sh_eth_config().Same here, at least the core message "Could not initialize PHY"
I am saying that, just in a different way. "phy startup failure" means the same as "Could not initialize PHY", but the wording matches the rest of the function.
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
PATCH v3 2/2 net: abort network initialization if the PHY driver fails
Quoted 17 lines · Timur Tabi
Quoted 15 lines · Joe Hershberger
Quoted 15 lines
Quoted 14 lines
drivers/net/sh_eth.c static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd) · line 420
Quoted 12 lines
drivers/net/sh_eth.c +3
-1@@ -415,7 +415,11 @@ static int sh_eth_config(struct sh_eth_dev *eth, bd_t *bd) goto err_phy_cfg; } phy = port_info->phydev; -phy_startup (phy); + ret =phy_startup (phy); +if (ret) { +printf (SHETHER_NAME ": phy startup failure\n" );Why is this string different from the others? Consistency?
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Yes, it looks like the other messages in
sh_eth_config().Same here, at least the core message "Could not initialize PHY"
I am saying that, just in a different way. "phy startup failure" means the same as "Could not initialize PHY", but the wording matches the rest of the function.
OK.
-Joe