Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ben Dooks and committed by
David S. Miller
40d15cd0 6d65e5ee

+20 -6
+20 -6
drivers/net/dm9000.c
··· 535 535 board_info_t *dm = to_dm9000_board(dev); 536 536 int offset = ee->offset; 537 537 int len = ee->len; 538 - int i; 538 + int done; 539 539 540 540 /* EEPROM access is aligned to two bytes */ 541 - 542 - if ((len & 1) != 0 || (offset & 1) != 0) 543 - return -EINVAL; 544 541 545 542 if (dm->flags & DM9000_PLATF_NO_EEPROM) 546 543 return -ENOENT; ··· 545 548 if (ee->magic != DM_EEPROM_MAGIC) 546 549 return -EINVAL; 547 550 548 - for (i = 0; i < len; i += 2) 549 - dm9000_write_eeprom(dm, (offset + i) / 2, data + i); 551 + while (len > 0) { 552 + if (len & 1 || offset & 1) { 553 + int which = offset & 1; 554 + u8 tmp[2]; 555 + 556 + dm9000_read_eeprom(dm, offset / 2, tmp); 557 + tmp[which] = *data; 558 + dm9000_write_eeprom(dm, offset / 2, tmp); 559 + 560 + done = 1; 561 + } else { 562 + dm9000_write_eeprom(dm, offset / 2, data); 563 + done = 2; 564 + } 565 + 566 + data += done; 567 + offset += done; 568 + len -= done; 569 + } 550 570 551 571 return 0; 552 572 }