netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Riesch <christian.riesch@omicron.at>
To: Grant Grundler <grundler@chromium.org>
Cc: netdev@vger.kernel.org, Oliver Neukum <oneukum@suse.de>,
	Eric Dumazet <edumazet@google.com>,
	Allan Chou <allan@asix.com.tw>, Mark Lord <kernel@teksavvy.com>,
	Ming Lei <tom.leiming@gmail.com>,
	Michael Riesch <michael@riesch.at>
Subject: Re: [PATCH 4/4] asix: Add a new driver for the AX88172A
Date: Mon, 9 Jul 2012 12:22:11 +0200	[thread overview]
Message-ID: <CABkLObon+CkLJagu2pX0OBGpNzSn9NfyM353h2BQ68viy2Bq6Q@mail.gmail.com> (raw)
In-Reply-To: <CANEJEGu3iTDYJD+ZpcwgRCZTF8a_bi9kWSuKK4eaHzS1uL+ZxA@mail.gmail.com>

Grant,

On Fri, Jul 6, 2012 at 11:20 PM, Grant Grundler <grundler@chromium.org> wrote:
> On Fri, Jul 6, 2012 at 4:33 AM, Christian Riesch
> <christian.riesch@omicron.at> wrote:
>> The Asix AX88172A is a USB 2.0 Ethernet interface that supports both an
>> internal PHY as well as an external PHY (connected via MII).
>>
>> This patch adds a driver for the AX88172A and provides support for
>> both modes and supports phylib.
>
> Christian,
> In general this looks fine to me...but I wouldn't know about "bus
> identifier life times" (Ben Hutchings comment).
>
> My nit pick is the declaration and of use_embdphy. An alternative
> coding _suggestion_ below.  I'm not substantially altering the
> functionality.
>
> thanks,
> grant

[...]

>> +
>> +struct ax88172a_private {
>> +       int use_embdphy;
>
> Can you move the "int" to the end of the struct?
> It's cleaner to have fields "natively align". ie pointers should start
> at 8 byte alignments when compiled for 64-bit.
>
>> +       struct mii_bus *mdio;
>> +       struct phy_device *phydev;
>> +       char phy_name[20];
>> +       u16 phy_addr;
>> +       u16 oldmode;
>> +};
>> +

[...]

>> +       /* are we using the internal or the external phy? */
>> +       ret = asix_read_cmd(dev, AX_CMD_SW_PHY_STATUS, 0, 0, 1, buf);
>> +       if (ret < 0) {
>> +               dbg("Failed to read software interface selection register: %d",
>> +                   ret);
>> +               goto free;
>> +       }
>> +       dbg("AX_CMD_SW_PHY_STATUS = 0x%02x\n", buf[0]);
>> +       switch ((buf[0] & 0x0c) >> 2) {
>> +       case 0:
>> +               dbg("use internal phy\n");
>> +               priv->use_embdphy = 1;
>> +               break;
>> +       case 1:
>> +               dbg("use external phy\n");
>> +               priv->use_embdphy = 0;
>> +               break;
>> +       default:
>> +               dbg("Interface mode not supported by driver\n");
>> +               goto free;
>> +       }
>
> This switch statement inverts the existing logic. Much simpler code would be:
>     /* buf[0] & 0xc describes phy interface mode */
>     if (buf[0] &  8) {
>          dbg("Interface mode not supported by driver\n");
>          goto free;
>     }
>     priv->use_extphy = (buf[0] & 4) >> 2;
>

Thank your for your comments! I'll change that in the next version!
Regards, Christian

  reply	other threads:[~2012-07-09 10:22 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-06 11:33 [PATCH 0/4] Add a driver for the ASIX AX88172A Christian Riesch
2012-07-06 11:33 ` [PATCH 1/4] asix: Fix checkpatch warnings Christian Riesch
2012-07-06 11:58   ` Eric Dumazet
2012-07-06 12:02     ` David Miller
2012-07-06 21:43     ` Grant Grundler
2012-07-07  8:36       ` Eric Dumazet
2012-07-09  9:48         ` Christian Riesch
2012-07-06 15:25   ` Joe Perches
2012-07-06 11:33 ` [PATCH 2/4] asix: Rename asix.c to asix_devices.c Christian Riesch
2012-07-06 11:33 ` [PATCH 3/4] asix: Factor out common code Christian Riesch
2012-07-06 11:33 ` [PATCH 4/4] asix: Add a new driver for the AX88172A Christian Riesch
2012-07-06 17:37   ` Ben Hutchings
2012-07-08 15:39     ` Michael Riesch
2012-07-08 15:50       ` Ben Hutchings
2012-07-09 10:30       ` Christian Riesch
2012-07-11  8:27         ` Christian Riesch
2012-07-11 15:10           ` Christian Riesch
2012-07-11 19:23             ` Michael Riesch
2012-07-06 21:20   ` Grant Grundler
2012-07-09 10:22     ` Christian Riesch [this message]
2012-07-12  7:22       ` Christian Riesch
2012-07-12 23:10         ` Grant Grundler
2012-07-06 11:51 ` [PATCH 0/4] Add a driver for the ASIX AX88172A Christian Riesch
2012-07-09  2:38 ` ASIX Allan Email [office]
2012-07-09 10:18   ` Christian Riesch
2012-07-09 17:45 ` Grant Grundler
2012-07-09 22:27   ` Mark Lord
2012-07-10  2:20     ` ASIX Allan Email [office]

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=CABkLObon+CkLJagu2pX0OBGpNzSn9NfyM353h2BQ68viy2Bq6Q@mail.gmail.com \
    --to=christian.riesch@omicron.at \
    --cc=allan@asix.com.tw \
    --cc=edumazet@google.com \
    --cc=grundler@chromium.org \
    --cc=kernel@teksavvy.com \
    --cc=michael@riesch.at \
    --cc=netdev@vger.kernel.org \
    --cc=oneukum@suse.de \
    --cc=tom.leiming@gmail.com \
    /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).