Patchwork [08/13] KSZ8851-SNL: Fix EEPROM access problem

login
register
mail settings
Submitter Ben Dooks
Date April 29, 2010, 11:16 p.m.
Message ID <20100429231740.358390546@fluff.org.uk>
Download mbox | patch
Permalink /patch/51398/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Ben Dooks - April 29, 2010, 11:16 p.m.
From: Tristram Ha <Tristram.Ha@micrel.com>

Accessing the EEPROM when the device is receiving sometimes hangs the
system as the hardware is not locked down.

Signed-off-by: Tristram Ha <Tristram.Ha@micrel.com>
[ben@simtec.co.uk: fix description text]
Signed-off-by: Ben Dooks <ben@simtec.co.uk>

---
---
 drivers/net/ks8851.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

Index: b/drivers/net/ks8851.c
===================================================================
--- a/drivers/net/ks8851.c	2010-04-29 01:22:42.667052653 +0900
+++ b/drivers/net/ks8851.c	2010-04-29 01:22:47.779528264 +0900
@@ -1181,7 +1181,6 @@  static void ks8851_eeprom_regwrite(struc
 	if (ee->reg_chip_select)
 		val |= EEPCR_EECS;
 
-	printk(KERN_INFO "%s: wr %04x\n", __func__, val);
 	ks8851_wrreg16(ks, KS_EEPCR, val);
 }
 
@@ -1197,6 +1196,8 @@  static int ks8851_eeprom_claim(struct ks
 	if (!(ks->rc_ccr & CCR_EEPROM))
 		return -ENOENT;
 
+	mutex_lock(&ks->lock);
+
 	/* start with clock low, cs high */
 	ks8851_wrreg16(ks, KS_EEPCR, EEPCR_EESA | EEPCR_EECS);
 	return 0;
@@ -1213,6 +1214,7 @@  static void ks8851_eeprom_release(struct
 	unsigned val = ks8851_rdreg16(ks,KS_EEPCR);
 
 	ks8851_wrreg16(ks, KS_EEPCR, val & ~EEPCR_EESA);
+	mutex_unlock(&ks->lock);
 }
 
 #define KS_EEPROM_MAGIC (0x00008851)