From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 3/3] net: move the eth_dev status detection at driver level
Date: Fri, 14 Sep 2012 09:57:06 +0200 [thread overview]
Message-ID: <1347609426-21286-3-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1347609426-21286-1-git-send-email-plagnioj@jcrosoft.com>
as this is depend on the phy link status
If not phylib used force active
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
drivers/net/altera_tse.c | 3 ++-
drivers/net/at91_ether.c | 2 ++
drivers/net/cs8900.c | 1 +
drivers/net/designware.c | 2 ++
drivers/net/dm9k.c | 2 +-
drivers/net/ep93xx.c | 2 +-
drivers/net/fec_imx.c | 2 ++
drivers/net/fec_mpc5200.c | 2 +-
drivers/net/gianfar.c | 2 ++
drivers/net/ks8851_mll.c | 2 +-
drivers/net/macb.c | 2 ++
drivers/net/miidev.c | 10 ++++++++++
drivers/net/netx_eth.c | 2 +-
drivers/net/smc91111.c | 2 +-
drivers/net/smc911x.c | 2 +-
drivers/net/tap.c | 1 +
drivers/net/usb/usbnet.c | 3 ++-
include/miidev.h | 1 +
net/eth.c | 4 +++-
19 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
index 33ae4af..878b0ca 100644
--- a/drivers/net/altera_tse.c
+++ b/drivers/net/altera_tse.c
@@ -350,7 +350,8 @@ static int tse_eth_open(struct eth_device *edev)
struct altera_tse_priv *priv = edev->priv;
int ret;
- ret = phy_device_connect(priv->miidev, priv->phy_addr, NULL);
+ ret = phy_device_connect(priv->miidev, priv->phy_addr,
+ mii_generic_update_link);
if (ret)
return ret;
diff --git a/drivers/net/at91_ether.c b/drivers/net/at91_ether.c
index 1a83eba..c750f10 100644
--- a/drivers/net/at91_ether.c
+++ b/drivers/net/at91_ether.c
@@ -152,6 +152,8 @@ static void update_linkspeed(struct mii_device *mdev)
else {} /* 10 Half Duplex */
}
at91_emac_write(AT91_EMAC_CFG, mac_cfg);
+
+ edev->active = mdev->phydev->link;
}
static int at91_ether_open(struct eth_device *edev)
diff --git a/drivers/net/cs8900.c b/drivers/net/cs8900.c
index ef00ea6..3f7fa05 100644
--- a/drivers/net/cs8900.c
+++ b/drivers/net/cs8900.c
@@ -255,6 +255,7 @@ static int cs8900_open(struct eth_device *dev)
struct cs8900_priv *priv = (struct cs8900_priv *)dev->priv;
cs8900_reset(priv);
cs8900_reginit(priv);
+ edev->active = 1;
return 0;
}
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index fe7f23c..fcd91ef 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -243,6 +243,8 @@ static void dwc_update_linkspeed(struct mii_device *mdev)
else
conf |= MII_PORTSELECT;
writel(conf, &mac_p->conf);
+
+ edev->active = mdev->phydev->link;
}
static int dwc_ether_open(struct eth_device *dev)
diff --git a/drivers/net/dm9k.c b/drivers/net/dm9k.c
index b5446fc..0a7863f 100644
--- a/drivers/net/dm9k.c
+++ b/drivers/net/dm9k.c
@@ -473,7 +473,7 @@ static int dm9k_eth_open(struct eth_device *edev)
{
struct dm9k *priv = (struct dm9k *)edev->priv;
- return phy_device_connect(&priv->miidev, 0, NULL);
+ return phy_device_connect(&priv->miidev, 0, mii_generic_update_link);
}
static void dm9k_write_length(struct dm9k *priv, unsigned length)
diff --git a/drivers/net/ep93xx.c b/drivers/net/ep93xx.c
index 3eedef9..ed76b2b 100644
--- a/drivers/net/ep93xx.c
+++ b/drivers/net/ep93xx.c
@@ -204,7 +204,7 @@ static int ep93xx_eth_open(struct eth_device *edev)
pr_debug("+ep93xx_eth_open\n");
- ret = phy_device_connect(&priv->miidev, 0, NULL);
+ ret = phy_device_connect(&priv->miidev, 0, mii_generic_update_link);
if (ret)
return ret;
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 7a00c5e..318cdaa 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -361,6 +361,8 @@ static void fec_update_linkspeed(struct mii_device *mdev)
rcntl |= FEC_R_CNTRL_RMII_10T;
writel(rcntl, fec->regs + FEC_R_CNTRL);
}
+
+ edev->active = mdev->phydev->link;
}
/**
diff --git a/drivers/net/fec_mpc5200.c b/drivers/net/fec_mpc5200.c
index 5df793d..cbce8a4 100644
--- a/drivers/net/fec_mpc5200.c
+++ b/drivers/net/fec_mpc5200.c
@@ -412,7 +412,7 @@ static int mpc5xxx_fec_open(struct eth_device *edev)
if (fec->xcv_type != SEVENWIRE) {
return phy_device_connect(&fec->miidev, CONFIG_PHY_ADDR,
- NULL);
+ mii_generic_update_link);
}
return 0;
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 5759fd2..d0fe5d8 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -97,6 +97,8 @@ static void gfar_adjust_link(struct mii_device *mdev)
else
priv->speed = 10;
+ edev->active = mdev->phydev->link;
+
if (priv->link) {
/* clear all bits relative with interface mode */
ecntrl = in_be32(regs + GFAR_ECNTRL_OFFSET);
diff --git a/drivers/net/ks8851_mll.c b/drivers/net/ks8851_mll.c
index a05eed1..5811693 100644
--- a/drivers/net/ks8851_mll.c
+++ b/drivers/net/ks8851_mll.c
@@ -788,7 +788,7 @@ static int ks8851_eth_open(struct eth_device *edev)
ks_enable_qmu(priv);
- ret = phy_device_connect(&priv->miidev, 1, NULL);
+ ret = phy_device_connect(&priv->miidev, 1, mii_generic_update_link);
if (ret)
return ret;
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 8ab198b..fe781ab 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -232,6 +232,8 @@ static void macb_adjust_link(struct mii_device *mdev)
reg |= MACB_BIT(SPD);
writel(reg, macb->regs + MACB_NCFGR);
+
+ edev->active = mdev->phydev->link;
}
static int macb_open(struct eth_device *edev)
diff --git a/drivers/net/miidev.c b/drivers/net/miidev.c
index e5e72df..74ecb57 100644
--- a/drivers/net/miidev.c
+++ b/drivers/net/miidev.c
@@ -31,6 +31,16 @@
static LIST_HEAD(miidev_list);
+void mii_generic_update_link(struct mii_device *bus)
+{
+ struct eth_device *edev = bus->edev;
+
+ if (!bus->phydev)
+ edev->active = 1;
+ else
+ edev->active = bus->phydev->link;
+}
+
static ssize_t miidev_read(struct cdev *cdev, void *_buf, size_t count, loff_t offset, ulong flags)
{
int i = count;
diff --git a/drivers/net/netx_eth.c b/drivers/net/netx_eth.c
index 156585d..25180ae 100644
--- a/drivers/net/netx_eth.c
+++ b/drivers/net/netx_eth.c
@@ -197,7 +197,7 @@ static int netx_eth_open(struct eth_device *edev)
{
struct netx_eth_priv *priv = (struct netx_eth_priv *)edev->priv;
- return phy_device_connect(&priv->miidev, 0, NULL);
+ return phy_device_connect(&priv->miidev, 0, mii_generic_update_link);
}
static void netx_eth_halt (struct eth_device *edev)
diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
index 6fd6010..f0e5dc1 100644
--- a/drivers/net/smc91111.c
+++ b/drivers/net/smc91111.c
@@ -900,7 +900,7 @@ static int smc91c111_eth_open(struct eth_device *edev)
smc91c111_enable(edev);
- return phy_device_connect(&priv->miidev, 0, NULL);
+ return phy_device_connect(&priv->miidev, 0, mii_generic_update_link);
}
static int smc91c111_eth_send(struct eth_device *edev, void *packet,
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 20fc3b9..5df740d 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -311,7 +311,7 @@ static int smc911x_eth_open(struct eth_device *edev)
struct smc911x_priv *priv = (struct smc911x_priv *)edev->priv;
int ret;
- ret = phy_device_connect(&priv->miidev, 1, NULL);
+ ret = phy_device_connect(&priv->miidev, 1, mii_generic_update_link);
if (ret)
return ret;
diff --git a/drivers/net/tap.c b/drivers/net/tap.c
index cf23668..751a84e 100644
--- a/drivers/net/tap.c
+++ b/drivers/net/tap.c
@@ -55,6 +55,7 @@ int tap_eth_rx (struct eth_device *edev)
int tap_eth_open(struct eth_device *edev)
{
+ edev->active = 1;
return 0;
}
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 74b3386..25bfa0e 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -170,7 +170,8 @@ static int usbnet_open(struct eth_device *edev)
dev_dbg(&edev->dev, "%s\n",__func__);
- return phy_device_connect(&dev->miidev, dev->phy_addr, NULL);
+ return phy_device_connect(&dev->miidev, dev->phy_addr,
+ mii_generic_update_link);
}
static void usbnet_halt(struct eth_device *edev)
diff --git a/include/miidev.h b/include/miidev.h
index 9bea683..6ac742e 100644
--- a/include/miidev.h
+++ b/include/miidev.h
@@ -50,6 +50,7 @@ struct mii_device {
int mii_register(struct mii_device *dev);
void mii_unregister(struct mii_device *mdev);
+void mii_generic_update_link(struct mii_device *bus);
static int inline mii_write(struct mii_device *dev, int addr, int reg, int value)
{
diff --git a/net/eth.c b/net/eth.c
index c034eaa..0e3db01 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -139,9 +139,11 @@ int eth_send(void *packet, int length)
ret = eth_current->open(eth_current);
if (ret)
return ret;
- eth_current->active = 1;
}
+ if (!eth_current->active)
+ return -ENETDOWN;
+
led_trigger_network(LED_TRIGGER_NET_TX);
return eth_current->send(eth_current, packet, length);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-09-14 8:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-14 7:37 [PATCH 0/3 v3] net: check error and introduce phylib Jean-Christophe PLAGNIOL-VILLARD
2012-09-14 7:57 ` [PATCH 1/3] net: " Jean-Christophe PLAGNIOL-VILLARD
2012-09-14 7:57 ` [PATCH 2/3] net: catch error on eth_send Jean-Christophe PLAGNIOL-VILLARD
2012-09-16 9:57 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-14 7:57 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-09-16 8:12 ` [PATCH 3/3] net: move the eth_dev status detection at driver level Sascha Hauer
2012-09-15 12:24 ` [PATCH 1/3] net: introduce phylib Sascha Hauer
2012-09-16 8:11 ` Sascha Hauer
2012-09-16 8:28 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-16 8:34 ` Sascha Hauer
2012-09-16 9:02 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-16 9:13 ` Sascha Hauer
2012-09-16 9:41 ` Jean-Christophe PLAGNIOL-VILLARD
-- strict thread matches above, loose matches on Subject: below --
2012-09-09 15:44 [PATCH 1/3 v2] " Jean-Christophe PLAGNIOL-VILLARD
2012-09-09 15:44 ` [PATCH 3/3] net: move the eth_dev status detection at driver level Jean-Christophe PLAGNIOL-VILLARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1347609426-21286-3-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox