aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2009-09-03 06:39:43 -0400
committerDavid S. Miller <davem@davemloft.net>2009-09-03 23:02:11 -0400
commit7ab0f2736bfe137a82a7084bbfb5f809da95cabd (patch)
treee305ec96eceebb285efee4b6fd307822ab257fe6
parentaae5e7c30fc660c50dfecbdd745799b05af90f01 (diff)
netdev: Remove redundant checks for CAP_NET_ADMIN in MDIO implementations
dev_ioctl() already checks capable(CAP_NET_ADMIN) before calling the driver's implementation of MDIO ioctls. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/amd8111e.c3
-rw-r--r--drivers/net/atl1c/atl1c_main.c8
-rw-r--r--drivers/net/atl1e/atl1e_main.c8
-rw-r--r--drivers/net/atlx/atl2.c4
-rw-r--r--drivers/net/bnx2.c3
-rw-r--r--drivers/net/cassini.c4
-rw-r--r--drivers/net/e1000/e1000_main.c4
-rw-r--r--drivers/net/e1000e/netdev.c2
-rw-r--r--drivers/net/ibm_newemac/core.c2
-rw-r--r--drivers/net/igb/igb_main.c2
-rw-r--r--drivers/net/mdio.c3
-rw-r--r--drivers/net/mii.c3
-rw-r--r--drivers/net/natsemi.c2
-rw-r--r--drivers/net/pci-skeleton.c5
-rw-r--r--drivers/net/pcmcia/3c574_cs.c2
-rw-r--r--drivers/net/pcmcia/axnet_cs.c2
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c2
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c2
-rw-r--r--drivers/net/phy/phy.c3
-rw-r--r--drivers/net/r8169.c2
-rw-r--r--drivers/net/sis900.c2
-rw-r--r--drivers/net/skge.c3
-rw-r--r--drivers/net/sky2.c3
-rw-r--r--drivers/net/sungem.c4
-rw-r--r--drivers/net/tg3.c3
-rw-r--r--drivers/net/tlan.c2
-rw-r--r--drivers/net/tulip/tulip_core.c2
-rw-r--r--drivers/net/tulip/winbond-840.c2
-rw-r--r--drivers/net/via-velocity.c4
-rw-r--r--drivers/net/yellowfin.c2
30 files changed, 1 insertions, 92 deletions
diff --git a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c
index 98b5f462c092..4e6359fff0e1 100644
--- a/drivers/net/amd8111e.c
+++ b/drivers/net/amd8111e.c
@@ -1524,9 +1524,6 @@ static int amd8111e_ioctl(struct net_device * dev , struct ifreq *ifr, int cmd)
1524 int err; 1524 int err;
1525 u32 mii_regval; 1525 u32 mii_regval;
1526 1526
1527 if (!capable(CAP_NET_ADMIN))
1528 return -EPERM;
1529
1530 switch(cmd) { 1527 switch(cmd) {
1531 case SIOCGMIIPHY: 1528 case SIOCGMIIPHY:
1532 data->phy_id = lp->ext_phy_addr; 1529 data->phy_id = lp->ext_phy_addr;
diff --git a/drivers/net/atl1c/atl1c_main.c b/drivers/net/atl1c/atl1c_main.c
index e46bf9238692..be2c6cfe6e84 100644
--- a/drivers/net/atl1c/atl1c_main.c
+++ b/drivers/net/atl1c/atl1c_main.c
@@ -534,10 +534,6 @@ static int atl1c_mii_ioctl(struct net_device *netdev,
534 break; 534 break;
535 535
536 case SIOCGMIIREG: 536 case SIOCGMIIREG:
537 if (!capable(CAP_NET_ADMIN)) {
538 retval = -EPERM;
539 goto out;
540 }
541 if (atl1c_read_phy_reg(&adapter->hw, data->reg_num & 0x1F, 537 if (atl1c_read_phy_reg(&adapter->hw, data->reg_num & 0x1F,
542 &data->val_out)) { 538 &data->val_out)) {
543 retval = -EIO; 539 retval = -EIO;
@@ -546,10 +542,6 @@ static int atl1c_mii_ioctl(struct net_device *netdev,
546 break; 542 break;
547 543
548 case SIOCSMIIREG: 544 case SIOCSMIIREG:
549 if (!capable(CAP_NET_ADMIN)) {
550 retval = -EPERM;
551 goto out;
552 }
553 if (data->reg_num & ~(0x1F)) { 545 if (data->reg_num & ~(0x1F)) {
554 retval = -EFAULT; 546 retval = -EFAULT;
555 goto out; 547 goto out;
diff --git a/drivers/net/atl1e/atl1e_main.c b/drivers/net/atl1e/atl1e_main.c
index bca127e65f95..69b830f4b68f 100644
--- a/drivers/net/atl1e/atl1e_main.c
+++ b/drivers/net/atl1e/atl1e_main.c
@@ -453,10 +453,6 @@ static int atl1e_mii_ioctl(struct net_device *netdev,
453 break; 453 break;
454 454
455 case SIOCGMIIREG: 455 case SIOCGMIIREG:
456 if (!capable(CAP_NET_ADMIN)) {
457 retval = -EPERM;
458 goto out;
459 }
460 if (atl1e_read_phy_reg(&adapter->hw, data->reg_num & 0x1F, 456 if (atl1e_read_phy_reg(&adapter->hw, data->reg_num & 0x1F,
461 &data->val_out)) { 457 &data->val_out)) {
462 retval = -EIO; 458 retval = -EIO;
@@ -465,10 +461,6 @@ static int atl1e_mii_ioctl(struct net_device *netdev,
465 break; 461 break;
466 462
467 case SIOCSMIIREG: 463 case SIOCSMIIREG:
468 if (!capable(CAP_NET_ADMIN)) {
469 retval = -EPERM;
470 goto out;
471 }
472 if (data->reg_num & ~(0x1F)) { 464 if (data->reg_num & ~(0x1F)) {
473 retval = -EFAULT; 465 retval = -EFAULT;
474 goto out; 466 goto out;
diff --git a/drivers/net/atlx/atl2.c b/drivers/net/atlx/atl2.c
index 10c06b97001f..ab688862093f 100644
--- a/drivers/net/atlx/atl2.c
+++ b/drivers/net/atlx/atl2.c
@@ -966,8 +966,6 @@ static int atl2_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
966 data->phy_id = 0; 966 data->phy_id = 0;
967 break; 967 break;
968 case SIOCGMIIREG: 968 case SIOCGMIIREG:
969 if (!capable(CAP_NET_ADMIN))
970 return -EPERM;
971 spin_lock_irqsave(&adapter->stats_lock, flags); 969 spin_lock_irqsave(&adapter->stats_lock, flags);
972 if (atl2_read_phy_reg(&adapter->hw, 970 if (atl2_read_phy_reg(&adapter->hw,
973 data->reg_num & 0x1F, &data->val_out)) { 971 data->reg_num & 0x1F, &data->val_out)) {
@@ -977,8 +975,6 @@ static int atl2_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
977 spin_unlock_irqrestore(&adapter->stats_lock, flags); 975 spin_unlock_irqrestore(&adapter->stats_lock, flags);
978 break; 976 break;
979 case SIOCSMIIREG: 977 case SIOCSMIIREG:
980 if (!capable(CAP_NET_ADMIN))
981 return -EPERM;
982 if (data->reg_num & ~(0x1F)) 978 if (data->reg_num & ~(0x1F))
983 return -EFAULT; 979 return -EFAULT;
984 spin_lock_irqsave(&adapter->stats_lock, flags); 980 spin_lock_irqsave(&adapter->stats_lock, flags);
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 1357d548e698..08cddb6ff740 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -7480,9 +7480,6 @@ bnx2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
7480 } 7480 }
7481 7481
7482 case SIOCSMIIREG: 7482 case SIOCSMIIREG:
7483 if (!capable(CAP_NET_ADMIN))
7484 return -EPERM;
7485
7486 if (bp->phy_flags & BNX2_PHY_FLAG_REMOTE_PHY_CAP) 7483 if (bp->phy_flags & BNX2_PHY_FLAG_REMOTE_PHY_CAP)
7487 return -EOPNOTSUPP; 7484 return -EOPNOTSUPP;
7488 7485
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index 7517dc1da650..05916aafa4f1 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -4875,10 +4875,6 @@ static int cas_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
4875 break; 4875 break;
4876 4876
4877 case SIOCSMIIREG: /* Write MII PHY register. */ 4877 case SIOCSMIIREG: /* Write MII PHY register. */
4878 if (!capable(CAP_NET_ADMIN)) {
4879 rc = -EPERM;
4880 break;
4881 }
4882 spin_lock_irqsave(&cp->lock, flags); 4878 spin_lock_irqsave(&cp->lock, flags);
4883 cas_mif_poll(cp, 0); 4879 cas_mif_poll(cp, 0);
4884 rc = cas_phy_write(cp, data->reg_num & 0x1f, data->val_in); 4880 rc = cas_phy_write(cp, data->reg_num & 0x1f, data->val_in);
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 2c723b1b8820..c66dd4f9437c 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -4714,8 +4714,6 @@ static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
4714 data->phy_id = hw->phy_addr; 4714 data->phy_id = hw->phy_addr;
4715 break; 4715 break;
4716 case SIOCGMIIREG: 4716 case SIOCGMIIREG:
4717 if (!capable(CAP_NET_ADMIN))
4718 return -EPERM;
4719 spin_lock_irqsave(&adapter->stats_lock, flags); 4717 spin_lock_irqsave(&adapter->stats_lock, flags);
4720 if (e1000_read_phy_reg(hw, data->reg_num & 0x1F, 4718 if (e1000_read_phy_reg(hw, data->reg_num & 0x1F,
4721 &data->val_out)) { 4719 &data->val_out)) {
@@ -4725,8 +4723,6 @@ static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
4725 spin_unlock_irqrestore(&adapter->stats_lock, flags); 4723 spin_unlock_irqrestore(&adapter->stats_lock, flags);
4726 break; 4724 break;
4727 case SIOCSMIIREG: 4725 case SIOCSMIIREG:
4728 if (!capable(CAP_NET_ADMIN))
4729 return -EPERM;
4730 if (data->reg_num & ~(0x1F)) 4726 if (data->reg_num & ~(0x1F))
4731 return -EFAULT; 4727 return -EFAULT;
4732 mii_reg = data->val_in; 4728 mii_reg = data->val_in;
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 0f8d9619adea..16c193a6c95c 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -4346,8 +4346,6 @@ static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
4346 data->phy_id = adapter->hw.phy.addr; 4346 data->phy_id = adapter->hw.phy.addr;
4347 break; 4347 break;
4348 case SIOCGMIIREG: 4348 case SIOCGMIIREG:
4349 if (!capable(CAP_NET_ADMIN))
4350 return -EPERM;
4351 switch (data->reg_num & 0x1F) { 4349 switch (data->reg_num & 0x1F) {
4352 case MII_BMCR: 4350 case MII_BMCR:
4353 data->val_out = adapter->phy_regs.bmcr; 4351 data->val_out = adapter->phy_regs.bmcr;
diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c
index 24ae671e4cb2..8a95234d419c 100644
--- a/drivers/net/ibm_newemac/core.c
+++ b/drivers/net/ibm_newemac/core.c
@@ -2225,8 +2225,6 @@ static int emac_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
2225 return 0; 2225 return 0;
2226 2226
2227 case SIOCSMIIREG: 2227 case SIOCSMIIREG:
2228 if (!capable(CAP_NET_ADMIN))
2229 return -EPERM;
2230 emac_mdio_write(ndev, dev->phy.address, data[1], data[2]); 2228 emac_mdio_write(ndev, dev->phy.address, data[1], data[2]);
2231 return 0; 2229 return 0;
2232 default: 2230 default:
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 90b0b1b91730..943186b78483 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -4914,8 +4914,6 @@ static int igb_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
4914 data->phy_id = adapter->hw.phy.addr; 4914 data->phy_id = adapter->hw.phy.addr;
4915 break; 4915 break;
4916 case SIOCGMIIREG: 4916 case SIOCGMIIREG:
4917 if (!capable(CAP_NET_ADMIN))
4918 return -EPERM;
4919 if (igb_read_phy_reg(&adapter->hw, data->reg_num & 0x1F, 4917 if (igb_read_phy_reg(&adapter->hw, data->reg_num & 0x1F,
4920 &data->val_out)) 4918 &data->val_out))
4921 return -EIO; 4919 return -EIO;
diff --git a/drivers/net/mdio.c b/drivers/net/mdio.c
index 7d2e610f14ff..21f8754fcf4c 100644
--- a/drivers/net/mdio.c
+++ b/drivers/net/mdio.c
@@ -380,10 +380,7 @@ int mdio_mii_ioctl(const struct mdio_if_info *mdio,
380 cmd = SIOCGMIIREG; 380 cmd = SIOCGMIIREG;
381 break; 381 break;
382 case SIOCGMIIREG: 382 case SIOCGMIIREG:
383 break;
384 case SIOCSMIIREG: 383 case SIOCSMIIREG:
385 if (!capable(CAP_NET_ADMIN))
386 return -EPERM;
387 break; 384 break;
388 default: 385 default:
389 return -EOPNOTSUPP; 386 return -EOPNOTSUPP;
diff --git a/drivers/net/mii.c b/drivers/net/mii.c
index d81a5d22a3a9..210b2b164b30 100644
--- a/drivers/net/mii.c
+++ b/drivers/net/mii.c
@@ -433,9 +433,6 @@ int generic_mii_ioctl(struct mii_if_info *mii_if,
433 case SIOCSMIIREG: { 433 case SIOCSMIIREG: {
434 u16 val = mii_data->val_in; 434 u16 val = mii_data->val_in;
435 435
436 if (!capable(CAP_NET_ADMIN))
437 return -EPERM;
438
439 if (mii_data->phy_id == mii_if->phy_id) { 436 if (mii_data->phy_id == mii_if->phy_id) {
440 switch(mii_data->reg_num) { 437 switch(mii_data->reg_num) {
441 case MII_BMCR: { 438 case MII_BMCR: {
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index b52e5d98a3b7..b2722c44337e 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -3075,8 +3075,6 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
3075 return 0; 3075 return 0;
3076 3076
3077 case SIOCSMIIREG: /* Write MII PHY register. */ 3077 case SIOCSMIIREG: /* Write MII PHY register. */
3078 if (!capable(CAP_NET_ADMIN))
3079 return -EPERM;
3080 if (dev->if_port == PORT_TP) { 3078 if (dev->if_port == PORT_TP) {
3081 if ((data->phy_id & 0x1f) == np->phy_addr_external) { 3079 if ((data->phy_id & 0x1f) == np->phy_addr_external) {
3082 if ((data->reg_num & 0x1f) == MII_ADVERTISE) 3080 if ((data->reg_num & 0x1f) == MII_ADVERTISE)
diff --git a/drivers/net/pci-skeleton.c b/drivers/net/pci-skeleton.c
index c47ba3610c58..0c44b48f1384 100644
--- a/drivers/net/pci-skeleton.c
+++ b/drivers/net/pci-skeleton.c
@@ -1784,11 +1784,6 @@ static int netdrv_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
1784 break; 1784 break;
1785 1785
1786 case SIOCSMIIREG: /* Write MII PHY register. */ 1786 case SIOCSMIIREG: /* Write MII PHY register. */
1787 if (!capable (CAP_NET_ADMIN)) {
1788 rc = -EPERM;
1789 break;
1790 }
1791
1792 spin_lock_irqsave (&tp->lock, flags); 1787 spin_lock_irqsave (&tp->lock, flags);
1793 mdio_write (dev, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in); 1788 mdio_write (dev, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in);
1794 spin_unlock_irqrestore (&tp->lock, flags); 1789 spin_unlock_irqrestore (&tp->lock, flags);
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 382d26520acc..d836af1b9034 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -1124,8 +1124,6 @@ static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1124 int saved_window; 1124 int saved_window;
1125 unsigned long flags; 1125 unsigned long flags;
1126 1126
1127 if (!capable(CAP_NET_ADMIN))
1128 return -EPERM;
1129 spin_lock_irqsave(&lp->window_lock, flags); 1127 spin_lock_irqsave(&lp->window_lock, flags);
1130 saved_window = inw(ioaddr + EL3_CMD) >> 13; 1128 saved_window = inw(ioaddr + EL3_CMD) >> 13;
1131 EL3WINDOW(4); 1129 EL3WINDOW(4);
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 3b681c1d7523..4f2fef6cf6dc 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -706,8 +706,6 @@ static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
706 data[3] = mdio_read(mii_addr, data[0], data[1] & 0x1f); 706 data[3] = mdio_read(mii_addr, data[0], data[1] & 0x1f);
707 return 0; 707 return 0;
708 case SIOCSMIIREG: /* Write MII PHY register. */ 708 case SIOCSMIIREG: /* Write MII PHY register. */
709 if (!capable(CAP_NET_ADMIN))
710 return -EPERM;
711 mdio_write(mii_addr, data[0], data[1] & 0x1f, data[2]); 709 mdio_write(mii_addr, data[0], data[1] & 0x1f, data[2]);
712 return 0; 710 return 0;
713 } 711 }
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 9ef1c1bfa83d..8996b45ffffb 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -1204,8 +1204,6 @@ static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1204 data[3] = mdio_read(mii_addr, data[0], data[1] & 0x1f); 1204 data[3] = mdio_read(mii_addr, data[0], data[1] & 0x1f);
1205 return 0; 1205 return 0;
1206 case SIOCSMIIREG: /* Write MII PHY register. */ 1206 case SIOCSMIIREG: /* Write MII PHY register. */
1207 if (!capable(CAP_NET_ADMIN))
1208 return -EPERM;
1209 mdio_write(mii_addr, data[0], data[1] & 0x1f, data[2]); 1207 mdio_write(mii_addr, data[0], data[1] & 0x1f, data[2]);
1210 return 0; 1208 return 0;
1211 } 1209 }
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index 68de89167b49..9709dd173ddc 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -1575,8 +1575,6 @@ do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1575 data[3] = mii_rd(ioaddr, data[0] & 0x1f, data[1] & 0x1f); 1575 data[3] = mii_rd(ioaddr, data[0] & 0x1f, data[1] & 0x1f);
1576 break; 1576 break;
1577 case SIOCSMIIREG: /* Write the specified MII register */ 1577 case SIOCSMIIREG: /* Write the specified MII register */
1578 if (!capable(CAP_NET_ADMIN))
1579 return -EPERM;
1580 mii_wr(ioaddr, data[0] & 0x1f, data[1] & 0x1f, data[2], 16); 1578 mii_wr(ioaddr, data[0] & 0x1f, data[1] & 0x1f, data[2], 16);
1581 break; 1579 break;
1582 default: 1580 default:
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index eda94fcd4065..6b71b0034060 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -324,9 +324,6 @@ int phy_mii_ioctl(struct phy_device *phydev,
324 break; 324 break;
325 325
326 case SIOCSMIIREG: 326 case SIOCSMIIREG:
327 if (!capable(CAP_NET_ADMIN))
328 return -EPERM;
329
330 if (mii_data->phy_id == phydev->addr) { 327 if (mii_data->phy_id == phydev->addr) {
331 switch(mii_data->reg_num) { 328 switch(mii_data->reg_num) {
332 case MII_BMCR: 329 case MII_BMCR:
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index ec0092affd5d..a91e9b3a3eb6 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1991,8 +1991,6 @@ static int rtl_xmii_ioctl(struct rtl8169_private *tp, struct mii_ioctl_data *dat
1991 return 0; 1991 return 0;
1992 1992
1993 case SIOCSMIIREG: 1993 case SIOCSMIIREG:
1994 if (!capable(CAP_NET_ADMIN))
1995 return -EPERM;
1996 mdio_write(tp->mmio_addr, data->reg_num & 0x1f, data->val_in); 1994 mdio_write(tp->mmio_addr, data->reg_num & 0x1f, data->val_in);
1997 return 0; 1995 return 0;
1998 } 1996 }
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
index d8827323507a..97949d0a699b 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -2128,8 +2128,6 @@ static int mii_ioctl(struct net_device *net_dev, struct ifreq *rq, int cmd)
2128 return 0; 2128 return 0;
2129 2129
2130 case SIOCSMIIREG: /* Write MII PHY register. */ 2130 case SIOCSMIIREG: /* Write MII PHY register. */
2131 if (!capable(CAP_NET_ADMIN))
2132 return -EPERM;
2133 mdio_write(net_dev, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in); 2131 mdio_write(net_dev, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in);
2134 return 0; 2132 return 0;
2135 default: 2133 default:
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 1a1e68549f5c..62e852e21ab2 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -2496,9 +2496,6 @@ static int skge_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2496 } 2496 }
2497 2497
2498 case SIOCSMIIREG: 2498 case SIOCSMIIREG:
2499 if (!capable(CAP_NET_ADMIN))
2500 return -EPERM;
2501
2502 spin_lock_bh(&hw->phy_lock); 2499 spin_lock_bh(&hw->phy_lock);
2503 if (hw->chip_id == CHIP_ID_GENESIS) 2500 if (hw->chip_id == CHIP_ID_GENESIS)
2504 err = xm_phy_write(hw, skge->port, data->reg_num & 0x1f, 2501 err = xm_phy_write(hw, skge->port, data->reg_num & 0x1f,
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index bab591b418df..00bc65a0aac9 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -1214,9 +1214,6 @@ static int sky2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1214 } 1214 }
1215 1215
1216 case SIOCSMIIREG: 1216 case SIOCSMIIREG:
1217 if (!capable(CAP_NET_ADMIN))
1218 return -EPERM;
1219
1220 spin_lock_bh(&sky2->phy_lock); 1217 spin_lock_bh(&sky2->phy_lock);
1221 err = gm_phy_write(hw, sky2->port, data->reg_num & 0x1f, 1218 err = gm_phy_write(hw, sky2->port, data->reg_num & 0x1f,
1222 data->val_in); 1219 data->val_in);
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index e0dfdd246470..305ec3d783db 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -2852,9 +2852,7 @@ static int gem_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2852 break; 2852 break;
2853 2853
2854 case SIOCSMIIREG: /* Write MII PHY register. */ 2854 case SIOCSMIIREG: /* Write MII PHY register. */
2855 if (!capable(CAP_NET_ADMIN)) 2855 if (!gp->running)
2856 rc = -EPERM;
2857 else if (!gp->running)
2858 rc = -EAGAIN; 2856 rc = -EAGAIN;
2859 else { 2857 else {
2860 __phy_write(gp, data->phy_id & 0x1f, data->reg_num & 0x1f, 2858 __phy_write(gp, data->phy_id & 0x1f, data->reg_num & 0x1f,
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index bd4981052609..7cf80006eafa 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -10610,9 +10610,6 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
10610 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) 10610 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)
10611 break; /* We have no PHY */ 10611 break; /* We have no PHY */
10612 10612
10613 if (!capable(CAP_NET_ADMIN))
10614 return -EPERM;
10615
10616 if (tp->link_config.phy_is_low_power) 10613 if (tp->link_config.phy_is_low_power)
10617 return -EAGAIN; 10614 return -EAGAIN;
10618 10615
diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c
index 49e273bceed6..3d31b47332bb 100644
--- a/drivers/net/tlan.c
+++ b/drivers/net/tlan.c
@@ -1004,8 +1004,6 @@ static int TLan_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1004 1004
1005 1005
1006 case SIOCSMIIREG: /* Write MII PHY register. */ 1006 case SIOCSMIIREG: /* Write MII PHY register. */
1007 if (!capable(CAP_NET_ADMIN))
1008 return -EPERM;
1009 TLan_MiiWriteReg(dev, data->phy_id & 0x1f, 1007 TLan_MiiWriteReg(dev, data->phy_id & 0x1f,
1010 data->reg_num & 0x1f, data->val_in); 1008 data->reg_num & 0x1f, data->val_in);
1011 return 0; 1009 return 0;
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index b89b73c0b30b..6b2330e4206e 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -923,8 +923,6 @@ static int private_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
923 return 0; 923 return 0;
924 924
925 case SIOCSMIIREG: /* Write MII PHY register. */ 925 case SIOCSMIIREG: /* Write MII PHY register. */
926 if (!capable (CAP_NET_ADMIN))
927 return -EPERM;
928 if (regnum & ~0x1f) 926 if (regnum & ~0x1f)
929 return -EINVAL; 927 return -EINVAL;
930 if (data->phy_id == phy) { 928 if (data->phy_id == phy) {
diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
index 3e59397e5386..b38d3b7f6e35 100644
--- a/drivers/net/tulip/winbond-840.c
+++ b/drivers/net/tulip/winbond-840.c
@@ -1470,8 +1470,6 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1470 return 0; 1470 return 0;
1471 1471
1472 case SIOCSMIIREG: /* Write MII PHY register. */ 1472 case SIOCSMIIREG: /* Write MII PHY register. */
1473 if (!capable(CAP_NET_ADMIN))
1474 return -EPERM;
1475 spin_lock_irq(&np->lock); 1473 spin_lock_irq(&np->lock);
1476 mdio_write(dev, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in); 1474 mdio_write(dev, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in);
1477 spin_unlock_irq(&np->lock); 1475 spin_unlock_irq(&np->lock);
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index ced1446dec04..e04e5bee005c 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -2328,14 +2328,10 @@ static int velocity_mii_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd
2328 miidata->phy_id = readb(&regs->MIIADR) & 0x1f; 2328 miidata->phy_id = readb(&regs->MIIADR) & 0x1f;
2329 break; 2329 break;
2330 case SIOCGMIIREG: 2330 case SIOCGMIIREG:
2331 if (!capable(CAP_NET_ADMIN))
2332 return -EPERM;
2333 if (velocity_mii_read(vptr->mac_regs, miidata->reg_num & 0x1f, &(miidata->val_out)) < 0) 2331 if (velocity_mii_read(vptr->mac_regs, miidata->reg_num & 0x1f, &(miidata->val_out)) < 0)
2334 return -ETIMEDOUT; 2332 return -ETIMEDOUT;
2335 break; 2333 break;
2336 case SIOCSMIIREG: 2334 case SIOCSMIIREG:
2337 if (!capable(CAP_NET_ADMIN))
2338 return -EPERM;
2339 spin_lock_irqsave(&vptr->lock, flags); 2335 spin_lock_irqsave(&vptr->lock, flags);
2340 err = velocity_mii_write(vptr->mac_regs, miidata->reg_num & 0x1f, miidata->val_in); 2336 err = velocity_mii_write(vptr->mac_regs, miidata->reg_num & 0x1f, miidata->val_in);
2341 spin_unlock_irqrestore(&vptr->lock, flags); 2337 spin_unlock_irqrestore(&vptr->lock, flags);
diff --git a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c
index 4987040c414b..40ad0dee0406 100644
--- a/drivers/net/yellowfin.c
+++ b/drivers/net/yellowfin.c
@@ -1365,8 +1365,6 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1365 return 0; 1365 return 0;
1366 1366
1367 case SIOCSMIIREG: /* Write MII PHY register. */ 1367 case SIOCSMIIREG: /* Write MII PHY register. */
1368 if (!capable(CAP_NET_ADMIN))
1369 return -EPERM;
1370 if (data->phy_id == np->phys[0]) { 1368 if (data->phy_id == np->phys[0]) {
1371 u16 value = data->val_in; 1369 u16 value = data->val_in;
1372 switch (data->reg_num) { 1370 switch (data->reg_num) {