public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: David Dillow <dave@thedillows.org>
To: Jaswinder Singh <jaswinder@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	becker@scyld.com, davidpmclean@yahoo.com,
	Jeff Garzik <jeff@garzik.org>, netdev <netdev@vger.kernel.org>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH] typhoon: use request_firmware
Date: Mon, 28 Jul 2008 21:38:18 -0400	[thread overview]
Message-ID: <1217295498.28682.16.camel@obelisk.thedillows.org> (raw)
In-Reply-To: <1217253260.17632.6.camel@jaswinder.satnam>

On Mon, 2008-07-28 at 19:24 +0530, Jaswinder Singh wrote:
> Here is patch for typhoon.c :

It's getting better, as it's not obviously broken now.

> +MODULE_FIRMWARE("3com/typhoon.bin");

Minor nit, but perhaps #define the name, so you don't have to keep this
and the string in typhoon_init_firmware() in sync.

> @@ -307,6 +308,9 @@ struct typhoon {
>  	/* unused stuff (future use) */
>  	int			capabilities;
>  	struct transmit_ring 	txHiRing;
> +
> +	/* firmware */
> +	u8			*tp_fw_image;
>  };

Now you keep one copy per NIC, which doubles the memory usage. Just use
static struct firmware *typhoon_fw;

> +static int typhoon_init_firmware(struct typhoon *tp)
> +{
> +	const struct firmware *fw;
> +	const char fw_name[] = "3com/typhoon.bin";

If you use the #define and the global static, you can get rid of the
above. Just use the define in place of fw_name below:

> +	err = request_firmware(&fw, fw_name, &tp->pdev->dev);
> +	if (err) {
> +		printk(KERN_ERR "%s: Failed to load firmware \"%s\"\n",
> +		       tp->name, fw_name);
> +		return err;
> +	}
> +	tp->tp_fw_image = vmalloc(fw->size);
> +	if (!tp->tp_fw_image) {
> +		err = -ENOMEM;
> +		printk(KERN_ERR "%s: \"%s\" Failed %d\n",
> +		       tp->name, fw_name, err);
> +		goto out;
> +	}

Then you can get rid of the double allocation and memcpy. Just put the
call to release_firmware() in typhoon_cleanup().

> @@ -2102,6 +2132,10 @@ typhoon_open(struct net_device *dev)
>  	if(err < 0)
>  		goto out_sleep;
>  
> +	err = typhoon_init_firmware(tp);
> +	if (err)
> +		goto out_irq;
> +

This should move to either typhoon_init() or typhoon_init_one(). Putting
it in typhoon_init() means we waste memory when the module is loaded if
there is no typhoon NIC; putting it in typhoon_init_one() means it needs
protection from threaded probing, should that ever be put back in. Given
that most modern distros don't do probing by blinding loading modules,
typhoon_init() seems a safe bet.

> @@ -2155,6 +2189,9 @@ typhoon_close(struct net_device *dev)

> +	if (tp->tp_fw_image)
> +		vfree(tp->tp_fw_image);
> +

This goes away and is replaced by a release_firmware() in
typhoon_cleanup() if you do the above.

Dave


  reply	other threads:[~2008-07-29  1:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-27 14:50 [PATCH] typhoon: use request_firmware Jaswinder Singh
2008-07-28  1:43 ` David Dillow
2008-07-28  3:16   ` Jaswinder Singh
2008-07-28 12:36     ` David Dillow
2008-07-28 13:54       ` Jaswinder Singh
2008-07-29  1:38         ` David Dillow [this message]
2008-07-29  3:57           ` David Dillow
2008-07-29 16:09           ` Jaswinder Singh
2008-07-30  5:25             ` David Dillow
2008-07-30  6:44               ` Jaswinder Singh
2008-07-31  3:37                 ` David Dillow
2008-07-31  7:42                   ` David Woodhouse

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=1217295498.28682.16.camel@obelisk.thedillows.org \
    --to=dave@thedillows.org \
    --cc=becker@scyld.com \
    --cc=davidpmclean@yahoo.com \
    --cc=dwmw2@infradead.org \
    --cc=jaswinder@infradead.org \
    --cc=jeff@garzik.org \
    --cc=linux-kernel@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