From: Joe Perches <joe@perches.com>
To: Mugunthan V N <mugunthanvnm@ti.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net
Subject: Re: [PATCH v2 1/2] netdev: driver: ethernet: add cpsw address lookup engine support
Date: Mon, 20 Feb 2012 14:37:32 -0800 [thread overview]
Message-ID: <1329777452.8318.5.camel@joe2Laptop> (raw)
In-Reply-To: <1329763023-29580-2-git-send-email-mugunthanvnm@ti.com>
On Tue, 2012-02-21 at 00:07 +0530, Mugunthan V N wrote:
> TI CPSW ethernet switch has a built-in address lookup engine. This patch adds
> the code necessary for programming this module.
just some style notes.
> diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
[]
> +struct ale_control_info {
> + const char *name;
> + int offset, port_offset;
> + int shift, port_shift;
> + int bits;
> +};
> +
> +#define CTRL_GLOBAL(name, bit) {#name, ALE_CONTROL, 0, bit, 0, 1}
> +#define CTRL_UNK(name, shift, bits) {#name, ALE_UNKNOWNVLAN, 0, shift, \
> + 0, bits}
> +#define CTRL_PORTCTL(name, start, bits) {#name, ALE_PORTCTL, 4, start, 0, bits}
named initializers might be more readable,
embedding the index might be too.
[]
> +struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
> +{
> + struct cpsw_ale *ale;
> + int ret;
> +
> + ret = -ENOMEM;
> + ale = kzalloc(sizeof(*ale), GFP_KERNEL);
> + if (WARN_ON(!ale))
> + return NULL;
The WARN_ON is unnecessary. alloc failures get a dump_stack.
> diff --git a/drivers/net/ethernet/ti/cpsw_ale.h b/drivers/net/ethernet/ti/cpsw_ale.h
[]
> +struct cpsw_ale {
> + struct cpsw_ale_params params;
> + struct timer_list timer;
> + unsigned long ageout;
> + struct device_attribute ale_control_attr;
> +#define control_attr_to_ale(attr) \
> + container_of(attr, struct cpsw_ale, ale_control_attr);
> + struct device_attribute ale_table_attr;
> +#define table_attr_to_ale(attr) \
> + container_of(attr, struct cpsw_ale, ale_table_attr);
> +};
Embedding the #defines in a struct makes it difficult to read.
Perhaps this is simpler:
struct cpsw_ale {
struct cpsw_ale_params params;
struct timer_list timer;
unsigned long ageout;
struct device_attribute ale_control_attr;
struct device_attribute ale_table_attr;
};
#define control_attr_to_ale(attr) \
container_of(attr, struct cpsw_ale, ale_control_attr);
#define table_attr_to_ale(attr) \
container_of(attr, struct cpsw_ale, ale_table_attr);
next prev parent reply other threads:[~2012-02-20 22:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-20 18:37 [PATCH v2 0/2] Adding new TI Common Platform ethernet SWitch driver Mugunthan V N
2012-02-20 18:37 ` [PATCH v2 1/2] netdev: driver: ethernet: add cpsw address lookup engine support Mugunthan V N
2012-02-20 22:37 ` Joe Perches [this message]
2012-02-22 16:43 ` N, Mugunthan V
2012-02-20 18:37 ` [PATCH v2 2/2] netdev: driver: ethernet: Add TI CPSW driver Mugunthan V N
2012-02-20 23:03 ` Joe Perches
2012-02-22 16:43 ` N, Mugunthan V
2012-02-23 12:47 ` N, Mugunthan V
2012-02-23 15:46 ` Joe Perches
2012-02-23 16:38 ` Andy Whitcroft
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=1329777452.8318.5.camel@joe2Laptop \
--to=joe@perches.com \
--cc=davem@davemloft.net \
--cc=mugunthanvnm@ti.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