From: "John W. Linville" <linville@tuxdriver.com>
To: Michael Wu <flamingice@sourmilk.net>
Cc: Jeff Garzik <jeff@garzik.org>,
linux-wireless@vger.kernel.org,
David Miller <davem@davemloft.net>,
Andrea Merello <andrea.merello@gmail.com>
Subject: Re: [PATCH 2/2] Add rtl8187 wireless driver
Date: Mon, 14 May 2007 16:29:29 -0400 [thread overview]
Message-ID: <20070514202929.GD6999@tuxdriver.com> (raw)
In-Reply-To: <200705122156.43796.flamingice@sourmilk.net>
On Sat, May 12, 2007 at 09:56:39PM -0400, Michael Wu wrote:
> On Saturday 12 May 2007 15:18, John W. Linville wrote:
> > On Fri, May 11, 2007 at 04:02:18PM -0400, Michael Wu wrote:
> > > +void rtl8187_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data)
> > > +{
> > > + struct rtl8187_priv *priv = dev->priv;
> > > +
> > > + data <<= 8;
> > > + data |= addr | 0x80;
> > > +
> > > + rtl818x_iowrite8(priv, &priv->map->PHY[3], (data >> 24) & 0xFF);
> > > + rtl818x_iowrite8(priv, &priv->map->PHY[2], (data >> 16) & 0xFF);
> > > + rtl818x_iowrite8(priv, &priv->map->PHY[1], (data >> 8) & 0xFF);
> > > + rtl818x_iowrite8(priv, &priv->map->PHY[0], data & 0xFF);
> > > +
> > > + msleep(1);
> > > +}
> >
> > msleep seems better than mdelay, but why is it there at all? There is
> > no need to speculate. Just give us a comment for why you put it there,
> > even if it is "copied from app note" or somesuch.
> >
> Magic (copied from the original code). There are many magic seeming delays in
> the code.. why single this one out?
Not really singling it out. Anyway, see response to next block.
> > > + msleep(200);
> > > + rtl818x_iowrite8(priv, (u8 *)0xFE18, 0x10);
> > > + rtl818x_iowrite8(priv, (u8 *)0xFE18, 0x11);
> > > + rtl818x_iowrite8(priv, (u8 *)0xFE18, 0x00);
> > > + msleep(200);
> >
> > Please comment these magic delays too, and give us a symbolic constant
> > for the magic addres. Yes, "RTL8187_MAGIC_INIT_ADDR_1" is better than a
> > raw number. :-)
> >
> I can't say I agree on that. If it's just a number without any comments, it's
> most likely magic. I don't want to put in #defines for constants which are
> used once and merely serve the purpose of saying I don't know what it does.
> That is counterproductive IMHO.
If you don't know why it is there, how about a comment indicating
what gave you the notion of putting it there? E.g. "copied from
realtek example code" or somesuch?
For this block in particular, I think you had stated that the
hardware works without it. Is there any reason not to just remove it?
Just precaution?
> > More magic number tables of unknown origin...you get the idea. :-) I
> > realize that these are either copied straight from a datasheet or from
> > someone's reverse engineered sources -- let's just have a comment saying
> > so for each block of these.
> >
> The *entire* rtl8187_rtl8225.c file is full of magic numbers. I'm not willing
> to put comments saying so for every single function/definition. I really
> don't know what's going on in that file.
OK, "each block" would be excessive if they all come from the
same place. A single comment is probably fine. I do see "Based on
the r8187 driver" at the top, but more information would be better.
Since Andrea is still around maybe the origin of that information is
still identifiable?
> > > + __le32 TX_CONF;
> > > +#define RTL818X_TX_CONF_LOOPBACK_MAC (1 << 17)
> > > +#define RTL818X_TX_CONF_NO_ICV (1 << 19)
> > > +#define RTL818X_TX_CONF_DISCW (1 << 20)
> > > +#define RTL818X_TX_CONF_R8180_ABCD (2 << 25)
> > > +#define RTL818X_TX_CONF_R8180_F (3 << 25)
> > > +#define RTL818X_TX_CONF_R8185_ABC (4 << 25)
> > > +#define RTL818X_TX_CONF_R8185_D (5 << 25)
> > > +#define RTL818X_TX_CONF_HWVER_MASK (7 << 25)
> > > +#define RTL818X_TX_CONF_CW_MIN (1 << 31)
> >
> > Using an enum for a sparsely defined bitmask like this should let the
> > compiler identify if we misuse a bitmask in the wrong place.
> >
> How? Can you give an example?
--------------------------------------------------------------------------------
enum foo {
FOO_BIT_BLAH = (1 << 1),
FOO_BIT_BLECH = (1 << 2),
};
enum bar {
BAR_BIT_BLAH = (1 << 3),
BAR_BIT_BLECH = (1 << 4),
};
void blather(void)
{
enum foo drizzle;
drizzle = BAR_BIT_BLAH;
}
--------------------------------------------------------------------------------
[linville-t43.mobile]:> sparse example.c
example.c:15:12: warning: mixing different enum types
example.c:15:12: int [signed] enum bar versus
example.c:15:12: int [signed] enum foo
> > Do we lose the benefits of the __le32 typechecking by using an enum?
> > There is probably some way to force that...
> >
> Bitmasks and register offsets are rarely typechecked in the first place. Why
> does rtl8187 need to be so much better? I don't see any problem with the
> bitmask definitions in rtl8187, as the register name prefixes make it obvious
> what bits should go with which registers.
I don't know if I consider this a merge blocker. Still, if sparse can
help us find "thinko" bugs it would be better to enable it to do so.
Interdiff from the prior version also shows this:
@@ -485,25 +485,16 @@
rtl818x_iowrite8(priv, &priv->map->SIFS, 0x22);
- if (conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME)
+ if (conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME) {
rtl818x_iowrite8(priv, &priv->map->SLOT, 0x9);
- else
+ rtl818x_iowrite8(priv, &priv->map->DIFS, 0x14);
+ rtl818x_iowrite8(priv, &priv->map->EIFS, 91 - 0x14);
+ rtl818x_iowrite8(priv, &priv->map->CW_VAL, 0x73);
+ } else {
rtl818x_iowrite8(priv, &priv->map->SLOT, 0x14);
-
- switch (conf->phymode) {
- case MODE_IEEE80211B:
rtl818x_iowrite8(priv, &priv->map->DIFS, 0x24);
rtl818x_iowrite8(priv, &priv->map->EIFS, 91 - 0x24);
rtl818x_iowrite8(priv, &priv->map->CW_VAL, 0xa5);
- break;
- case MODE_IEEE80211G:
- rtl818x_iowrite8(priv, &priv->map->DIFS, 0x14);
- rtl818x_iowrite8(priv, &priv->map->EIFS, 91 - 0x14);
- rtl818x_iowrite8(priv, &priv->map->CW_VAL, 0x73);
- break;
- default:
- BUG();
- break;
}
rtl818x_iowrite16(priv, &priv->map->ATIM_WND, 2);
Which seems alright, but I wanted to make sure it was intentional.
John
--
John W. Linville
linville@tuxdriver.com
next prev parent reply other threads:[~2007-05-14 20:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20070511195642.8042.20407.stgit@panda.sourmilk.net>
2007-05-11 20:02 ` [PATCH 2/2] Add rtl8187 wireless driver Michael Wu
2007-05-12 19:18 ` John W. Linville
2007-05-13 1:56 ` Michael Wu
2007-05-13 10:07 ` Andrea Merello
2007-05-14 20:34 ` John W. Linville
2007-05-14 20:29 ` John W. Linville [this message]
2007-05-17 5:48 ` Michael Wu
2007-05-17 15:31 ` John W. Linville
2007-05-17 19:43 ` Luis R. Rodriguez
2007-05-17 20:41 ` Michael Buesch
2007-05-18 6:50 ` Michael Wu
[not found] <20070507073636.4232.93444.stgit@panda.sourmilk.net>
2007-05-07 7:46 ` Michael Wu
2007-05-07 8:15 ` Christoph Hellwig
2007-05-07 8:39 ` David Miller
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=20070514202929.GD6999@tuxdriver.com \
--to=linville@tuxdriver.com \
--cc=andrea.merello@gmail.com \
--cc=davem@davemloft.net \
--cc=flamingice@sourmilk.net \
--cc=jeff@garzik.org \
--cc=linux-wireless@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).