From patchwork Tue Mar 27 23:42:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Hershberger X-Patchwork-Id: 149113 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id F1E00B6EEB for ; Wed, 28 Mar 2012 15:34:18 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3003C282A7; Wed, 28 Mar 2012 06:33:06 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5aB2rBm3FNyO; Wed, 28 Mar 2012 06:33:05 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F13A928322; Wed, 28 Mar 2012 06:28:53 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4EDF228277 for ; Wed, 28 Mar 2012 02:48:06 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jbjxv7BJV55P for ; Wed, 28 Mar 2012 02:48:05 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from spamkiller05.natinst.com (mailserver5.natinst.com [130.164.80.5]) by theia.denx.de (Postfix) with ESMTP id 6F0D328276 for ; Wed, 28 Mar 2012 02:48:04 +0200 (CEST) Received: from mailserv58-us.natinst.com (nb-hsrp-1338.natinst.com [130.164.19.133]) by spamkiller05.natinst.com (8.14.4/8.14.4) with ESMTP id q2RNgOhb029424; Tue, 27 Mar 2012 18:42:24 -0500 Received: from localhost.localdomain ([130.164.14.197]) by mailserv58-us.natinst.com (Lotus Domino Release 8.5.2FP3) with ESMTP id 2012032718422449-1289253 ; Tue, 27 Mar 2012 18:42:24 -0500 From: Joe Hershberger To: u-boot@lists.denx.de Date: Tue, 27 Mar 2012 18:42:18 -0500 Message-Id: <1332891744-17250-5-git-send-email-joe.hershberger@ni.com> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1327020811-1538-1-git-send-email-joe.hershberger@ni.com> References: <1327020811-1538-1-git-send-email-joe.hershberger@ni.com> X-MIMETrack: Itemize by SMTP Server on MailServ58-US/AUS/H/NIC(Release 8.5.2FP3|July 10, 2011) at 03/27/2012 06:42:24 PM, Serialize by Router on MailServ58-US/AUS/H/NIC(Release 8.5.2FP3|July 10, 2011) at 03/27/2012 06:42:24 PM, Serialize complete at 03/27/2012 06:42:24 PM X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.6.7498, 1.0.260, 0.0.0000 definitions=2012-03-27_08:2012-03-27, 2012-03-27, 1970-01-01 signatures=0 X-Mailman-Approved-At: Wed, 28 Mar 2012 06:28:13 +0200 Cc: Joe Hershberger Subject: [U-Boot] [PATCH v2 04/10] net: cosmetic: eth.c checkpatch compliance X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Signed-off-by: Joe Hershberger Cc: Joe Hershberger Cc: Simon Glass Cc: Mike Frysinger --- Changes for v2: - Split into smaller patches net/eth.c | 67 +++++++++++++++++++++++++++++------------------------------- 1 files changed, 32 insertions(+), 35 deletions(-) diff --git a/net/eth.c b/net/eth.c index 1aba089..05afbd3 100644 --- a/net/eth.c +++ b/net/eth.c @@ -87,7 +87,7 @@ static struct { int length; } eth_rcv_bufs[PKTBUFSRX]; -static unsigned int eth_rcv_current = 0, eth_rcv_last = 0; +static unsigned int eth_rcv_current, eth_rcv_last; #endif static struct eth_device *eth_devices, *eth_current; @@ -139,11 +139,10 @@ struct eth_device *eth_get_dev_by_index(int index) return target_dev; } -int eth_get_dev_index (void) +int eth_get_dev_index(void) { - if (!eth_current) { + if (!eth_current) return -1; - } return eth_current->index; } @@ -175,7 +174,7 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name, if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) { if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) && - memcmp(dev->enetaddr, env_enetaddr, 6)) { + memcmp(dev->enetaddr, env_enetaddr, 6)) { printf("\nWarning: %s MAC addresses don't match:\n", dev->name); printf("Address in SROM is %pM\n", @@ -188,10 +187,9 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name, } if (dev->write_hwaddr && - !eth_mac_skip(eth_number) && - is_valid_ether_addr(dev->enetaddr)) { + !eth_mac_skip(eth_number) && + is_valid_ether_addr(dev->enetaddr)) ret = dev->write_hwaddr(dev); - } return ret; } @@ -199,7 +197,7 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name, int eth_register(struct eth_device *dev) { struct eth_device *d; - static int index = 0; + static int index; assert(strlen(dev->name) < sizeof(dev->name)); @@ -207,7 +205,7 @@ int eth_register(struct eth_device *dev) eth_current = eth_devices = dev; eth_current_changed(); } else { - for (d=eth_devices; d->next!=eth_devices; d=d->next) + for (d = eth_devices; d->next != eth_devices; d = d->next) ; d->next = dev; } @@ -277,36 +275,37 @@ int eth_initialize(bd_t *bis) printf("Net Initialization Skipped\n"); if (!eth_devices) { - puts ("No ethernet found.\n"); + puts("No ethernet found.\n"); bootstage_error(BOOTSTAGE_ID_NET_ETH_START); } else { struct eth_device *dev = eth_devices; - char *ethprime = getenv ("ethprime"); + char *ethprime = getenv("ethprime"); bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT); do { if (dev->index) - puts (", "); + puts(", "); printf("%s", dev->name); - if (ethprime && strcmp (dev->name, ethprime) == 0) { + if (ethprime && strcmp(dev->name, ethprime) == 0) { eth_current = dev; - puts (" [PRIME]"); + puts(" [PRIME]"); } if (strchr(dev->name, ' ')) - puts("\nWarning: eth device name has a space!\n"); + puts("\nWarning: eth device name has a space!" + "\n"); if (eth_write_hwaddr(dev, "eth", dev->index)) puts("\nWarning: failed to set MAC address\n"); dev = dev->next; num_devices++; - } while(dev != eth_devices); + } while (dev != eth_devices); eth_current_changed(); - putc ('\n'); + putc('\n'); } return num_devices; @@ -317,9 +316,9 @@ int eth_initialize(bd_t *bis) * mcast_addr: multicast ipaddr from which multicast Mac is made * join: 1=join, 0=leave. */ -int eth_mcast_join( IPaddr_t mcast_ip, u8 join) +int eth_mcast_join(IPaddr_t mcast_ip, u8 join) { - u8 mcast_mac[6]; + u8 mcast_mac[6]; if (!eth_current || !eth_current->mcast) return -1; mcast_mac[5] = htonl(mcast_ip) & 0xff; @@ -336,7 +335,7 @@ int eth_mcast_join( IPaddr_t mcast_ip, u8 join) * some other adapter -- hash tables */ #define CRCPOLY_LE 0xedb88320 -u32 ether_crc (size_t len, unsigned char const *p) +u32 ether_crc(size_t len, unsigned char const *p) { int i; u32 crc; @@ -363,7 +362,7 @@ int eth_init(bd_t *bis) struct eth_device *old_current, *dev; if (!eth_current) { - puts ("No ethernet found.\n"); + puts("No ethernet found.\n"); return -1; } @@ -383,7 +382,7 @@ int eth_init(bd_t *bis) do { debug("Trying %s\n", eth_current->name); - if (eth_current->init(eth_current,bis) >= 0) { + if (eth_current->init(eth_current, bis) >= 0) { eth_current->state = ETH_STATE_ACTIVE; return 0; @@ -471,38 +470,36 @@ int eth_receive(void *packet, int length) void eth_try_another(int first_restart) { - static struct eth_device *first_failed = NULL; + static struct eth_device *first_failed; char *ethrotate; /* * Do not rotate between network interfaces when * 'ethrotate' variable is set to 'no'. */ - if (((ethrotate = getenv ("ethrotate")) != NULL) && - (strcmp(ethrotate, "no") == 0)) + ethrotate = getenv("ethrotate"); + if ((ethrotate != NULL) && (strcmp(ethrotate, "no") == 0)) return; if (!eth_current) return; - if (first_restart) { + if (first_restart) first_failed = eth_current; - } eth_current = eth_current->next; eth_current_changed(); - if (first_failed == eth_current) { + if (first_failed == eth_current) NetRestartWrap = 1; - } } void eth_set_current(void) { - static char *act = NULL; - static int env_changed_id = 0; - struct eth_device* old_current; + static char *act; + static int env_changed_id; + struct eth_device *old_current; int env_id; if (!eth_current) /* XXX no current */ @@ -525,7 +522,7 @@ void eth_set_current(void) eth_current_changed(); } -char *eth_get_name (void) +char *eth_get_name(void) { - return (eth_current ? eth_current->name : "unknown"); + return eth_current ? eth_current->name : "unknown"; }