Skip to content

Commit

Permalink
ks8851: Fix missing mutex_lock/unlock
Browse files Browse the repository at this point in the history
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: Matt Renzelmann <mjr@cs.wisc.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Matt Renzelmann authored and David S. Miller committed Apr 13, 2012
1 parent 59a54f3 commit 51c61a2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/net/ethernet/micrel/ks8851.c
Original file line number Diff line number Diff line change
Expand Up @@ -1418,6 +1418,7 @@ static int __devinit ks8851_probe(struct spi_device *spi)
struct net_device *ndev;
struct ks8851_net *ks;
int ret;
unsigned cider;

ndev = alloc_etherdev(sizeof(struct ks8851_net));
if (!ndev)
Expand Down Expand Up @@ -1484,8 +1485,8 @@ static int __devinit ks8851_probe(struct spi_device *spi)
ks8851_soft_reset(ks, GRR_GSR);

/* simple check for a valid chip being connected to the bus */

if ((ks8851_rdreg16(ks, KS_CIDER) & ~CIDER_REV_MASK) != CIDER_ID) {
cider = ks8851_rdreg16(ks, KS_CIDER);
if ((cider & ~CIDER_REV_MASK) != CIDER_ID) {
dev_err(&spi->dev, "failed to read device ID\n");
ret = -ENODEV;
goto err_id;
Expand Down Expand Up @@ -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",
CIDER_REV_GET(ks8851_rdreg16(ks, KS_CIDER)),
ndev->dev_addr, ndev->irq,
CIDER_REV_GET(cider), ndev->dev_addr, ndev->irq,
ks->rc_ccr & CCR_EEPROM ? "has" : "no");

return 0;
Expand Down

0 comments on commit 51c61a2

Please sign in to comment.