diff options
author | stephen hemminger <shemminger@vyatta.com> | 2011-04-06 07:58:36 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-06 18:05:46 -0400 |
commit | 7b1b3afadf33627e707c5038af991ae2ce9b5ac5 (patch) | |
tree | bbd0bc0bcc0eec0f514ffc87de36a23343cca1b6 /drivers/net/ewrk3.c | |
parent | 94469f75321d13a42056514e2883590b91d84cba (diff) |
ewrk3: convert to set_phys_id
Use ethtool infrastructure for blinking, which is now does
locking at higher level.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ewrk3.c')
-rw-r--r-- | drivers/net/ewrk3.c | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/drivers/net/ewrk3.c b/drivers/net/ewrk3.c index 380d0614a89a..c7ce4438e923 100644 --- a/drivers/net/ewrk3.c +++ b/drivers/net/ewrk3.c | |||
@@ -1604,55 +1604,47 @@ static u32 ewrk3_get_link(struct net_device *dev) | |||
1604 | return !(cmr & CMR_LINK); | 1604 | return !(cmr & CMR_LINK); |
1605 | } | 1605 | } |
1606 | 1606 | ||
1607 | static int ewrk3_phys_id(struct net_device *dev, u32 data) | 1607 | static int ewrk3_set_phys_id(struct net_device *dev, |
1608 | enum ethtool_phys_id_state state) | ||
1608 | { | 1609 | { |
1609 | struct ewrk3_private *lp = netdev_priv(dev); | 1610 | struct ewrk3_private *lp = netdev_priv(dev); |
1610 | unsigned long iobase = dev->base_addr; | 1611 | unsigned long iobase = dev->base_addr; |
1611 | unsigned long flags; | ||
1612 | u8 cr; | 1612 | u8 cr; |
1613 | int count; | ||
1614 | |||
1615 | /* Toggle LED 4x per second */ | ||
1616 | count = data << 2; | ||
1617 | 1613 | ||
1618 | spin_lock_irqsave(&lp->hw_lock, flags); | 1614 | spin_lock_irq(&lp->hw_lock); |
1619 | |||
1620 | /* Bail if a PHYS_ID is already in progress */ | ||
1621 | if (lp->led_mask == 0) { | ||
1622 | spin_unlock_irqrestore(&lp->hw_lock, flags); | ||
1623 | return -EBUSY; | ||
1624 | } | ||
1625 | 1615 | ||
1626 | /* Prevent ISR from twiddling the LED */ | 1616 | switch (state) { |
1627 | lp->led_mask = 0; | 1617 | case ETHTOOL_ID_ACTIVE: |
1618 | /* Prevent ISR from twiddling the LED */ | ||
1619 | lp->led_mask = 0; | ||
1620 | spin_unlock_irq(&lp->hw_lock); | ||
1621 | return -EINVAL; | ||
1628 | 1622 | ||
1629 | while (count--) { | 1623 | case ETHTOOL_ID_ON: |
1630 | /* Toggle the LED */ | ||
1631 | cr = inb(EWRK3_CR); | 1624 | cr = inb(EWRK3_CR); |
1632 | outb(cr ^ CR_LED, EWRK3_CR); | 1625 | outb(cr | CR_LED, EWRK3_CR); |
1626 | break; | ||
1633 | 1627 | ||
1634 | /* Wait a little while */ | 1628 | case ETHTOOL_ID_OFF: |
1635 | spin_unlock_irqrestore(&lp->hw_lock, flags); | 1629 | cr = inb(EWRK3_CR); |
1636 | msleep(250); | 1630 | outb(cr & ~CR_LED, EWRK3_CR); |
1637 | spin_lock_irqsave(&lp->hw_lock, flags); | 1631 | break; |
1638 | 1632 | ||
1639 | /* Exit if we got a signal */ | 1633 | case ETHTOOL_ID_INACTIVE: |
1640 | if (signal_pending(current)) | 1634 | lp->led_mask = CR_LED; |
1641 | break; | 1635 | cr = inb(EWRK3_CR); |
1636 | outb(cr & ~CR_LED, EWRK3_CR); | ||
1642 | } | 1637 | } |
1638 | spin_unlock_irq(&lp->hw_lock); | ||
1643 | 1639 | ||
1644 | lp->led_mask = CR_LED; | 1640 | return 0; |
1645 | cr = inb(EWRK3_CR); | ||
1646 | outb(cr & ~CR_LED, EWRK3_CR); | ||
1647 | spin_unlock_irqrestore(&lp->hw_lock, flags); | ||
1648 | return signal_pending(current) ? -ERESTARTSYS : 0; | ||
1649 | } | 1641 | } |
1650 | 1642 | ||
1651 | static const struct ethtool_ops ethtool_ops_203 = { | 1643 | static const struct ethtool_ops ethtool_ops_203 = { |
1652 | .get_drvinfo = ewrk3_get_drvinfo, | 1644 | .get_drvinfo = ewrk3_get_drvinfo, |
1653 | .get_settings = ewrk3_get_settings, | 1645 | .get_settings = ewrk3_get_settings, |
1654 | .set_settings = ewrk3_set_settings, | 1646 | .set_settings = ewrk3_set_settings, |
1655 | .phys_id = ewrk3_phys_id, | 1647 | .set_phys_id = ewrk3_set_phys_id, |
1656 | }; | 1648 | }; |
1657 | 1649 | ||
1658 | static const struct ethtool_ops ethtool_ops = { | 1650 | static const struct ethtool_ops ethtool_ops = { |
@@ -1660,7 +1652,7 @@ static const struct ethtool_ops ethtool_ops = { | |||
1660 | .get_settings = ewrk3_get_settings, | 1652 | .get_settings = ewrk3_get_settings, |
1661 | .set_settings = ewrk3_set_settings, | 1653 | .set_settings = ewrk3_set_settings, |
1662 | .get_link = ewrk3_get_link, | 1654 | .get_link = ewrk3_get_link, |
1663 | .phys_id = ewrk3_phys_id, | 1655 | .set_phys_id = ewrk3_set_phys_id, |
1664 | }; | 1656 | }; |
1665 | 1657 | ||
1666 | /* | 1658 | /* |