Netdev List
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Nisar.Sayed@microchip.com
Cc: davem@davemloft.net, UNGLinuxDriver@microchip.com,
	netdev@vger.kernel.org
Subject: Re: [PATCH net 2/3] lan78xx: Allow EEPROM write for less than MAX_EEPROM_SIZE
Date: Thu, 7 Sep 2017 16:10:48 +0200	[thread overview]
Message-ID: <20170907141048.GJ11248@lunn.ch> (raw)
In-Reply-To: <CE371C1263339941885964188A0225FA333A7C@CHN-SV-EXMX03.mchp-main.com>

On Thu, Sep 07, 2017 at 07:11:26AM +0000, Nisar.Sayed@microchip.com wrote:
> From: Nisar Sayed <Nisar.Sayed@microchip.com>
> 
> Allow EEPROM write for less than MAX_EEPROM_SIZE
> 
> Signed-off-by: Nisar Sayed <Nisar.Sayed@microchip.com>
> ---
>  drivers/net/usb/lan78xx.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
> index baf91c7..94ef943 100644
> --- a/drivers/net/usb/lan78xx.c
> +++ b/drivers/net/usb/lan78xx.c
> @@ -1299,6 +1299,10 @@ static int lan78xx_ethtool_set_eeprom(struct net_device *netdev,

static int lan78xx_ethtool_set_eeprom(struct net_device *netdev,
                                      struct ethtool_eeprom *ee, u8 *data)
{
        struct lan78xx_net *dev = netdev_priv(netdev);


        /* Allow entire eeprom update only */
        if ((ee->magic == LAN78XX_EEPROM_MAGIC) &&
            (ee->offset == 0) &&
            (ee->len == 512) &&
            (data[0] == EEPROM_INDICATOR))
                return lan78xx_write_raw_eeprom(dev, ee->offset, ee->len, data);
       else if ((ee->magic == LAN78XX_OTP_MAGIC) &&
>  		 (ee->len == 512) &&
>  		 (data[0] == OTP_INDICATOR_1))
>  		ret = lan78xx_write_raw_otp(dev, ee->offset, ee->len, data);
> +	else if ((ee->magic == LAN78XX_EEPROM_MAGIC) &&
> +		 (ee->offset >= 0 && ee->offset < MAX_EEPROM_SIZE) &&
> +		 (ee->len > 0 && (ee->offset + ee->len) <= MAX_EEPROM_SIZE))
> +		ret = lan78xx_write_raw_eeprom(dev, ee->offset, ee->len, data);
>  
>  	usb_autopm_put_interface(dev->intf);

Hi Nisar

You should explain why this change cannot be folded into the first if
statement.

	Andrew

      reply	other threads:[~2017-09-07 14:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-07  7:11 [PATCH net 2/3] lan78xx: Allow EEPROM write for less than MAX_EEPROM_SIZE Nisar.Sayed
2017-09-07 14:10 ` Andrew Lunn [this message]

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=20170907141048.GJ11248@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=Nisar.Sayed@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=davem@davemloft.net \
    --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