]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mii: Handle link state changes for forced modes in mii_check_media()
authorBen Hutchings <ben.hutchings@codethink.co.uk>
Fri, 16 Jan 2015 17:55:35 +0000 (17:55 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 19 Jan 2015 20:43:42 +0000 (15:43 -0500)
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>
drivers/net/ethernet/amd/pcnet32.c
drivers/net/ethernet/via/via-rhine.c
drivers/net/mii.c

index e2e3aaf501a20f7b9e8a7838b9b410ec89017c4d..11d6e6561df159c3dc9dff28fc504e945a77f47b 100644 (file)
@@ -2806,7 +2806,7 @@ static void pcnet32_check_media(struct net_device *dev, int verbose)
 
 /*
  * Check for loss of link and link establishment.
- * Can not use mii_check_media because it does nothing if mode is forced.
+ * Could possibly be changed to use mii_check_media instead.
  */
 
 static void pcnet32_watchdog(struct net_device *dev)
index 0ac76102b33dca861b67344ba1fbf320d2aa1f88..17e276651601b27c393001cdd5593cddcd828788 100644 (file)
@@ -1326,7 +1326,8 @@ static void rhine_check_media(struct net_device *dev, unsigned int init_media)
        struct rhine_private *rp = netdev_priv(dev);
        void __iomem *ioaddr = rp->base;
 
-       mii_check_media(&rp->mii_if, netif_msg_link(rp), init_media);
+       if (!rp->mii_if.force_media)
+               mii_check_media(&rp->mii_if, netif_msg_link(rp), init_media);
 
        if (rp->mii_if.full_duplex)
            iowrite8(ioread8(ioaddr + ChipCmd1) | Cmd1FDuplex,
index 4a99c391903790af8ce6b727918455d90415842b..993570b1e2aeb68726c268eea5a8332a2b8159f6 100644 (file)
@@ -302,7 +302,7 @@ void mii_check_link (struct mii_if_info *mii)
 }
 
 /**
- * mii_check_media - check the MII interface for a duplex change
+ * mii_check_media - check the MII interface for a carrier/speed/duplex change
  * @mii: the MII interface
  * @ok_to_print: OK to print link up/down messages
  * @init_media: OK to save duplex mode in @mii
@@ -318,10 +318,6 @@ unsigned int mii_check_media (struct mii_if_info *mii,
        int advertise, lpa, media, duplex;
        int lpa2 = 0;
 
-       /* if forced media, go no further */
-       if (mii->force_media)
-               return 0; /* duplex did not change */
-
        /* check current and old link status */
        old_carrier = netif_carrier_ok(mii->dev) ? 1 : 0;
        new_carrier = (unsigned int) mii_link_ok(mii);
@@ -345,6 +341,12 @@ unsigned int mii_check_media (struct mii_if_info *mii,
         */
        netif_carrier_on(mii->dev);
 
+       if (mii->force_media) {
+               if (ok_to_print)
+                       netdev_info(mii->dev, "link up\n");
+               return 0; /* duplex did not change */
+       }
+
        /* get MII advertise and LPA values */
        if ((!init_media) && (mii->advertising))
                advertise = mii->advertising;