bgmac: use phy_mii_ioctl in ioctl handler
authorHauke Mehrtens <hauke@hauke-m.de>
Fri, 20 Dec 2013 14:34:45 +0000 (15:34 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 27 Dec 2013 18:28:02 +0000 (13:28 -0500)
This works pretty much the same way, so avoid duplicating the code.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bgmac.c

index 3cd5d68a3d02875f64e8afa4dee16eeed3e6399a..39efb864267e887bcc8d062157ec90a36e9355f4 100644 (file)
@@ -1198,27 +1198,11 @@ static int bgmac_set_mac_address(struct net_device *net_dev, void *addr)
 static int bgmac_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
 {
        struct bgmac *bgmac = netdev_priv(net_dev);
-       struct mii_ioctl_data *data = if_mii(ifr);
-
-       switch (cmd) {
-       case SIOCGMIIPHY:
-               data->phy_id = bgmac->phyaddr;
-               /* fallthru */
-       case SIOCGMIIREG:
-               if (!netif_running(net_dev))
-                       return -EAGAIN;
-               data->val_out = bgmac_phy_read(bgmac, data->phy_id,
-                                              data->reg_num & 0x1f);
-               return 0;
-       case SIOCSMIIREG:
-               if (!netif_running(net_dev))
-                       return -EAGAIN;
-               bgmac_phy_write(bgmac, data->phy_id, data->reg_num & 0x1f,
-                               data->val_in);
-               return 0;
-       default:
-               return -EOPNOTSUPP;
-       }
+
+       if (!netif_running(net_dev))
+               return -EINVAL;
+
+       return phy_mii_ioctl(bgmac->phy_dev, ifr, cmd);
 }
 
 static const struct net_device_ops bgmac_netdev_ops = {