Commit 1df726ef authored by Russell King's avatar Russell King

NET: am79c961: fix race in link status code

The link status code operates from a timer, and writes the index
register without first taking a lock.  A well-placed interrupt
between writing the index register and reading the data register
could change the index register on us, which will return wrong data.
Add the necessary lock.
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent fb492c91
...@@ -308,8 +308,11 @@ static void am79c961_timer(unsigned long data) ...@@ -308,8 +308,11 @@ static void am79c961_timer(unsigned long data)
struct net_device *dev = (struct net_device *)data; struct net_device *dev = (struct net_device *)data;
struct dev_priv *priv = netdev_priv(dev); struct dev_priv *priv = netdev_priv(dev);
unsigned int lnkstat, carrier; unsigned int lnkstat, carrier;
unsigned long flags;
spin_lock_irqsave(&priv->chip_lock, flags);
lnkstat = read_ireg(dev->base_addr, ISALED0) & ISALED0_LNKST; lnkstat = read_ireg(dev->base_addr, ISALED0) & ISALED0_LNKST;
spin_unlock_irqrestore(&priv->chip_lock, flags);
carrier = netif_carrier_ok(dev); carrier = netif_carrier_ok(dev);
if (lnkstat && !carrier) { if (lnkstat && !carrier) {
......
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