Merge remote-tracking branch 'lightnvm/for-next'
[deliverable/linux.git] / drivers / staging / octeon / ethernet-mdio.c
index e13a4ab46977cba259a8faaad0a2f22e82ceb365..1fde9c824948c6f296fb2e099e314b0ea73d7f13 100644 (file)
@@ -34,48 +34,23 @@ static void cvm_oct_get_drvinfo(struct net_device *dev,
        strlcpy(info->bus_info, "Builtin", sizeof(info->bus_info));
 }
 
-static int cvm_oct_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
-{
-       struct octeon_ethernet *priv = netdev_priv(dev);
-
-       if (priv->phydev)
-               return phy_ethtool_gset(priv->phydev, cmd);
-
-       return -EINVAL;
-}
-
-static int cvm_oct_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
-{
-       struct octeon_ethernet *priv = netdev_priv(dev);
-
-       if (!capable(CAP_NET_ADMIN))
-               return -EPERM;
-
-       if (priv->phydev)
-               return phy_ethtool_sset(priv->phydev, cmd);
-
-       return -EINVAL;
-}
-
 static int cvm_oct_nway_reset(struct net_device *dev)
 {
-       struct octeon_ethernet *priv = netdev_priv(dev);
-
        if (!capable(CAP_NET_ADMIN))
                return -EPERM;
 
-       if (priv->phydev)
-               return phy_start_aneg(priv->phydev);
+       if (dev->phydev)
+               return phy_start_aneg(dev->phydev);
 
        return -EINVAL;
 }
 
 const struct ethtool_ops cvm_oct_ethtool_ops = {
        .get_drvinfo = cvm_oct_get_drvinfo,
-       .get_settings = cvm_oct_get_settings,
-       .set_settings = cvm_oct_set_settings,
        .nway_reset = cvm_oct_nway_reset,
        .get_link = ethtool_op_get_link,
+       .get_link_ksettings = phy_ethtool_get_link_ksettings,
+       .set_link_ksettings = phy_ethtool_set_link_ksettings,
 };
 
 /**
@@ -88,15 +63,13 @@ const struct ethtool_ops cvm_oct_ethtool_ops = {
  */
 int cvm_oct_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-       struct octeon_ethernet *priv = netdev_priv(dev);
-
        if (!netif_running(dev))
                return -EINVAL;
 
-       if (!priv->phydev)
+       if (!dev->phydev)
                return -EINVAL;
 
-       return phy_mii_ioctl(priv->phydev, rq, cmd);
+       return phy_mii_ioctl(dev->phydev, rq, cmd);
 }
 
 void cvm_oct_note_carrier(struct octeon_ethernet *priv,
@@ -119,9 +92,9 @@ void cvm_oct_adjust_link(struct net_device *dev)
        cvmx_helper_link_info_t link_info;
 
        link_info.u64           = 0;
-       link_info.s.link_up     = priv->phydev->link ? 1 : 0;
-       link_info.s.full_duplex = priv->phydev->duplex ? 1 : 0;
-       link_info.s.speed       = priv->phydev->speed;
+       link_info.s.link_up     = dev->phydev->link ? 1 : 0;
+       link_info.s.full_duplex = dev->phydev->duplex ? 1 : 0;
+       link_info.s.speed       = dev->phydev->speed;
        priv->link_info         = link_info.u64;
 
        /*
@@ -130,8 +103,8 @@ void cvm_oct_adjust_link(struct net_device *dev)
        if (priv->poll)
                priv->poll(dev);
 
-       if (priv->last_link != priv->phydev->link) {
-               priv->last_link = priv->phydev->link;
+       if (priv->last_link != dev->phydev->link) {
+               priv->last_link = dev->phydev->link;
                cvmx_helper_link_set(priv->port, link_info);
                cvm_oct_note_carrier(priv, link_info);
        }
@@ -151,9 +124,8 @@ int cvm_oct_common_stop(struct net_device *dev)
 
        priv->poll = NULL;
 
-       if (priv->phydev)
-               phy_disconnect(priv->phydev);
-       priv->phydev = NULL;
+       if (dev->phydev)
+               phy_disconnect(dev->phydev);
 
        if (priv->last_link) {
                link_info.u64 = 0;
@@ -176,6 +148,7 @@ int cvm_oct_phy_setup_device(struct net_device *dev)
 {
        struct octeon_ethernet *priv = netdev_priv(dev);
        struct device_node *phy_node;
+       struct phy_device *phydev = NULL;
 
        if (!priv->of_node)
                goto no_phy;
@@ -193,14 +166,14 @@ int cvm_oct_phy_setup_device(struct net_device *dev)
        if (!phy_node)
                goto no_phy;
 
-       priv->phydev = of_phy_connect(dev, phy_node, cvm_oct_adjust_link, 0,
-                                     PHY_INTERFACE_MODE_GMII);
+       phydev = of_phy_connect(dev, phy_node, cvm_oct_adjust_link, 0,
+                               PHY_INTERFACE_MODE_GMII);
 
-       if (!priv->phydev)
+       if (!phydev)
                return -ENODEV;
 
        priv->last_link = 0;
-       phy_start_aneg(priv->phydev);
+       phy_start_aneg(phydev);
 
        return 0;
 no_phy:
This page took 0.026083 seconds and 5 git commands to generate.