* [PATCH] net: DM9000: Add support for byte EEPROM access
@ 2011-06-10 10:50 Mark Brown
2011-06-10 12:24 ` Ben Hutchings
2011-06-11 22:55 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Mark Brown @ 2011-06-10 10:50 UTC (permalink / raw)
Cc: netdev, Ben Dooks, Mark Brown
From: Ben Dooks <ben-linux@fluff.org>
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>
---
drivers/net/dm9000.c | 26 ++++++++++++++++++++------
1 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 863e9c4..8ef31dc 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -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;
}
--
1.7.5.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: DM9000: Add support for byte EEPROM access
2011-06-10 10:50 [PATCH] net: DM9000: Add support for byte EEPROM access Mark Brown
@ 2011-06-10 12:24 ` Ben Hutchings
2011-06-11 22:55 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Ben Hutchings @ 2011-06-10 12:24 UTC (permalink / raw)
To: Mark Brown; +Cc: netdev, Ben Dooks
On Fri, 2011-06-10 at 11:50 +0100, Mark Brown wrote:
> From: Ben Dooks <ben-linux@fluff.org>
>
> 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>
Ben.
--
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: DM9000: Add support for byte EEPROM access
2011-06-10 10:50 [PATCH] net: DM9000: Add support for byte EEPROM access Mark Brown
2011-06-10 12:24 ` Ben Hutchings
@ 2011-06-11 22:55 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2011-06-11 22:55 UTC (permalink / raw)
To: broonie; +Cc: netdev, ben-linux
From: Mark Brown <broonie@opensource.wolfsonmicro.com>
Date: Fri, 10 Jun 2011 11:50:32 +0100
> From: Ben Dooks <ben-linux@fluff.org>
>
> 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>
Applied to net-next-2.6, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-06-11 22:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-10 10:50 [PATCH] net: DM9000: Add support for byte EEPROM access Mark Brown
2011-06-10 12:24 ` Ben Hutchings
2011-06-11 22:55 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).