diff options
author | Ben Dooks <ben-linux@fluff.org> | 2008-02-05 00:02:14 +0000 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2008-02-11 11:06:31 -0500 |
commit | 621ddcb0461baee26a5e7c86a76938f0aa83dec1 (patch) | |
tree | 40fed02f95849d05370ee7bb59df63852ee13fe1 /drivers/net/dm9000.c | |
parent | 3927f1c88efc25b2972c8cbd7ed10d5f1b88b52a (diff) | |
download | talos-op-linux-621ddcb0461baee26a5e7c86a76938f0aa83dec1.tar.gz talos-op-linux-621ddcb0461baee26a5e7c86a76938f0aa83dec1.zip |
DM9000: Ensure spinlock held whilst accessing EEPROM registers
Ensure we hold the spinlock whilst the registers and being
modified even though we hold the overall lock. This should
protect against an interrupt happening whilst we are using
the device.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/dm9000.c')
-rw-r--r-- | drivers/net/dm9000.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c index 3bef3b25ff0e..5a883711d1f4 100644 --- a/drivers/net/dm9000.c +++ b/drivers/net/dm9000.c @@ -1073,17 +1073,29 @@ dm9000_rx(struct net_device *dev) static void dm9000_read_eeprom(board_info_t *db, int offset, u8 *to) { + unsigned long flags; + mutex_lock(&db->addr_lock); + spin_lock_irqsave(&db->lock, flags); + iow(db, DM9000_EPAR, offset); iow(db, DM9000_EPCR, EPCR_ERPRR); + + spin_unlock_irqrestore(&db->lock, flags); + mdelay(8); /* according to the datasheet 200us should be enough, but it doesn't work */ + + spin_lock_irqsave(&db->lock, flags); + iow(db, DM9000_EPCR, 0x0); to[0] = ior(db, DM9000_EPDRL); to[1] = ior(db, DM9000_EPDRH); + spin_unlock_irqrestore(&db->lock, flags); + mutex_unlock(&db->addr_lock); } @@ -1093,14 +1105,22 @@ dm9000_read_eeprom(board_info_t *db, int offset, u8 *to) static void dm9000_write_eeprom(board_info_t *db, int offset, u8 *data) { + unsigned long flags; + mutex_lock(&db->addr_lock); + spin_lock_irqsave(&db->lock, flags); iow(db, DM9000_EPAR, offset); iow(db, DM9000_EPDRH, data[1]); iow(db, DM9000_EPDRL, data[0]); iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW); + spin_unlock_irqrestore(&db->lock, flags); + mdelay(8); /* same shit */ + + spin_lock_irqsave(&db->lock, flags); iow(db, DM9000_EPCR, 0); + spin_unlock_irqrestore(&db->lock, flags); mutex_unlock(&db->addr_lock); } |