Commit 0fa0ee05 authored by Ben Hutchings's avatar Ben Hutchings Committed by David S. Miller

netdev: Convert MDIO ioctl implementation to use struct mii_ioctl_data

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: default avatarBen Hutchings <bhutchings@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7ab0f273
...@@ -2209,7 +2209,7 @@ static const struct ethtool_ops emac_ethtool_ops = { ...@@ -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) static int emac_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
{ {
struct emac_instance *dev = netdev_priv(ndev); 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); DBG(dev, "ioctl %08x" NL, cmd);
...@@ -2218,14 +2218,16 @@ static int emac_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) ...@@ -2218,14 +2218,16 @@ static int emac_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
switch (cmd) { switch (cmd) {
case SIOCGMIIPHY: case SIOCGMIIPHY:
data[0] = dev->phy.address; data->phy_id = dev->phy.address;
/* Fall through */ /* Fall through */
case SIOCGMIIREG: 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; return 0;
case SIOCSMIIREG: 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; return 0;
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
...@@ -85,6 +85,7 @@ earlier 3Com products. ...@@ -85,6 +85,7 @@ earlier 3Com products.
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/ethtool.h> #include <linux/ethtool.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/mii.h>
#include <pcmcia/cs_types.h> #include <pcmcia/cs_types.h>
#include <pcmcia/cs.h> #include <pcmcia/cs.h>
...@@ -1096,16 +1097,16 @@ static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -1096,16 +1097,16 @@ static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{ {
struct el3_private *lp = netdev_priv(dev); struct el3_private *lp = netdev_priv(dev);
unsigned int ioaddr = dev->base_addr; 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; int phy = lp->phys & 0x1f;
DEBUG(2, "%s: In ioct(%-.6s, %#4.4x) %4.4x %4.4x %4.4x %4.4x.\n", 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, 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) { switch(cmd) {
case SIOCGMIIPHY: /* Get the address of the PHY in use. */ case SIOCGMIIPHY: /* Get the address of the PHY in use. */
data[0] = phy; data->phy_id = phy;
case SIOCGMIIREG: /* Read the specified MII register. */ case SIOCGMIIREG: /* Read the specified MII register. */
{ {
int saved_window; int saved_window;
...@@ -1114,7 +1115,8 @@ static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -1114,7 +1115,8 @@ static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
spin_lock_irqsave(&lp->window_lock, flags); spin_lock_irqsave(&lp->window_lock, flags);
saved_window = inw(ioaddr + EL3_CMD) >> 13; saved_window = inw(ioaddr + EL3_CMD) >> 13;
EL3WINDOW(4); 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); EL3WINDOW(saved_window);
spin_unlock_irqrestore(&lp->window_lock, flags); spin_unlock_irqrestore(&lp->window_lock, flags);
return 0; return 0;
...@@ -1127,7 +1129,8 @@ static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -1127,7 +1129,8 @@ static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
spin_lock_irqsave(&lp->window_lock, flags); spin_lock_irqsave(&lp->window_lock, flags);
saved_window = inw(ioaddr + EL3_CMD) >> 13; saved_window = inw(ioaddr + EL3_CMD) >> 13;
EL3WINDOW(4); 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); EL3WINDOW(saved_window);
spin_unlock_irqrestore(&lp->window_lock, flags); spin_unlock_irqrestore(&lp->window_lock, flags);
return 0; return 0;
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/crc32.h> #include <linux/crc32.h>
#include <linux/mii.h>
#include "../8390.h" #include "../8390.h"
#include <pcmcia/cs_types.h> #include <pcmcia/cs_types.h>
...@@ -697,16 +698,16 @@ static const struct ethtool_ops netdev_ethtool_ops = { ...@@ -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) static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{ {
axnet_dev_t *info = PRIV(dev); 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; unsigned int mii_addr = dev->base_addr + AXNET_MII_EEP;
switch (cmd) { switch (cmd) {
case SIOCGMIIPHY: case SIOCGMIIPHY:
data[0] = info->phy_id; data->phy_id = info->phy_id;
case SIOCGMIIREG: /* Read MII PHY register. */ 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; return 0;
case SIOCSMIIREG: /* Write MII PHY register. */ 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 0;
} }
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/log2.h> #include <linux/log2.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/mii.h>
#include "../8390.h" #include "../8390.h"
#include <pcmcia/cs_types.h> #include <pcmcia/cs_types.h>
...@@ -1191,7 +1192,7 @@ static const struct ethtool_ops netdev_ethtool_ops = { ...@@ -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) static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{ {
pcnet_dev_t *info = PRIV(dev); 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; unsigned int mii_addr = dev->base_addr + DLINK_GPIO;
if (!(info->flags & (IS_DL10019|IS_DL10022))) if (!(info->flags & (IS_DL10019|IS_DL10022)))
...@@ -1199,12 +1200,12 @@ static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -1199,12 +1200,12 @@ static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
switch (cmd) { switch (cmd) {
case SIOCGMIIPHY: case SIOCGMIIPHY:
data[0] = info->phy_id; data->phy_id = info->phy_id;
case SIOCGMIIREG: /* Read MII PHY register. */ 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; return 0;
case SIOCSMIIREG: /* Write MII PHY register. */ 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 0;
} }
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
...@@ -80,6 +80,7 @@ ...@@ -80,6 +80,7 @@
#include <linux/if_arp.h> #include <linux/if_arp.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/mii.h>
#include <pcmcia/cs_types.h> #include <pcmcia/cs_types.h>
#include <pcmcia/cs.h> #include <pcmcia/cs.h>
...@@ -1558,24 +1559,26 @@ do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -1558,24 +1559,26 @@ do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{ {
local_info_t *local = netdev_priv(dev); local_info_t *local = netdev_priv(dev);
unsigned int ioaddr = dev->base_addr; 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", DEBUG(1, "%s: ioctl(%-.6s, %#04x) %04x %04x %04x %04x\n",
dev->name, rq->ifr_ifrn.ifrn_name, cmd, 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) if (!local->mohawk)
return -EOPNOTSUPP; return -EOPNOTSUPP;
switch(cmd) { switch(cmd) {
case SIOCGMIIPHY: /* Get the address of the PHY in use. */ 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 */ /* fall through */
case SIOCGMIIREG: /* Read the specified MII register. */ 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; break;
case SIOCSMIIREG: /* Write the specified MII register */ 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; break;
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment