From: Ben Hutchings <ben@decadent.org.uk>
To: Joseph CHANG <josright123@gmail.com>,
Peter Korsgaard <jacmet@sunsite.dk>,
netdev@vger.kernel.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Joseph Chang <joseph_chang@davicom.com.tw>
Subject: Re: [PATCH 3/3] dm9601: add support ethtool style utility
Date: Thu, 10 Mar 2016 11:49:20 +0000 [thread overview]
Message-ID: <1457610560.3001.34.camel@decadent.org.uk> (raw)
In-Reply-To: <1457609067-3674-1-git-send-email-josright123@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2571 bytes --]
The subject line on this is very vague; it should say which ethtool
operation you're implementing.
On Thu, 2016-03-10 at 19:24 +0800, Joseph CHANG wrote:
> Add function dm9601_set_eeprom which tested good with ethtool
> utility, include the eeprom words dump and the eeprom byte write.
>
> Signed-off-by: Joseph CHANG <josright123@gmail.com>
> ---
> drivers/net/usb/dm9601.c | 39 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 39 insertions(+)
>
> diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
> index 50095df..a6904f4 100644
> --- a/drivers/net/usb/dm9601.c
> +++ b/drivers/net/usb/dm9601.c
> @@ -61,6 +61,7 @@
> #define DM_RX_OVERHEAD 7 /* 3 byte header + 4 byte crc tail */
> #define DM_TIMEOUT 1000
> #define DM_EP3I_VAL 0x07
> +#define MD96XX_EEPROM_MAGIC 0x9620
The get_eeprom operation needs to be changed, to set eeprom->magic to
this value.
> static int dm_read(struct usbnet *dev, u8 reg, u16 length, void *data)
> {
> @@ -289,6 +290,43 @@ static int dm9601_get_eeprom(struct net_device *net,
> return 0;
> }
>
> +static int dm9601_set_eeprom(struct net_device *net,
> + struct ethtool_eeprom *eeprom, u8 *data)
> +{
> + struct usbnet *dev = netdev_priv(net);
> + int offset = eeprom->offset;
> + int len = eeprom->len;
> + int done;
> +
> + if (eeprom->magic != MD96XX_EEPROM_MAGIC) {
> + netdev_dbg(dev->net, "EEPROM: magic value mismatch, magic = 0x%x",
> + eeprom->magic);
> + return -EINVAL;
> + }
> +
> + while (len > 0) {
> + if (len & 1 || offset & 1) {
Given that the get_eeprom operation only handles word-aligned reads, is
it really important to support misaligned writes in set_eeprom?
Also, this test should be 'if (len == 1 || offset & 1)'. Consider a
write with offset = 2, len = 3. You want to write a word on the first
iteration, then a byte on the second iteration.
> + int which = offset & 1;
> + u8 tmp[2];
> +
> + dm_read_eeprom_word(dev, offset / 2, tmp);
> + tmp[which] = *data;
> + dm_write_eeprom_word(dev, offset / 2,
> + tmp[0] | tmp[1] << 8);
> + mdelay(10);
Why is a delay required here, but not in the other case?
> + done = 1;
> + } else {
> + dm_write_eeprom_word(dev, offset / 2,
> + data[0] | data[1] << 8);
> + done = 2;
> + }
> + data += done;
> + offset += done;
> + len -= done;
> + }
> + return 0;
> +}
[...]
Ben.
--
Ben Hutchings
To err is human; to really foul things up requires a computer.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-03-10 11:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-10 11:24 [PATCH 3/3] dm9601: add support ethtool style utility Joseph CHANG
2016-03-10 11:49 ` Ben Hutchings [this message]
[not found] <201603101253.u2ACrnUJ002444@mail.davicom.com.tw>
2016-03-10 13:17 ` Ben Hutchings
2016-03-11 11:08 ` Joseph Chang
2016-03-11 11:33 ` Ben Hutchings
2016-03-11 11:42 ` Ben Hutchings
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1457610560.3001.34.camel@decadent.org.uk \
--to=ben@decadent.org.uk \
--cc=jacmet@sunsite.dk \
--cc=joseph_chang@davicom.com.tw \
--cc=josright123@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).