From: Joe Perches <joe@perches.com>
To: Masayuki Ohtake <masa-korg@dsn.okisemi.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
ML netdev <netdev@vger.kernel.org>,
Greg Rose <gregory.v.rose@intel.com>,
Maxime Bizon <mbizon@freebox.fr>,
Kristoffer Glembo <kristoffer@gaisler.com>,
Ralf Baechle <ralf@linux-mips.org>,
John Linn <john.linn@xilinx.com>,
Randy Dunlap <randy.dunlap@oracle.com>,
"David S. Miller" <davem@davemloft.net>,
MeeGo <meego-dev@meego.com>, "Wang, Qi" <qi.wang@intel.com>,
"Wang, Yong Y" <yong.y.wang@intel.com>,
Andrew <andrew.chih.howe.khor@intel.com>,
Intel OTC <joel.clark@intel.com>,
"Foster, Margie" <margie.foster@intel.com>,
Toshiharu Okada <okada533@dsn.okisemi.com>,
Tomoya Morinaga <morinaga526@dsn.okisemi.com>,
Takahiro Shimizu <shimizu394@dsn.okisemi.com>
Subject: Re: [PATCH] Gigabit Ethernet driver of Topcliff PCH
Date: Thu, 26 Aug 2010 07:44:30 -0700 [thread overview]
Message-ID: <1282833870.1875.52.camel@Joe-Laptop> (raw)
In-Reply-To: <4C763A67.5040107@dsn.okisemi.com>
On Thu, 2010-08-26 at 18:56 +0900, Masayuki Ohtake wrote:
> Gigabit Ethernet driver of Topcliff PCH
> +++ b/drivers/net/pch_gbe/pch_gbe.h
Just a few style comments
> +#undef FALSE
> +#define FALSE 0
> +#undef TRUE
> +#define TRUE 1
Perhaps better to use the kernel true/false.
> +#ifdef DEBUG
> +#define PCH_GBE_DEBUG(fmt, args...)\
> + printk(KERN_DEBUG KBUILD_MODNAME ": " fmt, ##args)
> +#else
> +#define PCH_GBE_DEBUG(fmt, args...) do { } while (0)
> +#endif
Better to use
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
and
pr_debug(fmt, ...);
[]
> +struct pch_gbe_functions {
> + void (*get_bus_info) (struct pch_gbe_hw *);
> + s32(*init_hw) (struct pch_gbe_hw *);
> + s32(*read_phy_reg) (struct pch_gbe_hw *, u32, u16 *);
Trivial: Inconsistent spacing (a few times)
Perhaps:
s32 (*read_phy_reg) etc...
> + s32(*write_phy_reg) (struct pch_gbe_hw *, u32, u16);
> + void (*reset_phy) (struct pch_gbe_hw *);
[]
> + s32(*read_mac_addr) (struct pch_gbe_hw *);
> +++ b/drivers/net/pch_gbe/pch_gbe_api.c
> @@ -0,0 +1,247 @@
[]
Convert all the
printk(KERN_<level> KBUILD_MODNAME ": " etc
to
pr_<level>(etc
> +#include "pch_gbe.h"
> +#include "pch_gbe_phy.h"
[]
> +static s32 pch_gbe_plat_init_hw(struct pch_gbe_hw *hw)
> +{
> + s32 ret_val;
> +
> + ret_val = pch_gbe_phy_get_id(hw);
> + if (ret_val) {
> + printk(KERN_ERR KBUILD_MODNAME ": "
> + "pch_gbe_phy_get_id error\n");
pr_err("pch_gbe_phy_get_id error\n");
> +inline s32 pch_gbe_hal_setup_init_funcs(struct pch_gbe_hw *hw)
> +{
> + if (hw->reg) {
> + pch_gbe_plat_init_function_pointers(hw);
> + return 0;
> + }
> + printk(KERN_ERR KBUILD_MODNAME ": " "ERROR: Registers not mapped\n");
pr_err("ERROR: Registers not mapped\n");
etc...
> + return -ENOSYS;
> +}
These are more commonly written as:
if (!fn_ptr) {
[ report_error_condition ]
return -ERRNO;
}
rtn = fn_ptr(foo);
if (rtn is err) {
[ report_error_condition ]
return -ERRNO2;
}
return 0;
For more complicated styles where some unwinding
is necessary
if (!fn_ptr) {
[ report_error_condition ]
err = -ERRNO;
goto out;
}
windup
rtn = fn_ptr(foo);
if (rtn is err) {
[ report_error_condition ]
err = ERRNO2
goto out2;
}
return 0;
outn:
..
out2:
unwind;
out:
return err;
> +
> +/**
> + * pch_gbe_hal_get_bus_info - Obtain bus information for adapter
> + * @hw: Pointer to the HW structure
> + */
> +inline void pch_gbe_hal_get_bus_info(struct pch_gbe_hw *hw)
> +{
> + if (hw->func.get_bus_info)
> + hw->func.get_bus_info(hw);
> + else
> + printk(KERN_ERR KBUILD_MODNAME ": " "Error: configuration\n");
pr_err("ERROR: configuration\n");
etc...
> +++ b/drivers/net/pch_gbe/pch_gbe_ethtool.c
[]
Add #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
before any include
> +#include <linux/pci.h>
> +#include <linux/ethtool.h>
[]
> +static int pch_gbe_get_settings(struct net_device *netdev,
> + struct ethtool_cmd *ecmd)
> +{
> + struct pch_gbe_adapter *adapter = netdev_priv(netdev);
> + int ret;
> +
> + PCH_GBE_DEBUG("ethtool: %s\n", __func__);
If you really want to track entering functions,
it might be better to use something like:
#define FUNC_ENTER() pr_devel("ethtool: %s enter\n", __func__)
#define FUNC_EXIT() pr_devel("ethtool: %s exit\n", __func__)
Unlike pr_debug, pr_devel does not remain active in
code when DEBUG is not #defined. Look up dynamic_debug.
> + PCH_GBE_DEBUG("hw->mac.addr : 0x%02x %02x %02x %02x %02x %02x\n",
> + hw->mac.addr[0], hw->mac.addr[1], hw->mac.addr[2],
> + hw->mac.addr[3], hw->mac.addr[4], hw->mac.addr[5]);
There's a vsprintf pointer extension "%pM" used for mac addresses
pr_debug("hw->mac.addr: %pM\n, hw->mac.addr);
etc.
next prev parent reply other threads:[~2010-08-26 14:44 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-26 9:56 [PATCH] Gigabit Ethernet driver of Topcliff PCH Masayuki Ohtake
2010-08-26 10:28 ` Sam Ravnborg
2010-08-26 12:47 ` Masayuki Ohtake
2010-08-26 14:44 ` Joe Perches [this message]
2010-08-26 15:34 ` Stephen Hemminger
2010-08-26 15:40 ` Stephen Hemminger
2010-08-26 15:41 ` Stephen Hemminger
2010-08-26 15:42 ` Stephen Hemminger
2010-08-26 15:43 ` Stephen Hemminger
2010-08-26 15:45 ` Stephen Hemminger
2010-08-26 15:47 ` Stephen Hemminger
2010-08-26 15:57 ` Stephen Hemminger
2010-08-26 16:05 ` Stephen Hemminger
2010-08-26 16:16 ` Joe Perches
2010-08-26 16:29 ` Stephen Hemminger
2010-08-26 17:02 ` Joe Perches
2010-08-31 14:15 ` Masayuki Ohtake
2010-08-31 14:51 ` Eric Dumazet
2010-09-02 12:39 ` Masayuki Ohtake
2010-09-02 13:40 ` Eric Dumazet
2010-09-02 15:10 ` Stephen Hemminger
2010-09-03 13:32 ` Masayuki Ohtake
2010-09-03 13:43 ` Eric Dumazet
2010-09-03 14:11 ` Masayuki Ohtake
2010-08-31 15:08 ` Randy Dunlap
2010-08-31 16:10 ` Joe Perches
2010-08-31 17:25 ` [PATCH] drivers/net/pch_gbe: Use bool not unsigned char Joe Perches
2010-08-31 18:38 ` [PATCH] drivers/net/pch_gbe: Cleanup stats use Joe Perches
2010-09-01 1:33 ` Stephen Hemminger
2010-09-01 1:38 ` Joe Perches
2010-09-03 2:23 ` [PATCH] Gigabit Ethernet driver of Topcliff PCH FUJITA Tomonori
2010-09-07 1:13 ` Masayuki Ohtake
2010-09-07 3:21 ` FUJITA Tomonori
2010-09-07 4:06 ` Masayuki Ohtake
-- strict thread matches above, loose matches on Subject: below --
2010-09-03 14:09 Masayuki Ohtake
2010-09-03 16:35 ` Jiri Slaby
2010-09-07 1:13 ` Masayuki Ohtake
2010-09-08 13:52 ` Masayuki Ohtake
2010-09-08 14:16 ` Jiri Slaby
2010-09-08 14:54 ` Stephen Hemminger
2010-09-08 14:55 ` Stephen Hemminger
2010-09-09 13:37 ` Masayuki Ohtake
2010-09-09 13:38 ` Masayuki Ohtake
2010-09-03 20:00 ` Joe Perches
2010-09-07 2:42 ` Masayuki Ohtake
2010-09-08 20:36 ` David Miller
2010-09-15 12:19 ` Masayuki Ohtake
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=1282833870.1875.52.camel@Joe-Laptop \
--to=joe@perches.com \
--cc=andrew.chih.howe.khor@intel.com \
--cc=davem@davemloft.net \
--cc=gregory.v.rose@intel.com \
--cc=joel.clark@intel.com \
--cc=john.linn@xilinx.com \
--cc=kristoffer@gaisler.com \
--cc=linux-kernel@vger.kernel.org \
--cc=margie.foster@intel.com \
--cc=masa-korg@dsn.okisemi.com \
--cc=mbizon@freebox.fr \
--cc=meego-dev@meego.com \
--cc=morinaga526@dsn.okisemi.com \
--cc=netdev@vger.kernel.org \
--cc=okada533@dsn.okisemi.com \
--cc=qi.wang@intel.com \
--cc=ralf@linux-mips.org \
--cc=randy.dunlap@oracle.com \
--cc=shimizu394@dsn.okisemi.com \
--cc=yong.y.wang@intel.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