From patchwork Wed Oct 20 05:06:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 71889 X-Patchwork-Delegate: wd@denx.de Return-Path: X-Original-To: wd@gemini.denx.de Delivered-To: wd@gemini.denx.de Received: from diddl.denx.de (diddl.denx.de [10.0.0.6]) by gemini.denx.de (Postfix) with ESMTP id 4C153136320 for ; Wed, 20 Oct 2010 07:07:43 +0200 (CEST) Received: from diddl.denx.de (localhost.localdomain [127.0.0.1]) by diddl.denx.de (Postfix) with ESMTP id 2D70D2000369 for ; Wed, 20 Oct 2010 07:07:43 +0200 (CEST) Received: from pop.mnet-online.de by diddl.denx.de with POP3 (fetchmail-6.3.17) for (single-drop); Wed, 20 Oct 2010 07:07:43 +0200 (CEST) Received: from murder ([192.168.8.180]) by backend2 (Cyrus v2.2.12) with LMTPA; Wed, 20 Oct 2010 07:07:34 +0200 X-Sieve: CMU Sieve 2.2 Received: from mail.m-online.net (localhost [127.0.0.1]) by frontend1.mail.m-online.net (Cyrus v2.2.12) with LMTPA; Wed, 20 Oct 2010 07:07:34 +0200 Received: from scanner-2.m-online.net (scanner-2.mail.m-online.net [192.168.8.166]) by mail.m-online.net (Postfix) with ESMTP id A7F221C0016F; Wed, 20 Oct 2010 07:07:34 +0200 (CEST) Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by mxin-1.m-online.net (Postfix) with ESMTP id A3D0A46C0B4; Wed, 20 Oct 2010 07:07:32 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6D88B280AC; Wed, 20 Oct 2010 07:07:29 +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 zwEjyoic3B4T; Wed, 20 Oct 2010 07:07:29 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3FC122809C; Wed, 20 Oct 2010 07:07:24 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 19CD628093 for ; Wed, 20 Oct 2010 07:07:20 +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 gGusIs8iTw-Q for ; Wed, 20 Oct 2010 07:07:18 +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 smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by theia.denx.de (Postfix) with ESMTPS id 06B6328091 for ; Wed, 20 Oct 2010 07:07:16 +0200 (CEST) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 970F41B402B; Wed, 20 Oct 2010 05:07:10 +0000 (UTC) From: Mike Frysinger To: u-boot@lists.denx.de, Ben Warren Date: Wed, 20 Oct 2010 01:06:48 -0400 Message-Id: <1287551208-22052-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.3.1 Subject: [U-Boot] [PATCH] cmd_mii: localize & constify local funcs/data X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 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 X-Virus-Scanned: by amavisd-new at m-online.net No need for these structures to be writable or global. While we're here, also drop local versions of the ARRAY_SIZE macro. Signed-off-by: Mike Frysinger --- common/cmd_mii.c | 68 +++++++++++++++++++++++------------------------------ 1 files changed, 30 insertions(+), 38 deletions(-) diff --git a/common/cmd_mii.c b/common/cmd_mii.c index 3ea493b..3fb0795 100644 --- a/common/cmd_mii.c +++ b/common/cmd_mii.c @@ -34,7 +34,7 @@ typedef struct _MII_reg_desc_t { char * name; } MII_reg_desc_t; -MII_reg_desc_t reg_0_5_desc_tbl[] = { +static const MII_reg_desc_t reg_0_5_desc_tbl[] = { { 0, "PHY control register" }, { 1, "PHY status register" }, { 2, "PHY ID 1 register" }, @@ -50,7 +50,7 @@ typedef struct _MII_field_desc_t { char * name; } MII_field_desc_t; -MII_field_desc_t reg_0_desc_tbl[] = { +static const MII_field_desc_t reg_0_desc_tbl[] = { { 15, 15, 0x01, "reset" }, { 14, 14, 0x01, "loopback" }, { 13, 6, 0x81, "speed selection" }, /* special */ @@ -63,7 +63,7 @@ MII_field_desc_t reg_0_desc_tbl[] = { { 5, 0, 0x3f, "(reserved)" } }; -MII_field_desc_t reg_1_desc_tbl[] = { +static const MII_field_desc_t reg_1_desc_tbl[] = { { 15, 15, 0x01, "100BASE-T4 able" }, { 14, 14, 0x01, "100BASE-X full duplex able" }, { 13, 13, 0x01, "100BASE-X half duplex able" }, @@ -82,17 +82,17 @@ MII_field_desc_t reg_1_desc_tbl[] = { { 0, 0, 0x01, "extended capabilities" }, }; -MII_field_desc_t reg_2_desc_tbl[] = { +static const MII_field_desc_t reg_2_desc_tbl[] = { { 15, 0, 0xffff, "OUI portion" }, }; -MII_field_desc_t reg_3_desc_tbl[] = { +static const MII_field_desc_t reg_3_desc_tbl[] = { { 15, 10, 0x3f, "OUI portion" }, { 9, 4, 0x3f, "manufacturer part number" }, { 3, 0, 0x0f, "manufacturer rev. number" }, }; -MII_field_desc_t reg_4_desc_tbl[] = { +static const MII_field_desc_t reg_4_desc_tbl[] = { { 15, 15, 0x01, "next page able" }, { 14, 14, 0x01, "reserved" }, { 13, 13, 0x01, "remote fault" }, @@ -107,7 +107,7 @@ MII_field_desc_t reg_4_desc_tbl[] = { { 4, 0, 0x1f, "xxx to do" }, }; -MII_field_desc_t reg_5_desc_tbl[] = { +static const MII_field_desc_t reg_5_desc_tbl[] = { { 15, 15, 0x01, "next page able" }, { 14, 14, 0x01, "acknowledge" }, { 13, 13, 0x01, "remote fault" }, @@ -121,39 +121,31 @@ MII_field_desc_t reg_5_desc_tbl[] = { { 5, 5, 0x01, "10BASE-T able" }, { 4, 0, 0x1f, "xxx to do" }, }; - -#define DESC0LEN (sizeof(reg_0_desc_tbl)/sizeof(reg_0_desc_tbl[0])) -#define DESC1LEN (sizeof(reg_1_desc_tbl)/sizeof(reg_1_desc_tbl[0])) -#define DESC2LEN (sizeof(reg_2_desc_tbl)/sizeof(reg_2_desc_tbl[0])) -#define DESC3LEN (sizeof(reg_3_desc_tbl)/sizeof(reg_3_desc_tbl[0])) -#define DESC4LEN (sizeof(reg_4_desc_tbl)/sizeof(reg_4_desc_tbl[0])) -#define DESC5LEN (sizeof(reg_5_desc_tbl)/sizeof(reg_5_desc_tbl[0])) - typedef struct _MII_field_desc_and_len_t { - MII_field_desc_t * pdesc; + const MII_field_desc_t *pdesc; ushort len; } MII_field_desc_and_len_t; -MII_field_desc_and_len_t desc_and_len_tbl[] = { - { reg_0_desc_tbl, DESC0LEN }, - { reg_1_desc_tbl, DESC1LEN }, - { reg_2_desc_tbl, DESC2LEN }, - { reg_3_desc_tbl, DESC3LEN }, - { reg_4_desc_tbl, DESC4LEN }, - { reg_5_desc_tbl, DESC5LEN }, +static const MII_field_desc_and_len_t desc_and_len_tbl[] = { + { reg_0_desc_tbl, ARRAY_SIZE(reg_0_desc_tbl) }, + { reg_1_desc_tbl, ARRAY_SIZE(reg_1_desc_tbl) }, + { reg_2_desc_tbl, ARRAY_SIZE(reg_2_desc_tbl) }, + { reg_3_desc_tbl, ARRAY_SIZE(reg_3_desc_tbl) }, + { reg_4_desc_tbl, ARRAY_SIZE(reg_4_desc_tbl) }, + { reg_5_desc_tbl, ARRAY_SIZE(reg_5_desc_tbl) }, }; static void dump_reg( ushort regval, - MII_reg_desc_t * prd, - MII_field_desc_and_len_t * pdl); + const MII_reg_desc_t *prd, + const MII_field_desc_and_len_t *pdl); static int special_field( ushort regno, - MII_field_desc_t * pdesc, + const MII_field_desc_t *pdesc, ushort regval); -void MII_dump_0_to_5( +static void MII_dump_0_to_5( ushort regvals[6], uchar reglo, uchar reghi) @@ -169,12 +161,12 @@ void MII_dump_0_to_5( static void dump_reg( ushort regval, - MII_reg_desc_t * prd, - MII_field_desc_and_len_t * pdl) + const MII_reg_desc_t *prd, + const MII_field_desc_and_len_t *pdl) { ulong i; ushort mask_in_place; - MII_field_desc_t * pdesc; + const MII_field_desc_t *pdesc; printf("%u. (%04hx) -- %s --\n", prd->regno, regval, prd->name); @@ -217,7 +209,7 @@ static void dump_reg( static int special_field( ushort regno, - MII_field_desc_t * pdesc, + const MII_field_desc_t *pdesc, ushort regval) { if ((regno == 0) && (pdesc->lo == 6)) { @@ -268,12 +260,12 @@ static int special_field( return 0; } -char last_op[2]; -uint last_data; -uint last_addr_lo; -uint last_addr_hi; -uint last_reg_lo; -uint last_reg_hi; +static char last_op[2]; +static uint last_data; +static uint last_addr_lo; +static uint last_addr_hi; +static uint last_reg_lo; +static uint last_reg_hi; static void extract_range( char * input, @@ -292,7 +284,7 @@ static void extract_range( } /* ---------------------------------------------------------------- */ -int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +static int do_mii(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { char op[2]; unsigned char addrlo, addrhi, reglo, reghi;