Commit 51c61a28 authored by Matt Renzelmann's avatar Matt Renzelmann Committed by David S. Miller

ks8851: Fix missing mutex_lock/unlock

Move the ks8851_rdreg16 call above the call to request_irq and cache
the result for subsequent repeated use.  A spurious interrupt may
otherwise cause a crash.  Thanks to Stephen Boyd, Flavio Leitner, and
Ben Hutchings for feedback.
Signed-off-by: default avatarMatt Renzelmann <mjr@cs.wisc.edu>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 59a54f30
...@@ -1418,6 +1418,7 @@ static int __devinit ks8851_probe(struct spi_device *spi) ...@@ -1418,6 +1418,7 @@ static int __devinit ks8851_probe(struct spi_device *spi)
struct net_device *ndev; struct net_device *ndev;
struct ks8851_net *ks; struct ks8851_net *ks;
int ret; int ret;
unsigned cider;
ndev = alloc_etherdev(sizeof(struct ks8851_net)); ndev = alloc_etherdev(sizeof(struct ks8851_net));
if (!ndev) if (!ndev)
...@@ -1484,8 +1485,8 @@ static int __devinit ks8851_probe(struct spi_device *spi) ...@@ -1484,8 +1485,8 @@ static int __devinit ks8851_probe(struct spi_device *spi)
ks8851_soft_reset(ks, GRR_GSR); ks8851_soft_reset(ks, GRR_GSR);
/* simple check for a valid chip being connected to the bus */ /* simple check for a valid chip being connected to the bus */
cider = ks8851_rdreg16(ks, KS_CIDER);
if ((ks8851_rdreg16(ks, KS_CIDER) & ~CIDER_REV_MASK) != CIDER_ID) { if ((cider & ~CIDER_REV_MASK) != CIDER_ID) {
dev_err(&spi->dev, "failed to read device ID\n"); dev_err(&spi->dev, "failed to read device ID\n");
ret = -ENODEV; ret = -ENODEV;
goto err_id; goto err_id;
...@@ -1516,8 +1517,7 @@ static int __devinit ks8851_probe(struct spi_device *spi) ...@@ -1516,8 +1517,7 @@ static int __devinit ks8851_probe(struct spi_device *spi)
} }
netdev_info(ndev, "revision %d, MAC %pM, IRQ %d, %s EEPROM\n", netdev_info(ndev, "revision %d, MAC %pM, IRQ %d, %s EEPROM\n",
CIDER_REV_GET(ks8851_rdreg16(ks, KS_CIDER)), CIDER_REV_GET(cider), ndev->dev_addr, ndev->irq,
ndev->dev_addr, ndev->irq,
ks->rc_ccr & CCR_EEPROM ? "has" : "no"); ks->rc_ccr & CCR_EEPROM ? "has" : "no");
return 0; return 0;
......
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