diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/core/ethtool.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 41dee2de13ad..13d79f5a86e5 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
@@ -1669,7 +1669,7 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr) | |||
1669 | return dev->ethtool_ops->phys_id(dev, id.data); | 1669 | return dev->ethtool_ops->phys_id(dev, id.data); |
1670 | 1670 | ||
1671 | rc = dev->ethtool_ops->set_phys_id(dev, ETHTOOL_ID_ACTIVE); | 1671 | rc = dev->ethtool_ops->set_phys_id(dev, ETHTOOL_ID_ACTIVE); |
1672 | if (rc && rc != -EINVAL) | 1672 | if (rc < 0) |
1673 | return rc; | 1673 | return rc; |
1674 | 1674 | ||
1675 | /* Drop the RTNL lock while waiting, but prevent reentry or | 1675 | /* Drop the RTNL lock while waiting, but prevent reentry or |
@@ -1684,21 +1684,22 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr) | |||
1684 | schedule_timeout_interruptible( | 1684 | schedule_timeout_interruptible( |
1685 | id.data ? (id.data * HZ) : MAX_SCHEDULE_TIMEOUT); | 1685 | id.data ? (id.data * HZ) : MAX_SCHEDULE_TIMEOUT); |
1686 | } else { | 1686 | } else { |
1687 | /* Driver expects to be called periodically */ | 1687 | /* Driver expects to be called at twice the frequency in rc */ |
1688 | int n = rc * 2, i, interval = HZ / n; | ||
1689 | |||
1690 | /* Count down seconds */ | ||
1688 | do { | 1691 | do { |
1689 | rtnl_lock(); | 1692 | /* Count down iterations per second */ |
1690 | rc = dev->ethtool_ops->set_phys_id(dev, ETHTOOL_ID_ON); | 1693 | i = n; |
1691 | rtnl_unlock(); | 1694 | do { |
1692 | if (rc) | 1695 | rtnl_lock(); |
1693 | break; | 1696 | rc = dev->ethtool_ops->set_phys_id(dev, |
1694 | schedule_timeout_interruptible(HZ / 2); | 1697 | (i & 1) ? ETHTOOL_ID_OFF : ETHTOOL_ID_ON); |
1695 | 1698 | rtnl_unlock(); | |
1696 | rtnl_lock(); | 1699 | if (rc) |
1697 | rc = dev->ethtool_ops->set_phys_id(dev, ETHTOOL_ID_OFF); | 1700 | break; |
1698 | rtnl_unlock(); | 1701 | schedule_timeout_interruptible(interval); |
1699 | if (rc) | 1702 | } while (!signal_pending(current) && --i != 0); |
1700 | break; | ||
1701 | schedule_timeout_interruptible(HZ / 2); | ||
1702 | } while (!signal_pending(current) && | 1703 | } while (!signal_pending(current) && |
1703 | (id.data == 0 || --id.data != 0)); | 1704 | (id.data == 0 || --id.data != 0)); |
1704 | } | 1705 | } |