From patchwork Wed Apr 8 06:41:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Hershberger X-Patchwork-Id: 459130 X-Patchwork-Delegate: sjg@chromium.org 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 DB271140082 for ; Wed, 8 Apr 2015 16:47:01 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 82937A74AD; Wed, 8 Apr 2015 08:46:06 +0200 (CEST) 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 7cWSS_u3iV81; Wed, 8 Apr 2015 08:46:06 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9BE32A74D5; Wed, 8 Apr 2015 08:45:27 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 22C05A7420 for ; Wed, 8 Apr 2015 08:43:34 +0200 (CEST) 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 ymOdwQPXhvQd for ; Wed, 8 Apr 2015 08:43:34 +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 ni.com (skprod3.natinst.com [130.164.80.24]) by theia.denx.de (Postfix) with ESMTPS id 17B9CA744D for ; Wed, 8 Apr 2015 08:43:27 +0200 (CEST) Received: from us-aus-mgwout2.amer.corp.natinst.com (nb-snip2-1338.natinst.com [130.164.19.135]) by us-aus-skprod3.natinst.com (8.15.0.59/8.15.0.59) with ESMTP id t386hQpO003899 for ; Wed, 8 Apr 2015 01:43:26 -0500 Received: from linux-xvxi.natinst.com ([130.164.14.198]) by us-aus-mgwout2.amer.corp.natinst.com (Lotus Domino Release 8.5.3FP6) with ESMTP id 2015040801432596-960400 ; Wed, 8 Apr 2015 01:43:25 -0500 From: Joe Hershberger To: u-boot@lists.denx.de Date: Wed, 8 Apr 2015 01:41:14 -0500 Message-Id: <1428475285-25836-15-git-send-email-joe.hershberger@ni.com> X-Mailer: git-send-email 1.7.11.5 In-Reply-To: <1428475285-25836-1-git-send-email-joe.hershberger@ni.com> References: <1428095695-23368-1-git-send-email-joe.hershberger@ni.com> <1428475285-25836-1-git-send-email-joe.hershberger@ni.com> X-MIMETrack: Itemize by SMTP Server on US-AUS-MGWOut2/AUS/H/NIC(Release 8.5.3FP6|November 21, 2013) at 04/08/2015 01:43:25 AM, Serialize by Router on US-AUS-MGWOut2/AUS/H/NIC(Release 8.5.3FP6|November 21, 2013) at 04/08/2015 01:43:26 AM, Serialize complete at 04/08/2015 01:43:26 AM X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2015-04-08_03:, , signatures=0 Cc: Joe Hershberger Subject: [U-Boot] [PATCH v2 14/25] net: cosmetic: Clean up CDP variables and functions X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Make a thorough pass through all variables and function names contained within cdp.c and remove CamelCase and improve naming. Signed-off-by: Joe Hershberger Acked-by: Simon Glass --- Changes in v2: None common/cmd_net.c | 17 +++++++------- include/net.h | 4 ++-- net/cdp.c | 70 ++++++++++++++++++++++++++------------------------------ net/cdp.h | 2 +- net/net.c | 2 +- 5 files changed, 46 insertions(+), 49 deletions(-) diff --git a/common/cmd_net.c b/common/cmd_net.c index 87c4ed1..1deebf2 100644 --- a/common/cmd_net.c +++ b/common/cmd_net.c @@ -290,18 +290,19 @@ static void cdp_update_env(void) { char tmp[16]; - if (CDPApplianceVLAN != htons(-1)) { - printf("CDP offered appliance VLAN %d\n", ntohs(CDPApplianceVLAN)); - VLAN_to_string(CDPApplianceVLAN, tmp); + if (cdp_appliance_vlan != htons(-1)) { + printf("CDP offered appliance VLAN %d\n", + ntohs(cdp_appliance_vlan)); + VLAN_to_string(cdp_appliance_vlan, tmp); setenv("vlan", tmp); - NetOurVLAN = CDPApplianceVLAN; + NetOurVLAN = cdp_appliance_vlan; } - if (CDPNativeVLAN != htons(-1)) { - printf("CDP offered native VLAN %d\n", ntohs(CDPNativeVLAN)); - VLAN_to_string(CDPNativeVLAN, tmp); + if (cdp_native_vlan != htons(-1)) { + printf("CDP offered native VLAN %d\n", ntohs(cdp_native_vlan)); + VLAN_to_string(cdp_native_vlan, tmp); setenv("nvlan", tmp); - NetOurNativeVLAN = CDPNativeVLAN; + NetOurNativeVLAN = cdp_native_vlan; } } diff --git a/include/net.h b/include/net.h index 1dc54ce..9343ade 100644 --- a/include/net.h +++ b/include/net.h @@ -512,8 +512,8 @@ extern struct in_addr net_ping_ip; /* the ip address to ping */ #if defined(CONFIG_CMD_CDP) /* when CDP completes these hold the return values */ -extern ushort CDPNativeVLAN; /* CDP returned native VLAN */ -extern ushort CDPApplianceVLAN; /* CDP returned appliance VLAN */ +extern ushort cdp_native_vlan; /* CDP returned native VLAN */ +extern ushort cdp_appliance_vlan; /* CDP returned appliance VLAN */ /* * Check for a CDP packet by examining the received MAC address field diff --git a/net/cdp.c b/net/cdp.c index 392437d..d8df3ea 100644 --- a/net/cdp.c +++ b/net/cdp.c @@ -36,17 +36,16 @@ const u8 net_cdp_ethaddr[6] = { 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc }; #define CDP_TIMEOUT 250UL /* one packet every 250ms */ -static int CDPSeq; -static int CDPOK; +static int cdp_seq; +static int cdp_ok; -ushort CDPNativeVLAN; -ushort CDPApplianceVLAN; +ushort cdp_native_vlan; +ushort cdp_appliance_vlan; -static const uchar CDP_SNAP_hdr[8] = { +static const uchar cdp_snap_hdr[8] = { 0xAA, 0xAA, 0x03, 0x00, 0x00, 0x0C, 0x20, 0x00 }; -static ushort -CDP_compute_csum(const uchar *buff, ushort len) +static ushort cdp_compute_csum(const uchar *buff, ushort len) { ushort csum; int odd; @@ -104,8 +103,7 @@ CDP_compute_csum(const uchar *buff, ushort len) return csum; } -static int -CDPSendTrigger(void) +static int cdp_send_trigger(void) { uchar *pkt; ushort *s; @@ -130,8 +128,8 @@ CDPSendTrigger(void) pkt += ETHER_HDR_SIZE; /* SNAP header */ - memcpy((uchar *)pkt, CDP_SNAP_hdr, sizeof(CDP_SNAP_hdr)); - pkt += sizeof(CDP_SNAP_hdr); + memcpy((uchar *)pkt, cdp_snap_hdr, sizeof(cdp_snap_hdr)); + pkt += sizeof(cdp_snap_hdr); /* CDP header */ *pkt++ = 0x02; /* CDP version 2 */ @@ -210,8 +208,8 @@ CDPSendTrigger(void) len = (uchar *)s - ((uchar *)net_tx_packet + ETHER_HDR_SIZE); et->et_protlen = htons(len); - len = ETHER_HDR_SIZE + sizeof(CDP_SNAP_hdr); - chksum = CDP_compute_csum((uchar *)net_tx_packet + len, + len = ETHER_HDR_SIZE + sizeof(cdp_snap_hdr); + chksum = cdp_compute_csum((uchar *)net_tx_packet + len, (uchar *)s - (net_tx_packet + len)); if (chksum == 0) chksum = 0xFFFF; @@ -221,19 +219,18 @@ CDPSendTrigger(void) return 0; } -static void -CDPTimeout(void) +static void cdp_timeout_handler(void) { - CDPSeq++; + cdp_seq++; - if (CDPSeq < 3) { - NetSetTimeout(CDP_TIMEOUT, CDPTimeout); - CDPSendTrigger(); + if (cdp_seq < 3) { + NetSetTimeout(CDP_TIMEOUT, cdp_timeout_handler); + cdp_send_trigger(); return; } /* if not OK try again */ - if (!CDPOK) + if (!cdp_ok) NetStartAgain(); else net_set_state(NETLOOP_SUCCESS); @@ -247,15 +244,15 @@ void cdp_receive(const uchar *pkt, unsigned len) ushort vlan, nvlan; /* minimum size? */ - if (len < sizeof(CDP_SNAP_hdr) + 4) + if (len < sizeof(cdp_snap_hdr) + 4) goto pkt_short; /* check for valid CDP SNAP header */ - if (memcmp(pkt, CDP_SNAP_hdr, sizeof(CDP_SNAP_hdr)) != 0) + if (memcmp(pkt, cdp_snap_hdr, sizeof(cdp_snap_hdr)) != 0) return; - pkt += sizeof(CDP_SNAP_hdr); - len -= sizeof(CDP_SNAP_hdr); + pkt += sizeof(cdp_snap_hdr); + len -= sizeof(cdp_snap_hdr); /* Version of CDP protocol must be >= 2 and TTL != 0 */ if (pkt[0] < 0x02 || pkt[1] == 0) @@ -269,7 +266,7 @@ void cdp_receive(const uchar *pkt, unsigned len) printf("**WARNING: CDP packet received with a protocol version " "%d > 2\n", pkt[0] & 0xff); - if (CDP_compute_csum(pkt, len) != 0) + if (cdp_compute_csum(pkt, len) != 0) return; pkt += 4; @@ -340,28 +337,27 @@ void cdp_receive(const uchar *pkt, unsigned len) } } - CDPApplianceVLAN = vlan; - CDPNativeVLAN = nvlan; + cdp_appliance_vlan = vlan; + cdp_native_vlan = nvlan; - CDPOK = 1; + cdp_ok = 1; return; - pkt_short: +pkt_short: printf("** CDP packet is too short\n"); return; } -void -CDPStart(void) +void cdp_start(void) { printf("Using %s device\n", eth_get_name()); - CDPSeq = 0; - CDPOK = 0; + cdp_seq = 0; + cdp_ok = 0; - CDPNativeVLAN = htons(-1); - CDPApplianceVLAN = htons(-1); + cdp_native_vlan = htons(-1); + cdp_appliance_vlan = htons(-1); - NetSetTimeout(CDP_TIMEOUT, CDPTimeout); + NetSetTimeout(CDP_TIMEOUT, cdp_timeout_handler); - CDPSendTrigger(); + cdp_send_trigger(); } diff --git a/net/cdp.h b/net/cdp.h index 95e4ce0..83475c9 100644 --- a/net/cdp.h +++ b/net/cdp.h @@ -14,7 +14,7 @@ #ifndef __CDP_H__ #define __CDP_H__ -void CDPStart(void); +void cdp_start(void); /* Process a received CDP packet */ void cdp_receive(const uchar *pkt, unsigned len); diff --git a/net/net.c b/net/net.c index a159432..3c8b608 100644 --- a/net/net.c +++ b/net/net.c @@ -412,7 +412,7 @@ restart: #endif #if defined(CONFIG_CMD_CDP) case CDP: - CDPStart(); + cdp_start(); break; #endif #if defined (CONFIG_NETCONSOLE) && !(CONFIG_SPL_BUILD)