netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Krzysztof Majzerowicz-Jaszcz <cristos@vipserv.org>
Cc: jeffrey.t.kirsher@intel.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers: net: ethernet: intel: e1000: e1000_ethtool.c coding style fixes
Date: Sat, 16 Aug 2014 11:41:29 -0700	[thread overview]
Message-ID: <1408214489.2683.87.camel@joe-AO725> (raw)
In-Reply-To: <1408180328-4827-1-git-send-email-cristos@vipserv.org>

On Sat, 2014-08-16 at 11:12 +0200, Krzysztof Majzerowicz-Jaszcz wrote:
> Fixed many errors/warnings and checks in e1000_ethtool.c reported by checkpatch.pl

Hello Krzysztof.

Just some trivial notes:

> diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
[]
> @@ -1,35 +1,30 @@
>  /*******************************************************************************
> -
> -  Intel PRO/1000 Linux driver
> -  Copyright(c) 1999 - 2006 Intel Corporation.
> -
> -  This program is free software; you can redistribute it and/or modify it
> -  under the terms and conditions of the GNU General Public License,
> -  version 2, as published by the Free Software Foundation.
[]
> + * Intel PRO/1000 Linux driver
> + *  Copyright(c) 1999 - 2006 Intel Corporation.
> + *
> + *  This program is free software; you can redistribute it and/or modify it
> + *  under the terms and conditions of the GNU General Public License,
> + *  version 2, as published by the Free Software Foundation.

There's odd space use after the * here.

I think it better to always use a single space not
one for the first line and two for subsequent lines.

> @@ -680,8 +676,8 @@ static bool reg_pattern_test(struct e1000_adapter *adapter, u64 *data, int reg,
>  			     u32 mask, u32 write)
>  {
>  	struct e1000_hw *hw = &adapter->hw;
> -	static const u32 test[] =
> -		{0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
> +	static const u32 test[] = {0x5A5A5A5A, 0xA5A5A5A5,
> +				   0x00000000, 0xFFFFFFFF};

Canonical form is
	struct foo bar[] = {
		...
	};
so
	static const u32 test[] = {
		0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF
	};

> @@ -792,10 +788,9 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
>  		REG_PATTERN_TEST(TDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
>  		REG_PATTERN_TEST(TIDV, 0x0000FFFF, 0x0000FFFF);
>  		value = E1000_RAR_ENTRIES;
> -		for (i = 0; i < value; i++) {
> -			REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF,
> -			                 0xFFFFFFFF);
> -		}
> +		for (i = 0; i < value; i++)
> +			REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2),
> +					 0x8003FFFF, 0xFFFFFFFF);

It's OK to keep the braces when a single statement
spans multiple lines.

> @@ -1397,7 +1390,7 @@ static int e1000_check_lbtest_frame(struct sk_buff *skb,
>  	frame_size &= ~1;
>  	if (*(skb->data + 3) == 0xFF) {
>  		if ((*(skb->data + frame_size / 2 + 10) == 0xBE) &&
> -		   (*(skb->data + frame_size / 2 + 12) == 0xAF)) {
> +		    (*(skb->data + frame_size / 2 + 12) == 0xAF)) {
>  			return 0;
>  		}
>  	}

Perhaps these would read better using [] indexing

	if (skb->data[3] == 0xff) {
		if (skb->data[frame_size / 2 + 10] == 0xbe &&
		    skb->data[frame_size / 2 + 12] == 0xaf) {

> @@ -1835,11 +1830,11 @@ static void e1000_get_ethtool_stats(struct net_device *netdev,
>  	for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
>  		switch (e1000_gstrings_stats[i].type) {
>  		case NETDEV_STATS:
> -			p = (char *) netdev +
> +			p = (char *)netdev +
>  					e1000_gstrings_stats[i].stat_offset;
>  			break;
>  		case E1000_STATS:
> -			p = (char *) adapter +
> +			p = (char *)adapter +
>  					e1000_gstrings_stats[i].stat_offset;
>  			brseak;
>  		}

Maybe use a temporary for &e1000_gstring_stats[i]

Something like: (w/ void * for char *, WARN_ONCE, trigraph->if/else)

static void e1000_get_ethtool_stats(struct net_device *netdev,
				    struct ethtool_stats *stats, u64 *data)
{
	struct e1000_adapter *adapter = netdev_priv(netdev);
	int i;
	void *p = NULL;
	const struct e1000_stats *stat = e1000_gstring_stats;

	e1000_update_stats(adapter);

	for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
		switch (stat->type) {
		case NETDEV_STATS:
			p = (void *)netdev + stat->stat_offset;
			break;
		case E1000_STATS:
			p = (void *)adapter + stat->stat_offset;
			break;
		default:
			WARN_ONCE(1, "Invalid E1000 stat type: %u index %d\n",
				  stat->type, i);
			break;
		}

		if (stat->sizeof_stat == sizeof(u64))
			data[i] = *(u64 *)p;
		else
			data[i] = *(u32 *)p;

		stat++;
	}
}

> @@ -1859,7 +1854,7 @@ static void e1000_get_strings(struct net_device *netdev, u32 stringset,
>  	switch (stringset) {
>  	case ETH_SS_TEST:
>  		memcpy(data, *e1000_gstrings_test,
> -			sizeof(e1000_gstrings_test));
> +		       sizeof(e1000_gstrings_test));

This fits in 80 columns on a single line.

		memcpy(data, *e1000_gstrings_test, sizeof(e1000_gstrings_test));

Not sure why there's what seems a superfluous * though.
Maybe:
		memcpy(data, e1000_gstrings_test, sizeof(e1000_gstrings_test));

  reply	other threads:[~2014-08-16 18:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-16  9:12 [PATCH] drivers: net: ethernet: intel: e1000: e1000_ethtool.c coding style fixes Krzysztof Majzerowicz-Jaszcz
2014-08-16 18:41 ` Joe Perches [this message]
2014-08-18 15:29   ` Alexander Duyck
2014-08-18 15:31     ` Joe Perches
2014-08-18 15:36       ` Krzysztof Majzerowicz-Jaszcz
2014-08-18 15:40         ` Joe Perches
2014-08-18 15:43           ` Krzysztof Majzerowicz-Jaszcz
2014-08-18 15:45       ` Alexander Duyck
2014-08-18 16:29         ` Joe Perches

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=1408214489.2683.87.camel@joe-AO725 \
    --to=joe@perches.com \
    --cc=cristos@vipserv.org \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).