RE: [PATCH v2 1/2] netdev: driver: ethernet: add cpsw address lookup engine support
From: N, Mugunthan V <hidden>
Date: 2012-02-22 16:43:17
Joe
-----Original Message----- From: Joe Perches [mailto:joe@perches.com] Sent: Tuesday, February 21, 2012 4:08 AM To: N, Mugunthan V Cc: netdev@vger.kernel.org; davem@davemloft.net Subject: Re: [PATCH v2 1/2] netdev: driver: ethernet: add cpsw address lookup engine support On Tue, 2012-02-21 at 00:07 +0530, Mugunthan V N wrote:quoted
TI CPSW ethernet switch has a built-in address lookup engine. Thispatch addsquoted
the code necessary for programming this module.just some style notes.quoted
diff --git a/drivers/net/ethernet/ti/cpsw_ale.cb/drivers/net/ethernet/ti/cpsw_ale.c []quoted
+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}quoted
+#define CTRL_UNK(name, shift, bits) {#name, ALE_UNKNOWNVLAN, 0,shift, \quoted
+ 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.
Agreed, will used named initializers also with embedding the index.
[]quoted
+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.
You mean kzalloc will provide a dump stack during allocation failure, if so I will remove the WARN_ON
quoted
diff --git a/drivers/net/ethernet/ti/cpsw_ale.hb/drivers/net/ethernet/ti/cpsw_ale.h []quoted
+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);
Yes, I will move the define outside struct definition in next set of patch set.
With regards Mugunthan V N