aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <ben.hutchings@codethink.co.uk>2015-01-16 12:55:35 -0500
committerDavid S. Miller <davem@davemloft.net>2015-01-19 15:43:42 -0500
commit5bdc73800dad3ef5d06977a4b90304bd34353933 (patch)
tree18cb054bd34e363d5f60b520baca32a95c27cdb8
parent8f1115b4f2193e421ed1e56ced079153e270f16f (diff)
mii: Handle link state changes for forced modes in mii_check_media()
mii_check_media() does not update the link (carrier) state or log link changes when the link mode is forced. Drivers using the mii library must do this themselves, but most of them do not. Instead of changing them all, provide a sensible default behaviour similar to mii_check_link() when the mode is forced. via-rhine depends on it being a no-op in this case, so make its call to mii_check_media() conditional. Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/amd/pcnet32.c2
-rw-r--r--drivers/net/ethernet/via/via-rhine.c3
-rw-r--r--drivers/net/mii.c12
3 files changed, 10 insertions, 7 deletions
diff --git a/drivers/net/ethernet/amd/pcnet32.c b/drivers/net/ethernet/amd/pcnet32.c
index e2e3aaf501a2..11d6e6561df1 100644
--- a/drivers/net/ethernet/amd/pcnet32.c
+++ b/drivers/net/ethernet/amd/pcnet32.c
@@ -2806,7 +2806,7 @@ static void pcnet32_check_media(struct net_device *dev, int verbose)
2806 2806
2807/* 2807/*
2808 * Check for loss of link and link establishment. 2808 * Check for loss of link and link establishment.
2809 * Can not use mii_check_media because it does nothing if mode is forced. 2809 * Could possibly be changed to use mii_check_media instead.
2810 */ 2810 */
2811 2811
2812static void pcnet32_watchdog(struct net_device *dev) 2812static void pcnet32_watchdog(struct net_device *dev)
diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
index 0ac76102b33d..17e276651601 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c
@@ -1326,7 +1326,8 @@ static void rhine_check_media(struct net_device *dev, unsigned int init_media)
1326 struct rhine_private *rp = netdev_priv(dev); 1326 struct rhine_private *rp = netdev_priv(dev);
1327 void __iomem *ioaddr = rp->base; 1327 void __iomem *ioaddr = rp->base;
1328 1328
1329 mii_check_media(&rp->mii_if, netif_msg_link(rp), init_media); 1329 if (!rp->mii_if.force_media)
1330 mii_check_media(&rp->mii_if, netif_msg_link(rp), init_media);
1330 1331
1331 if (rp->mii_if.full_duplex) 1332 if (rp->mii_if.full_duplex)
1332 iowrite8(ioread8(ioaddr + ChipCmd1) | Cmd1FDuplex, 1333 iowrite8(ioread8(ioaddr + ChipCmd1) | Cmd1FDuplex,
diff --git a/drivers/net/mii.c b/drivers/net/mii.c
index 4a99c3919037..993570b1e2ae 100644
--- a/drivers/net/mii.c
+++ b/drivers/net/mii.c
@@ -302,7 +302,7 @@ void mii_check_link (struct mii_if_info *mii)
302} 302}
303 303
304/** 304/**
305 * mii_check_media - check the MII interface for a duplex change 305 * mii_check_media - check the MII interface for a carrier/speed/duplex change
306 * @mii: the MII interface 306 * @mii: the MII interface
307 * @ok_to_print: OK to print link up/down messages 307 * @ok_to_print: OK to print link up/down messages
308 * @init_media: OK to save duplex mode in @mii 308 * @init_media: OK to save duplex mode in @mii
@@ -318,10 +318,6 @@ unsigned int mii_check_media (struct mii_if_info *mii,
318 int advertise, lpa, media, duplex; 318 int advertise, lpa, media, duplex;
319 int lpa2 = 0; 319 int lpa2 = 0;
320 320
321 /* if forced media, go no further */
322 if (mii->force_media)
323 return 0; /* duplex did not change */
324
325 /* check current and old link status */ 321 /* check current and old link status */
326 old_carrier = netif_carrier_ok(mii->dev) ? 1 : 0; 322 old_carrier = netif_carrier_ok(mii->dev) ? 1 : 0;
327 new_carrier = (unsigned int) mii_link_ok(mii); 323 new_carrier = (unsigned int) mii_link_ok(mii);
@@ -345,6 +341,12 @@ unsigned int mii_check_media (struct mii_if_info *mii,
345 */ 341 */
346 netif_carrier_on(mii->dev); 342 netif_carrier_on(mii->dev);
347 343
344 if (mii->force_media) {
345 if (ok_to_print)
346 netdev_info(mii->dev, "link up\n");
347 return 0; /* duplex did not change */
348 }
349
348 /* get MII advertise and LPA values */ 350 /* get MII advertise and LPA values */
349 if ((!init_media) && (mii->advertising)) 351 if ((!init_media) && (mii->advertising))
350 advertise = mii->advertising; 352 advertise = mii->advertising;