]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
netdev: Convert MDIO ioctl implementation to use struct mii_ioctl_data
authorBen Hutchings <bhutchings@solarflare.com>
Thu, 3 Sep 2009 10:41:17 +0000 (10:41 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 4 Sep 2009 03:02:12 +0000 (20:02 -0700)
A few drivers still access the arguments to MDIO ioctls as an array of
u16.  Convert them to use struct mii_ioctl_data.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ibm_newemac/core.c
drivers/net/pcmcia/3c574_cs.c
drivers/net/pcmcia/axnet_cs.c
drivers/net/pcmcia/pcnet_cs.c
drivers/net/pcmcia/xirc2ps_cs.c

index 8a95234d419c8a4d0c32b7a2b33d9d6dc17c29c6..1d7d7fef414f8f64a1a97ab7658214d2af9ea044 100644 (file)
@@ -2209,7 +2209,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,14 +2218,16 @@ static int emac_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
 
        switch (cmd) {
        case SIOCGMIIPHY:
-               data[0] = dev->phy.address;
+               data->phy_id = dev->phy.address;
                /* Fall through */
        case SIOCGMIIREG:
-               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:
-               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;
index d836af1b9034d97ab03bd805628f83c1a20dc130..ee8ad3e180dd308b3b20e6b32d3a686b6b3eba6f 100644 (file)
@@ -85,6 +85,7 @@ earlier 3Com products.
 #include <linux/ioport.h>
 #include <linux/ethtool.h>
 #include <linux/bitops.h>
+#include <linux/mii.h>
 
 #include <pcmcia/cs_types.h>
 #include <pcmcia/cs.h>
@@ -1096,16 +1097,16 @@ static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
        struct el3_private *lp = netdev_priv(dev);
        unsigned int ioaddr = dev->base_addr;
-       u16 *data = (u16 *)&rq->ifr_ifru;
+       struct mii_ioctl_data *data = if_mii(rq);
        int phy = lp->phys & 0x1f;
 
        DEBUG(2, "%s: In ioct(%-.6s, %#4.4x) %4.4x %4.4x %4.4x %4.4x.\n",
                  dev->name, rq->ifr_ifrn.ifrn_name, cmd,
-                 data[0], data[1], data[2], data[3]);
+                 data->phy_id, data->reg_num, data->val_in, data->val_out);
 
        switch(cmd) {
        case SIOCGMIIPHY:               /* Get the address of the PHY in use. */
-               data[0] = phy;
+               data->phy_id = phy;
        case SIOCGMIIREG:               /* Read the specified MII register. */
                {
                        int saved_window;
@@ -1114,7 +1115,8 @@ static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
                        spin_lock_irqsave(&lp->window_lock, flags);
                        saved_window = inw(ioaddr + EL3_CMD) >> 13;
                        EL3WINDOW(4);
-                       data[3] = mdio_read(ioaddr, data[0] & 0x1f, data[1] & 0x1f);
+                       data->val_out = mdio_read(ioaddr, data->phy_id & 0x1f,
+                                                 data->reg_num & 0x1f);
                        EL3WINDOW(saved_window);
                        spin_unlock_irqrestore(&lp->window_lock, flags);
                        return 0;
@@ -1127,7 +1129,8 @@ static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
                        spin_lock_irqsave(&lp->window_lock, flags);
                        saved_window = inw(ioaddr + EL3_CMD) >> 13;
                        EL3WINDOW(4);
-                       mdio_write(ioaddr, data[0] & 0x1f, data[1] & 0x1f, data[2]);
+                       mdio_write(ioaddr, data->phy_id & 0x1f,
+                                  data->reg_num & 0x1f, data->val_in);
                        EL3WINDOW(saved_window);
                        spin_unlock_irqrestore(&lp->window_lock, flags);
                        return 0;
index 4f2fef6cf6dcddc504137fd56cba4cc8f3a82777..3131a59a8d32b4cfbf1f032e237cece52b2f54ea 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/crc32.h>
+#include <linux/mii.h>
 #include "../8390.h"
 
 #include <pcmcia/cs_types.h>
@@ -697,16 +698,16 @@ static const struct ethtool_ops netdev_ethtool_ops = {
 static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
     axnet_dev_t *info = PRIV(dev);
-    u16 *data = (u16 *)&rq->ifr_ifru;
+    struct mii_ioctl_data *data = if_mii(rq);
     unsigned int mii_addr = dev->base_addr + AXNET_MII_EEP;
     switch (cmd) {
     case SIOCGMIIPHY:
-       data[0] = info->phy_id;
+       data->phy_id = info->phy_id;
     case SIOCGMIIREG:          /* Read MII PHY register. */
-       data[3] = mdio_read(mii_addr, data[0], data[1] & 0x1f);
+       data->val_out = mdio_read(mii_addr, data->phy_id, data->reg_num & 0x1f);
        return 0;
     case SIOCSMIIREG:          /* Write MII PHY register. */
-       mdio_write(mii_addr, data[0], data[1] & 0x1f, data[2]);
+       mdio_write(mii_addr, data->phy_id, data->reg_num & 0x1f, data->val_in);
        return 0;
     }
     return -EOPNOTSUPP;
index 8996b45ffffb476ed68e58f992dee08c9bbf5684..90a94d2158314341da9e915239d52452018cccfd 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/netdevice.h>
 #include <linux/log2.h>
 #include <linux/etherdevice.h>
+#include <linux/mii.h>
 #include "../8390.h"
 
 #include <pcmcia/cs_types.h>
@@ -1191,7 +1192,7 @@ static const struct ethtool_ops netdev_ethtool_ops = {
 static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
     pcnet_dev_t *info = PRIV(dev);
-    u16 *data = (u16 *)&rq->ifr_ifru;
+    struct mii_ioctl_data *data = if_mii(rq);
     unsigned int mii_addr = dev->base_addr + DLINK_GPIO;
 
     if (!(info->flags & (IS_DL10019|IS_DL10022)))
@@ -1199,12 +1200,12 @@ static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 
     switch (cmd) {
     case SIOCGMIIPHY:
-       data[0] = info->phy_id;
+       data->phy_id = info->phy_id;
     case SIOCGMIIREG:          /* Read MII PHY register. */
-       data[3] = mdio_read(mii_addr, data[0], data[1] & 0x1f);
+       data->val_out = mdio_read(mii_addr, data->phy_id, data->reg_num & 0x1f);
        return 0;
     case SIOCSMIIREG:          /* Write MII PHY register. */
-       mdio_write(mii_addr, data[0], data[1] & 0x1f, data[2]);
+       mdio_write(mii_addr, data->phy_id, data->reg_num & 0x1f, data->val_in);
        return 0;
     }
     return -EOPNOTSUPP;
index 9709dd173ddc9904ee2038b026d2fc2ad27b0957..cf842310253816a94bcd2e22bd59158fd94c6442 100644 (file)
@@ -80,6 +80,7 @@
 #include <linux/if_arp.h>
 #include <linux/ioport.h>
 #include <linux/bitops.h>
+#include <linux/mii.h>
 
 #include <pcmcia/cs_types.h>
 #include <pcmcia/cs.h>
@@ -1558,24 +1559,26 @@ do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
     local_info_t *local = netdev_priv(dev);
     unsigned int ioaddr = dev->base_addr;
-    u16 *data = (u16 *)&rq->ifr_ifru;
+    struct mii_ioctl_data *data = if_mii(rq);
 
     DEBUG(1, "%s: ioctl(%-.6s, %#04x) %04x %04x %04x %04x\n",
          dev->name, rq->ifr_ifrn.ifrn_name, cmd,
-         data[0], data[1], data[2], data[3]);
+         data->phy_id, data->reg_num, data->val_in, data->val_out);
 
     if (!local->mohawk)
        return -EOPNOTSUPP;
 
     switch(cmd) {
       case SIOCGMIIPHY:                /* Get the address of the PHY in use. */
-       data[0] = 0;            /* we have only this address */
+       data->phy_id = 0;       /* we have only this address */
        /* fall through */
       case SIOCGMIIREG:                /* Read the specified MII register. */
-       data[3] = mii_rd(ioaddr, data[0] & 0x1f, data[1] & 0x1f);
+       data->val_out = mii_rd(ioaddr, data->phy_id & 0x1f,
+                              data->reg_num & 0x1f);
        break;
       case SIOCSMIIREG:                /* Write the specified MII register */
-       mii_wr(ioaddr, data[0] & 0x1f, data[1] & 0x1f, data[2], 16);
+       mii_wr(ioaddr, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in,
+              16);
        break;
       default:
        return -EOPNOTSUPP;