From: Marcelo Tosatti <marcelo@kvack.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Marcelo Tosatti <marcelo@kvack.org>,
netdev <netdev@vger.kernel.org>, Jeff Garzik <jgarzik@pobox.com>,
"John W. Linville" <linville@redhat.com>,
Dan Williams <dcbw@redhat.com>,
"Luis R. Rodriguez" <mcgrof@gmail.com>,
Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Subject: Re: [PATCH] Marvell Libertas 8388 802.11b/g USB driver (v2)
Date: Sat, 10 Feb 2007 12:05:29 -0200 [thread overview]
Message-ID: <20070210140529.GA3814@dmt.wfacil.com.br> (raw)
In-Reply-To: <200701270253.08320.arnd@arndb.de>
On Sat, Jan 27, 2007 at 02:53:07AM +0100, Arnd Bergmann wrote:
> > +/** Command Processing States and Options */
> > +#define HostCmd_STATE_IDLE 0x0000
> > +#define HostCmd_STATE_IN_USE_BY_HOST 0x0001
> > +#define HostCmd_STATE_IN_USE_BY_MINIPORT 0x0002
> > +#define HostCmd_STATE_FINISHED 0x000f
>
> No SilLYcAps please
Done.
> Most of these are unused as well, I guess it would be good
> to go through the whole list and see what can be removed.
Done.
> > +/**
> > + * @brief This function reads of the packet into the upload buff,
> > + * wake up the main thread and initialise the Rx callack.
> > + *
> > + * @param urb pointer to struct urb
> > + * @return N/A
> > + */
> > +static void if_usb_receive(struct urb *urb)
> > +{
>
> This function is a little long, there is a switch() statement in it
> that can probably be converted into one function per case.
Moved processing of CMD_TYPE_REQUEST and CMD_TYPE_DATA to inline
functions.
> > +/**
> > + * @brief Given a usb_card_rec return its wlan_private
> > + * @param card pointer to a usb_card_rec
> > + * @return pointer to wlan_private
> > + */
> > +wlan_private *libertas_sbi_get_priv(void *card)
> > +{
> > + struct usb_card_rec *cardp = (struct usb_card_rec *)card;
> > + return (wlan_private *)cardp->priv;
> > +}
>
> Don't do explicit casts of void* pointers.
Fixed.
> > + data = *((int *)(wrq->u.name + SUBCMD_OFFSET));
>
> You use this weird line in many places, it would be good to make it
> a helper function.
Converted to a macro.
> > +static u8 Is_Command_Allowed_In_PS(u16 Command)
> > +{
> > + int count = sizeof(Commands_Allowed_In_PS)
> > + / sizeof(Commands_Allowed_In_PS[0]);
> > + int i;
> > +
> > + for (i = 0; i < count; i++) {
> > + if (Command == cpu_to_le16(Commands_Allowed_In_PS[i]))
> > + return 1;
> > + }
> > +
> > + return 0;
> > +}
>
> In places where you use variables that are strictly little-endian,
> it would be nice to use the __le32/__le16 types instead of u32/u16.
>
> > +/**
> > + * @brief This function handles the command response
> > + *
> > + * @param priv A pointer to wlan_private structure
> > + * @return WLAN_STATUS_SUCCESS or WLAN_STATUS_FAILURE
> > + */
> > +int libertas_process_rx_command(wlan_private * priv)
> > +{
>
> This function is incredibly long, to the point where it gets
> unreadable.
Moved the switch() to an inline function, that should make it much more
readable.
> > +static struct dentry *libertas_dir = NULL;
> > +static const int big_buffer_len = 4096;
> > +static char big_buffer[4096];
> > +static DECLARE_MUTEX(big_buffer_sem);
>
> This seems to provide a generalized interface for buffering debugfs
> files. Have you considered using the existing simple_attribute
> and seq_file interfaces instead?
>
> Even if they don't work for this, I would consider it cleaner to
> use get_zeroed_page/free_page instead of the global buffer here.
Borrowed the idea from bcm43xx, but yeah, I agree that using
get_zeroed_page/free_page is cleaner and safer.
Done.
> > +static struct file_operations libertas_devinfo_fops = {
> > + .owner = THIS_MODULE,
> > + .open = open_file_generic,
> > + .write = write_file_dummy,
> > + .read = libertas_dev_info,
> > +};
> > +
> > +static struct file_operations libertas_getscantable_fops = {
> > + .owner = THIS_MODULE,
> > + .open = open_file_generic,
> > + .write = write_file_dummy,
> > + .read = libertas_getscantable,
> > +};
> > +
> > +static struct file_operations libertas_sleepparams_fops = {
> > + .owner = THIS_MODULE,
> > + .open = open_file_generic,
> > + .write = libertas_sleepparams_write,
> > + .read = libertas_sleepparams_read,
> > +};
>
> I would guess you can better express this with some array, like
>
> #define FOPS(read, write) { \
> .owner = THIS_MODULE, \
> .open = open_file_generic, \
> .read = (read), \
> .write = (write), \
> }
>
> struct libertas_debugfs_files {
> char *name;
> int perm;
> struct file_operations fops;
> } debugfs_files = {
> { "devinfo", 0444, FOPS(libertas_dev_info, NULL), },
> { "getscantable", 0444, FOPS(libertas_getscantable, NULL), },
> { "sleepparams", 0644, FOPS(libertas_sleepparams_read,
> libertas_sleepparams_write), },
> ...
> };
>
> > +void libertas_debugfs_init_one(wlan_private *priv, struct net_device *dev)
> > +{
> > + if (!libertas_dir)
> > + goto exit;
> > +
> > + priv->debugfs_dir = debugfs_create_dir(dev->name, libertas_dir);
> > + if (!priv->debugfs_dir)
> > + goto exit;
> > +
> > + priv->debugfs_devinfo = debugfs_create_file("info", 0444,
> > + priv->debugfs_dir,
> > + priv,
> > + &libertas_devinfo_fops);
>
> And then here do a loop over that array.
Done.
next prev parent reply other threads:[~2007-02-10 14:09 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-16 18:55 [PATCH] Marvell Libertas 8388 802.11b/g USB driver (v2) Marcelo Tosatti
2007-01-16 19:32 ` Arkadiusz Miskiewicz
2007-01-16 22:41 ` Dan Williams
2007-01-17 7:52 ` Johannes Berg
2007-01-17 18:42 ` Marcelo Tosatti
2007-01-17 23:06 ` Christoph Hellwig
2007-01-18 15:41 ` Dan Williams
2007-01-18 22:40 ` Christoph Hellwig
2007-01-18 22:54 ` Jon Smirl
2007-01-19 3:29 ` Dan Williams
2007-01-19 3:27 ` Dan Williams
2007-01-17 13:11 ` Jiri Benc
2007-01-17 15:01 ` Dan Williams
2007-01-17 15:18 ` Johannes Berg
2007-01-17 17:43 ` Dan Williams
2007-01-17 18:00 ` Dan Williams
2007-01-17 23:09 ` Christoph Hellwig
2007-01-17 23:19 ` Jeff Garzik
2007-01-18 8:22 ` John W. Linville
2007-01-24 15:26 ` Marcelo Tosatti
2007-01-24 18:52 ` Dan Williams
2007-01-24 20:13 ` John W. Linville
2007-01-18 15:40 ` Dan Williams
2007-01-17 18:01 ` Johannes Berg
2007-01-22 11:26 ` Marcelo Tosatti
2007-01-22 15:20 ` Jon Smirl
2007-01-23 15:41 ` Johannes Berg
2007-01-23 16:18 ` Jon Smirl
2007-01-23 16:54 ` Johannes Berg
2007-01-23 17:14 ` Jon Smirl
2007-01-23 17:38 ` Johannes Berg
2007-01-23 17:59 ` Dan Williams
2007-01-23 18:23 ` Jon Smirl
2007-01-23 18:30 ` Johannes Berg
2007-01-23 19:01 ` Jon Smirl
2007-01-23 19:13 ` Johannes Berg
2007-01-22 11:28 ` Marcelo Tosatti
2007-01-17 18:07 ` Jiri Benc
2007-01-18 15:43 ` Marcelo Tosatti
2007-01-17 15:43 ` Jiri Benc
2007-01-18 15:02 ` Marcelo Tosatti
2007-01-27 1:53 ` Arnd Bergmann
2007-02-03 22:43 ` Marcelo Tosatti
2007-02-05 14:01 ` John W. Linville
2007-02-05 15:12 ` Arnd Bergmann
2007-02-05 15:42 ` Christoph Hellwig
2007-02-06 22:42 ` Marcelo Tosatti
2007-02-10 14:05 ` Marcelo Tosatti [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-01-20 20:15 Marcelo Tosatti
2007-01-20 20:15 Marcelo Tosatti
2007-02-01 0:58 ` Marcelo Tosatti
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=20070210140529.GA3814@dmt.wfacil.com.br \
--to=marcelo@kvack.org \
--cc=acme@ghostprotocols.net \
--cc=arnd@arndb.de \
--cc=dcbw@redhat.com \
--cc=jgarzik@pobox.com \
--cc=linville@redhat.com \
--cc=mcgrof@gmail.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).