netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: Ajit Khaparde <ajitk@serverengines.com>
Cc: davem@davemloft.net, jgarzik@pobox.com, netdev@vger.kernel.org
Subject: Re: [RFC][PATCH][v4] ethtool: Add a new ethtool option to flash a firmware image from the specified file to a device.
Date: Thu, 20 Aug 2009 18:27:59 +0100	[thread overview]
Message-ID: <1250789279.2779.5.camel@achroite> (raw)
In-Reply-To: <20090820171635.GA20213@serverengines.com>

On Thu, 2009-08-20 at 22:46 +0530, Ajit Khaparde wrote:
> This patch adds a new "-f" option to the ethtool utility
> to flash a firmware image specified by a file, to a network device.
> The filename is passed to the network driver which will flash the image
> on the chip using the request_firmware path.
[...]
> @@ -304,6 +309,9 @@ static int rx_fhash_get = 0;
>  static int rx_fhash_set = 0;
>  static u32 rx_fhash_val = 0;
>  static int rx_fhash_changed = 0;
> +static char flash_file[ETHTOOL_FLASH_MAX_FILENAME];

It would be much simpler to make this a pointer...

> +static int flash = -1;
> +static int flash_region = 0;
>  static enum {
>  	ONLINE=0,
>  	OFFLINE,
[...]
> @@ -516,6 +525,10 @@ static void parse_cmdline(int argc, char **argp)
>  				if (phys_id_time < 0)
>  					show_usage(1);
>  				break;
> +			} else if (mode == MODE_FLASHDEV) {
> +				sprintf(flash_file, "%s", argp[i]);

...and to change this to "flash_file = argp[i];"...

> +				flash = 1;
> +				break;
>  			}
>  			/* fallthrough */
>  		default:
[...]
> @@ -2398,6 +2419,38 @@ static int do_grxclass(int fd, struct ifreq *ifr)
>  	return 0;
>  }
>  
> +static int do_flash(int fd, struct ifreq *ifr)
> +{
> +	struct ethtool_flash efl;
> +	int err;
> +
> +	if (flash < 0) {
> +		fprintf(stdout, "Missing filename argument\n");
> +		show_usage(1);
> +		return 98;
> +	}
> +
> +	if (strlen(flash_file) > ETHTOOL_FLASH_MAX_FILENAME - 1) {
> +		fprintf(stdout, "Filename too long\n");
> +		return 99;
> +	}
[...]

...and then this length check would work properly.

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


      reply	other threads:[~2009-08-20 17:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-20 17:16 [RFC][PATCH][v4] ethtool: Add a new ethtool option to flash a firmware image from the specified file to a device Ajit Khaparde
2009-08-20 17:27 ` Ben Hutchings [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=1250789279.2779.5.camel@achroite \
    --to=bhutchings@solarflare.com \
    --cc=ajitk@serverengines.com \
    --cc=davem@davemloft.net \
    --cc=jgarzik@pobox.com \
    --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).