drivers/net: Move && and || to end of previous line
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / net / ibm_newemac / core.c
index f0f890803710bed42418201bf2bb4fa58f25cb99..fb5e019169eef75baa4a0679deab781b34fc4dee 100644 (file)
@@ -24,6 +24,7 @@
  *
  */
 
+#include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/string.h>
 #include <linux/errno.h>
@@ -443,7 +444,7 @@ static u32 __emac_calc_base_mr1(struct emac_instance *dev, int tx_size, int rx_s
                ret |= EMAC_MR1_TFS_2K;
                break;
        default:
-               printk(KERN_WARNING "%s: Unknown Rx FIFO size %d\n",
+               printk(KERN_WARNING "%s: Unknown Tx FIFO size %d\n",
                       dev->ndev->name, tx_size);
        }
 
@@ -470,6 +471,9 @@ static u32 __emac4_calc_base_mr1(struct emac_instance *dev, int tx_size, int rx_
        DBG2(dev, "__emac4_calc_base_mr1" NL);
 
        switch(tx_size) {
+       case 16384:
+               ret |= EMAC4_MR1_TFS_16K;
+               break;
        case 4096:
                ret |= EMAC4_MR1_TFS_4K;
                break;
@@ -477,7 +481,7 @@ static u32 __emac4_calc_base_mr1(struct emac_instance *dev, int tx_size, int rx_
                ret |= EMAC4_MR1_TFS_2K;
                break;
        default:
-               printk(KERN_WARNING "%s: Unknown Rx FIFO size %d\n",
+               printk(KERN_WARNING "%s: Unknown Tx FIFO size %d\n",
                       dev->ndev->name, tx_size);
        }
 
@@ -1344,7 +1348,7 @@ static inline int emac_xmit_finish(struct emac_instance *dev, int len)
        ++dev->stats.tx_packets;
        dev->stats.tx_bytes += len;
 
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 /* Tx lock BH */
@@ -1972,27 +1976,27 @@ static int emac_ethtool_set_settings(struct net_device *ndev,
        if (cmd->autoneg == AUTONEG_DISABLE) {
                switch (cmd->speed) {
                case SPEED_10:
-                       if (cmd->duplex == DUPLEX_HALF
-                           && !(f & SUPPORTED_10baseT_Half))
+                       if (cmd->duplex == DUPLEX_HALF &&
+                           !(f & SUPPORTED_10baseT_Half))
                                return -EINVAL;
-                       if (cmd->duplex == DUPLEX_FULL
-                           && !(f & SUPPORTED_10baseT_Full))
+                       if (cmd->duplex == DUPLEX_FULL &&
+                           !(f & SUPPORTED_10baseT_Full))
                                return -EINVAL;
                        break;
                case SPEED_100:
-                       if (cmd->duplex == DUPLEX_HALF
-                           && !(f & SUPPORTED_100baseT_Half))
+                       if (cmd->duplex == DUPLEX_HALF &&
+                           !(f & SUPPORTED_100baseT_Half))
                                return -EINVAL;
-                       if (cmd->duplex == DUPLEX_FULL
-                           && !(f & SUPPORTED_100baseT_Full))
+                       if (cmd->duplex == DUPLEX_FULL &&
+                           !(f & SUPPORTED_100baseT_Full))
                                return -EINVAL;
                        break;
                case SPEED_1000:
-                       if (cmd->duplex == DUPLEX_HALF
-                           && !(f & SUPPORTED_1000baseT_Half))
+                       if (cmd->duplex == DUPLEX_HALF &&
+                           !(f & SUPPORTED_1000baseT_Half))
                                return -EINVAL;
-                       if (cmd->duplex == DUPLEX_FULL
-                           && !(f & SUPPORTED_1000baseT_Full))
+                       if (cmd->duplex == DUPLEX_FULL &&
+                           !(f & SUPPORTED_1000baseT_Full))
                                return -EINVAL;
                        break;
                default:
@@ -2145,9 +2149,12 @@ static int emac_ethtool_nway_reset(struct net_device *ndev)
        return res;
 }
 
-static int emac_ethtool_get_stats_count(struct net_device *ndev)
+static int emac_ethtool_get_sset_count(struct net_device *ndev, int stringset)
 {
-       return EMAC_ETHTOOL_STATS_COUNT;
+       if (stringset == ETH_SS_STATS)
+               return EMAC_ETHTOOL_STATS_COUNT;
+       else
+               return -EINVAL;
 }
 
 static void emac_ethtool_get_strings(struct net_device *ndev, u32 stringset,
@@ -2178,7 +2185,6 @@ static void emac_ethtool_get_drvinfo(struct net_device *ndev,
        info->fw_version[0] = '\0';
        sprintf(info->bus_info, "PPC 4xx EMAC-%d %s",
                dev->cell_index, dev->ofdev->node->full_name);
-       info->n_stats = emac_ethtool_get_stats_count(ndev);
        info->regdump_len = emac_ethtool_get_regs_len(ndev);
 }
 
@@ -2198,7 +2204,7 @@ static const struct ethtool_ops emac_ethtool_ops = {
        .get_rx_csum = emac_ethtool_get_rx_csum,
 
        .get_strings = emac_ethtool_get_strings,
-       .get_stats_count = emac_ethtool_get_stats_count,
+       .get_sset_count = emac_ethtool_get_sset_count,
        .get_ethtool_stats = emac_ethtool_get_ethtool_stats,
 
        .get_link = ethtool_op_get_link,
@@ -2209,7 +2215,7 @@ static const struct ethtool_ops emac_ethtool_ops = {
 static int emac_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
 {
        struct emac_instance *dev = netdev_priv(ndev);
-       uint16_t *data = (uint16_t *) & rq->ifr_ifru;
+       struct mii_ioctl_data *data = if_mii(rq);
 
        DBG(dev, "ioctl %08x" NL, cmd);
 
@@ -2218,19 +2224,16 @@ static int emac_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
 
        switch (cmd) {
        case SIOCGMIIPHY:
-       case SIOCDEVPRIVATE:
-               data[0] = dev->phy.address;
+               data->phy_id = dev->phy.address;
                /* Fall through */
        case SIOCGMIIREG:
-       case SIOCDEVPRIVATE + 1:
-               data[3] = emac_mdio_read(ndev, dev->phy.address, data[1]);
+               data->val_out = emac_mdio_read(ndev, dev->phy.address,
+                                              data->reg_num);
                return 0;
 
        case SIOCSMIIREG:
-       case SIOCDEVPRIVATE + 2:
-               if (!capable(CAP_NET_ADMIN))
-                       return -EPERM;
-               emac_mdio_write(ndev, dev->phy.address, data[1], data[2]);
+               emac_mdio_write(ndev, dev->phy.address, data->reg_num,
+                               data->val_in);
                return 0;
        default:
                return -EOPNOTSUPP;
@@ -2559,13 +2562,13 @@ static int __devinit emac_init_config(struct emac_instance *dev)
        if (emac_read_uint_prop(np, "mdio-device", &dev->mdio_ph, 0))
                dev->mdio_ph = 0;
        if (emac_read_uint_prop(np, "zmii-device", &dev->zmii_ph, 0))
-               dev->zmii_ph = 0;;
+               dev->zmii_ph = 0;
        if (emac_read_uint_prop(np, "zmii-channel", &dev->zmii_port, 0))
-               dev->zmii_port = 0xffffffff;;
+               dev->zmii_port = 0xffffffff;
        if (emac_read_uint_prop(np, "rgmii-device", &dev->rgmii_ph, 0))
-               dev->rgmii_ph = 0;;
+               dev->rgmii_ph = 0;
        if (emac_read_uint_prop(np, "rgmii-channel", &dev->rgmii_port, 0))
-               dev->rgmii_port = 0xffffffff;;
+               dev->rgmii_port = 0xffffffff;
        if (emac_read_uint_prop(np, "fifo-entry-size", &dev->fifo_entry_size, 0))
                dev->fifo_entry_size = 16;
        if (emac_read_uint_prop(np, "mal-burst-size", &dev->mal_burst_size, 0))
@@ -2988,6 +2991,7 @@ static struct of_device_id emac_match[] =
        },
        {},
 };
+MODULE_DEVICE_TABLE(of, emac_match);
 
 static struct of_platform_driver emac_driver = {
        .name = "emac",