lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 20 Feb 2012 14:37:32 -0800
From:	Joe Perches <joe@...ches.com>
To:	Mugunthan V N <mugunthanvnm@...com>
Cc:	netdev@...r.kernel.org, davem@...emloft.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:
> 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);



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ