aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2011-06-09 20:50:32 -0400
committerDavid S. Miller <davem@davemloft.net>2011-06-11 18:54:52 -0400
commit40d15cd06e87722b1cc27d56c8274617580f2c56 (patch)
tree0069ec0f16f41b0369d10c35616444c7c8d9d21f
parent6d65e5eee6fc8fa9abef9e78e7e789c2cb06f95c (diff)
net: DM9000: Add support for byte EEPROM access
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. Signed-off-by: Ben Dooks <ben-linux@fluff.org> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Reviewed-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/dm9000.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 863e9c459e6..8ef31dc4704 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -535,21 +535,35 @@ static int dm9000_set_eeprom(struct net_device *dev,
535 board_info_t *dm = to_dm9000_board(dev); 535 board_info_t *dm = to_dm9000_board(dev);
536 int offset = ee->offset; 536 int offset = ee->offset;
537 int len = ee->len; 537 int len = ee->len;
538 int i; 538 int done;
539 539
540 /* EEPROM access is aligned to two bytes */ 540 /* EEPROM access is aligned to two bytes */
541 541
542 if ((len & 1) != 0 || (offset & 1) != 0)
543 return -EINVAL;
544
545 if (dm->flags & DM9000_PLATF_NO_EEPROM) 542 if (dm->flags & DM9000_PLATF_NO_EEPROM)
546 return -ENOENT; 543 return -ENOENT;
547 544
548 if (ee->magic != DM_EEPROM_MAGIC) 545 if (ee->magic != DM_EEPROM_MAGIC)
549 return -EINVAL; 546 return -EINVAL;
550 547
551 for (i = 0; i < len; i += 2) 548 while (len > 0) {
552 dm9000_write_eeprom(dm, (offset + i) / 2, data + i); 549 if (len & 1 || offset & 1) {
550 int which = offset & 1;
551 u8 tmp[2];
552
553 dm9000_read_eeprom(dm, offset / 2, tmp);
554 tmp[which] = *data;
555 dm9000_write_eeprom(dm, offset / 2, tmp);
556
557 done = 1;
558 } else {
559 dm9000_write_eeprom(dm, offset / 2, data);
560 done = 2;
561 }
562
563 data += done;
564 offset += done;
565 len -= done;
566 }
553 567
554 return 0; 568 return 0;
555} 569}