Skip to contentSkip to conversation

net: DM9000: Add support for byte EEPROM access

PATCH Applied Mark Brown 3 participants 3 messages Jun 10, 2011 – Jun 11, 2011

Subsystems (2)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 net: DM9000: Add support for byte EEPROM access

From: Ben Dooks <[email protected]>

Given many versions of ethtool's reluctance to do anything other than byte accesses to the EEPROM interface, it is easier to update the driver to support byte accesses so that all the ethtool versions that have been observed in Debian can write the EEPROM.

---
 drivers/net/dm9000.c |   26 ++++++++++++++++++++------
 1 files changed, 20 insertions(+), 6 deletions(-)
drivers/net/dm9000.c +20 -6
index 863e9c4..8ef31dc 100644
@@ -535,21 +535,35 @@ static int dm9000_set_eeprom(struct net_device *dev,
 	board_info_t *dm = to_dm9000_board(dev);
 	int offset = ee->offset;
 	int len = ee->len;
-	int i;
+	int done;
 
 	/* EEPROM access is aligned to two bytes */
 
-	if ((len & 1) != 0 || (offset & 1) != 0)
-		return -EINVAL;
-
 	if (dm->flags & DM9000_PLATF_NO_EEPROM)
 		return -ENOENT;
 
 	if (ee->magic != DM_EEPROM_MAGIC)
 		return -EINVAL;
 
-	for (i = 0; i < len; i += 2)
-		dm9000_write_eeprom(dm, (offset + i) / 2, data + i);
+	while (len > 0) {
+		if (len & 1 || offset & 1) {
+			int which = offset & 1;
+			u8 tmp[2];
+
+			dm9000_read_eeprom(dm, offset / 2, tmp);
+			tmp[which] = *data;
+			dm9000_write_eeprom(dm, offset / 2, tmp);
+
+			done = 1;
+		} else {
+			dm9000_write_eeprom(dm, offset / 2, data);
+			done = 2;
+		}
+
+		data += done;
+		offset += done;
+		len -= done;
+	}
 
 	return 0;
 }
Signature · 1 line
1.7.5.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Mark Brown

From: Ben Dooks <[email protected]>

Given many versions of ethtool's reluctance to do anything other than byte accesses to the EEPROM interface, it is easier to update the driver to support byte accesses so that all the ethtool versions that have been observed in Debian can write the EEPROM.

Ben.

Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
maintainer Applied
#2 lore raw
In reply to Mark Brown

From: Mark Brown <[email protected]>
Date: Fri, 10 Jun 2011 11:50:32 +0100

Quoted 9 lines

From: Ben Dooks <[email protected]>

Given many versions of ethtool's reluctance to do anything other than byte accesses to the EEPROM interface, it is easier to update the driver to support byte accesses so that all the ethtool versions that have been observed in Debian can write the EEPROM.

Applied to net-next-2.6, thanks.