From: Joe Perches <joe@perches.com>
To: Po-Yu Chuang <ratbert.chuang@gmail.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
ratbert@faraday-tech.com, bhutchings@solarflare.com,
eric.dumazet@gmail.com, dilinger@queued.net
Subject: Re: [PATCH v2] net: add Faraday FTMAC100 10/100 Ethernet driver
Date: Mon, 17 Jan 2011 09:19:48 -0800 [thread overview]
Message-ID: <1295284788.21277.65.camel@Joe-Laptop> (raw)
In-Reply-To: <1295256060-2091-1-git-send-email-ratbert.chuang@gmail.com>
On Mon, 2011-01-17 at 17:21 +0800, Po-Yu Chuang wrote:
> From: Po-Yu Chuang <ratbert@faraday-tech.com>
> FTMAC100 Ethernet Media Access Controller supports 10/100 Mbps and
> MII. This driver has been working on some ARM/NDS32 SoC's including
> Faraday A320 and Andes AG101.
Hi again.
> Signed-off-by: Po-Yu Chuang <ratbert@faraday-tech.com>
> ---
> v2:
> always use NAPI
> do not use our own net_device_stats structure
> don't set trans_start and last_rx
> stats.rx_packets and stats.rx_bytes include dropped packets
> add missed netif_napi_del()
> initialize spinlocks in probe function
> remove rx_lock and hw_lock
> use netdev_[err/info/dbg] instead of dev_* ones
> use netdev_alloc_skb_ip_align()
> remove ftmac100_get_stats()
> use is_valid_ether_addr() instead of is_zero_ether_addr()
> add const to ftmac100_ethtool_ops and ftmac100_netdev_ops
> use net_ratelimit() instead of printk_ratelimit()
> no explicit inline
> use %pM to print MAC address
> add comment before wmb
> use napi poll() to handle all interrupts
This looks very clean, thanks for doing the rework.
Now the the really trivial...
> + * priveate data
private
> +static void ftmac100_enable_all_int(struct ftmac100 *priv)
> +{
> + unsigned int imr;
> +
> + imr = FTMAC100_INT_RPKT_FINISH | FTMAC100_INT_NORXBUF
> + | FTMAC100_INT_XPKT_OK | FTMAC100_INT_XPKT_LOST
> + | FTMAC100_INT_RPKT_LOST | FTMAC100_INT_AHB_ERR
> + | FTMAC100_INT_PHYSTS_CHG;
This could be a #define.
> + maccr = FTMAC100_MACCR_XMT_EN |
> + FTMAC100_MACCR_RCV_EN |
> + FTMAC100_MACCR_XDMA_EN |
> + FTMAC100_MACCR_RDMA_EN |
> + FTMAC100_MACCR_CRC_APD |
> + FTMAC100_MACCR_FULLDUP |
> + FTMAC100_MACCR_RX_RUNT |
> + FTMAC100_MACCR_RX_BROADPKT;
Here too.
> +static int ftmac100_rx_packet_error(struct ftmac100 *priv,
> + struct ftmac100_rxdes *rxdes)
[]
> + if (unlikely(ftmac100_rxdes_frame_too_long(rxdes))) {
> + if (net_ratelimit())
> + netdev_info(netdev, "rx frame too long\n");
> +
> + netdev->stats.rx_length_errors++;
> + error = 1;
> + }
> +
> + if (unlikely(ftmac100_rxdes_runt(rxdes))) {
else if ?
> +static int ftmac100_rx_packet(struct ftmac100 *priv, int *processed)
> +{
> + struct net_device *netdev = priv->netdev;
> + struct ftmac100_rxdes *rxdes;
> + struct sk_buff *skb;
> + int length;
> + int copied = 0;
> + int done = 0;
You could use bool/true/false here for copied and done
and all the other uses of an int for a logical bool.
> +static void ftmac100_txdes_set_dma_own(struct ftmac100_txdes *txdes)
> +{
> + /*
> + * Make sure dma own bit will not be set before any other
> + * descriptor fiels.
field/fields
> +static int ftmac100_mdio_read(struct net_device *netdev, int phy_id, int reg)
> +{
> + struct ftmac100 *priv = netdev_priv(netdev);
> + int phycr;
> + int i;
> +
> + phycr = FTMAC100_PHYCR_PHYAD(phy_id) |
> + FTMAC100_PHYCR_REGAD(reg) |
> + FTMAC100_PHYCR_MIIRD;
> +
> + iowrite32(phycr, priv->base + FTMAC100_OFFSET_PHYCR);
> + for (i = 0; i < 10; i++) {
> + phycr = ioread32(priv->base + FTMAC100_OFFSET_PHYCR);
> +
> + if ((phycr & FTMAC100_PHYCR_MIIRD) == 0)
> + return phycr & FTMAC100_PHYCR_MIIRDATA;
> +
> + usleep_range(100, 1000);
> + }
> +
> + netdev_err(netdev, "mdio read timed out\n");
> + return 0xffff;
0xffff is a rather odd return, perhaps a #define?
> +/******************************************************************************
> + * initialization / finalization
> + *****************************************************************************/
> +static int __init ftmac100_init(void)
> +{
> + printk(KERN_INFO "Loading " DRV_NAME ": version " DRV_VERSION " ...\n");
You could use
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
before any #include and
pr_info("Loading version " DRV_VERSION " ...\n");
One last comment on split long line indentation style
and long function declarations.
There's no required style so you can use what you are
most comfortable doing.
Most of drivers/net uses an alignment to open parenthesis
using maximal tabs and minimal necessary spaces instead of
an extra tabstop.
Like:
static int some_long_function(type var1, type var2...
type varN)
and
some_long_function(var1, var2, ...
varN);
not
static int some_long_function(type var1, type var2...
type varN)
and
some_long_function(var1, var2, ...
varN);
next prev parent reply other threads:[~2011-01-17 17:19 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-13 11:49 [PATCH] net: add Faraday FTMAC100 10/100 Ethernet driver Po-Yu Chuang
2011-01-13 14:03 ` Ben Hutchings
2011-01-14 5:37 ` Po-Yu Chuang
2011-01-13 14:22 ` Eric Dumazet
2011-01-13 16:29 ` Andres Salomon
2011-01-14 6:44 ` Po-Yu Chuang
2011-01-14 6:56 ` Po-Yu Chuang
2011-01-13 15:39 ` Joe Perches
2011-01-14 6:35 ` Po-Yu Chuang
[not found] ` <1294959948.4114.189.camel@Joe-Laptop>
2011-01-14 6:49 ` Po-Yu Chuang
2011-01-17 9:21 ` [PATCH v2] " Po-Yu Chuang
2011-01-17 17:19 ` Joe Perches [this message]
2011-01-19 9:40 ` Po-Yu Chuang
2011-01-19 12:46 ` Ben Hutchings
2011-01-19 16:41 ` Joe Perches
2011-01-20 5:30 ` Po-Yu Chuang
2011-01-20 8:46 ` Joe Perches
2011-01-17 17:29 ` Eric Dumazet
2011-01-17 18:58 ` Ben Hutchings
2011-01-17 20:39 ` Eric Dumazet
2011-01-17 18:21 ` Eric Dumazet
2011-01-18 3:08 ` Po-Yu Chuang
2011-01-19 9:20 ` Po-Yu Chuang
2011-01-20 15:30 ` [PATCH v3] " Po-Yu Chuang
2011-01-20 15:35 ` Eric Dumazet
2011-01-20 15:43 ` Po-Yu Chuang
2011-01-20 15:41 ` Eric Dumazet
2011-01-20 15:54 ` Po-Yu Chuang
2011-01-20 17:56 ` Joe Perches
2011-01-21 3:35 ` Po-Yu Chuang
2011-01-20 19:00 ` Joe Perches
2011-01-21 5:03 ` Po-Yu Chuang
[not found] ` <1295592411.6795.10.camel@Joe-Laptop>
2011-01-21 7:06 ` Po-Yu Chuang
2011-01-20 19:01 ` Michał Mirosław
2011-01-21 3:37 ` Po-Yu Chuang
2011-01-21 7:55 ` [PATCH v4] " Po-Yu Chuang
2011-01-21 9:08 ` Eric Dumazet
2011-01-24 8:07 ` Po-Yu Chuang
2011-01-21 12:26 ` Michał Mirosław
2011-01-24 8:26 ` Po-Yu Chuang
2011-01-24 20:22 ` Michał Mirosław
2011-01-25 2:46 ` Po-Yu Chuang
2011-02-01 3:56 ` Po-Yu Chuang
2011-02-01 4:35 ` David Miller
2011-02-24 7:27 ` Po-Yu Chuang
2011-02-24 7:51 ` David Miller
2011-02-24 8:07 ` Po-Yu Chuang
2011-02-24 8:22 ` Eric Dumazet
2011-02-24 9:29 ` [PATCH ref0] " Po-Yu Chuang
2011-02-24 17:39 ` Eric Dumazet
2011-02-24 17:48 ` Eric Dumazet
2011-02-25 2:32 ` Po-Yu Chuang
2011-02-25 9:45 ` Po-Yu Chuang
2011-02-25 10:52 ` Eric Dumazet
2011-02-25 18:34 ` David Miller
2011-02-25 18:45 ` Eric Dumazet
2011-02-25 18:47 ` Eric Dumazet
2011-03-01 5:45 ` Po-Yu Chuang
2011-03-01 5:53 ` Eric Dumazet
2011-02-25 9:57 ` [PATCH v6] " Po-Yu Chuang
2011-02-25 11:40 ` Eric Dumazet
2011-03-01 5:20 ` Po-Yu Chuang
2011-03-01 5:26 ` Eric Dumazet
2011-03-01 5:45 ` Eric Dumazet
2011-03-01 5:51 ` Po-Yu Chuang
2011-03-01 5:54 ` Eric Dumazet
2011-03-01 5:59 ` Eric Dumazet
2011-03-01 6:48 ` [PATCH] " Po-Yu Chuang
2011-03-01 7:27 ` Eric Dumazet
2011-03-03 20:19 ` David Miller
2011-02-24 18:43 ` [PATCH v4] " David Miller
2011-01-24 12:39 ` [PATCH v5] " Po-Yu Chuang
2011-01-24 15:07 ` Eric Dumazet
2011-01-25 2:46 ` Po-Yu Chuang
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=1295284788.21277.65.camel@Joe-Laptop \
--to=joe@perches.com \
--cc=bhutchings@solarflare.com \
--cc=dilinger@queued.net \
--cc=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=ratbert.chuang@gmail.com \
--cc=ratbert@faraday-tech.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