trivial: fix typos s/paramter/parameter/ and s/excute/execute/ in documentation and...
[sfrench/cifs-2.6.git] / drivers / net / mii.c
index e42aa797f08b88ca9f9b71a065e1dab90d4047cd..92056051f2691cd3fe94fa82603cc2a9849511f9 100644 (file)
 #include <linux/ethtool.h>
 #include <linux/mii.h>
 
+/**
+ * mii_ethtool_gset - get settings that are specified in @ecmd
+ * @mii: MII interface
+ * @ecmd: requested ethtool_cmd
+ *
+ * Returns 0 for success, negative on error.
+ */
 int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
 {
        struct net_device *dev = mii->dev;
@@ -83,9 +90,9 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
        if (bmcr & BMCR_ANENABLE) {
                ecmd->advertising |= ADVERTISED_Autoneg;
                ecmd->autoneg = AUTONEG_ENABLE;
-               
+
                nego = mii_nway_result(advert & lpa);
-               if ((bmcr2 & (ADVERTISE_1000HALF | ADVERTISE_1000FULL)) & 
+               if ((bmcr2 & (ADVERTISE_1000HALF | ADVERTISE_1000FULL)) &
                    (lpa2 >> 2))
                        ecmd->speed = SPEED_1000;
                else if (nego == LPA_100FULL || nego == LPA_100HALF)
@@ -103,7 +110,7 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
        } else {
                ecmd->autoneg = AUTONEG_DISABLE;
 
-               ecmd->speed = ((bmcr & BMCR_SPEED1000 && 
+               ecmd->speed = ((bmcr & BMCR_SPEED1000 &&
                                (bmcr & BMCR_SPEED100) == 0) ? SPEED_1000 :
                               (bmcr & BMCR_SPEED100) ? SPEED_100 : SPEED_10);
                ecmd->duplex = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF;
@@ -114,12 +121,19 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
        return 0;
 }
 
+/**
+ * mii_ethtool_sset - set settings that are specified in @ecmd
+ * @mii: MII interface
+ * @ecmd: requested ethtool_cmd
+ *
+ * Returns 0 for success, negative on error.
+ */
 int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
 {
        struct net_device *dev = mii->dev;
 
-       if (ecmd->speed != SPEED_10 && 
-           ecmd->speed != SPEED_100 && 
+       if (ecmd->speed != SPEED_10 &&
+           ecmd->speed != SPEED_100 &&
            ecmd->speed != SPEED_1000)
                return -EINVAL;
        if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL)
@@ -134,9 +148,9 @@ int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
                return -EINVAL;
        if ((ecmd->speed == SPEED_1000) && (!mii->supports_gmii))
                return -EINVAL;
-                                 
+
        /* ignore supported, maxtxpkt, maxrxpkt */
-       
+
        if (ecmd->autoneg == AUTONEG_ENABLE) {
                u32 bmcr, advert, tmp;
                u32 advert2 = 0, tmp2 = 0;
@@ -176,7 +190,7 @@ int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
                }
                if ((mii->supports_gmii) && (advert2 != tmp2))
                        mii->mdio_write(dev, mii->phy_id, MII_CTRL1000, tmp2);
-               
+
                /* turn on autonegotiation, and force a renegotiate */
                bmcr = mii->mdio_read(dev, mii->phy_id, MII_BMCR);
                bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
@@ -188,7 +202,7 @@ int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
 
                /* turn off auto negotiation, set speed and duplexity */
                bmcr = mii->mdio_read(dev, mii->phy_id, MII_BMCR);
-               tmp = bmcr & ~(BMCR_ANENABLE | BMCR_SPEED100 | 
+               tmp = bmcr & ~(BMCR_ANENABLE | BMCR_SPEED100 |
                               BMCR_SPEED1000 | BMCR_FULLDPLX);
                if (ecmd->speed == SPEED_1000)
                        tmp |= BMCR_SPEED1000;
@@ -207,6 +221,10 @@ int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
        return 0;
 }
 
+/**
+ * mii_check_gmii_support - check if the MII supports Gb interfaces
+ * @mii: the MII interface
+ */
 int mii_check_gmii_support(struct mii_if_info *mii)
 {
        int reg;
@@ -221,6 +239,12 @@ int mii_check_gmii_support(struct mii_if_info *mii)
        return 0;
 }
 
+/**
+ * mii_link_ok - is link status up/ok
+ * @mii: the MII interface
+ *
+ * Returns 1 if the MII reports link status up/ok, 0 otherwise.
+ */
 int mii_link_ok (struct mii_if_info *mii)
 {
        /* first, a dummy read, needed to latch some MII phys */
@@ -230,6 +254,12 @@ int mii_link_ok (struct mii_if_info *mii)
        return 0;
 }
 
+/**
+ * mii_nway_restart - restart NWay (autonegotiation) for this interface
+ * @mii: the MII interface
+ *
+ * Returns 0 on success, negative on error.
+ */
 int mii_nway_restart (struct mii_if_info *mii)
 {
        int bmcr;
@@ -247,6 +277,14 @@ int mii_nway_restart (struct mii_if_info *mii)
        return r;
 }
 
+/**
+ * mii_check_link - check MII link status
+ * @mii: MII interface
+ *
+ * If the link status changed (previous != current), call
+ * netif_carrier_on() if current link status is Up or call
+ * netif_carrier_off() if current link status is Down.
+ */
 void mii_check_link (struct mii_if_info *mii)
 {
        int cur_link = mii_link_ok(mii);
@@ -258,6 +296,15 @@ void mii_check_link (struct mii_if_info *mii)
                netif_carrier_off(mii->dev);
 }
 
+/**
+ * mii_check_media - check the MII interface for a 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
+ *
+ * Returns 1 if the duplex mode changed, 0 if not.
+ * If the media type is forced, always returns 0.
+ */
 unsigned int mii_check_media (struct mii_if_info *mii,
                              unsigned int ok_to_print,
                              unsigned int init_media)
@@ -326,6 +373,16 @@ unsigned int mii_check_media (struct mii_if_info *mii,
        return 0; /* duplex did not change */
 }
 
+/**
+ * generic_mii_ioctl - main MII ioctl interface
+ * @mii_if: the MII interface
+ * @mii_data: MII ioctl data structure
+ * @cmd: MII ioctl command
+ * @duplex_chg_out: pointer to @duplex_changed status if there was no
+ *     ioctl error
+ *
+ * Returns 0 on success, negative on error.
+ */
 int generic_mii_ioctl(struct mii_if_info *mii_if,
                      struct mii_ioctl_data *mii_data, int cmd,
                      unsigned int *duplex_chg_out)