From patchwork Sat Jun 22 13:56:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 253415 X-Patchwork-Delegate: hs@denx.de 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 009232C042D for ; Sat, 22 Jun 2013 23:57:20 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 614204A124; Sat, 22 Jun 2013 15:57:18 +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 IEKGxObz2hne; Sat, 22 Jun 2013 15:57:18 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 13FF84A125; Sat, 22 Jun 2013 15:57:12 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 244374A125 for ; Sat, 22 Jun 2013 15:57:05 +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 fzSDsFnAKk3v for ; Sat, 22 Jun 2013 15:56:56 +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 mail-pb0-f51.google.com (mail-pb0-f51.google.com [209.85.160.51]) by theia.denx.de (Postfix) with ESMTPS id 2E9574A124 for ; Sat, 22 Jun 2013 15:56:47 +0200 (CEST) Received: by mail-pb0-f51.google.com with SMTP id um15so9020741pbc.10 for ; Sat, 22 Jun 2013 06:56:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:subject:from:to:cc:date:content-type:x-mailer :mime-version:content-transfer-encoding:x-gm-message-state; bh=5gokgvo9vNNGSheEHzOw3F47tgIwtXCdKXffZxfmQr8=; b=HNkBghMOKQfPCFae/EciAk6LNKCTdx9X7dfFzDoTH5CEE+VKn+QOf4Vr/AQ+UQ8bs6 T/ZSc6TKWuD6FbmDkc3M0qnZCru9Lp1v3X9UXkmUD1uWOcv7ykmf/2WXP3jrPpF8w80I LYakrYe7Q+7abO7xVeYTnBKU+KWbST883ieu2hyA68IDJdZjpd488enuND6HjFvRj+u2 /vaL2frVKpDQO+mJYc1ofzq/ueO0r414KafIYkozjEUaM35ioU0m8WUt13KgW/nck0PC 3a43xUX1T28sugdDulbdgJxSqT30Y6OcEhcMujmIWgnOAT+Zi0XaNM0styxNu7vqKwmw bIKA== X-Received: by 10.68.178.161 with SMTP id cz1mr16324128pbc.27.1371909406020; Sat, 22 Jun 2013 06:56:46 -0700 (PDT) Received: from [192.168.0.100] (218-173-173-121.dynamic.hinet.net. [218.173.173.121]) by mx.google.com with ESMTPSA id ve3sm9402126pbc.14.2013.06.22.06.56.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 22 Jun 2013 06:56:45 -0700 (PDT) Message-ID: <1371909395.8977.0.camel@phoenix> From: Axel Lin To: Marek Vasut Date: Sat, 22 Jun 2013 21:56:35 +0800 X-Mailer: Evolution 3.6.4-0ubuntu1 Mime-Version: 1.0 X-Gm-Message-State: ALoCoQnHFmT+P7FpMuGpsjqkCx2EzP6pWi7Pn22u4aCiUzvKtLrQhTzvmHO9wYtfL9SXbJj1DEs8 Cc: u-boot@lists.denx.de, Sean Paul , York Sun Subject: [U-Boot] [PATCH] cmd_i2c: Use ARRAY_SIZE instead of reinventing it 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: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Signed-off-by: Axel Lin Acked-by: Simon Glass --- common/cmd_i2c.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index 4380794..3215644 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -120,8 +120,6 @@ static uchar i2c_no_probes[] = CONFIG_SYS_I2C_NOPROBES; #define COMPARE_ADDR(a,i) (i2c_no_probes[(i)] == (a)) #define NO_PROBE_ADDR(i) i2c_no_probes[(i)] #endif /* CONFIG_MULTI_BUS */ - -#define NUM_ELEMENTS_NOPROBE (sizeof(i2c_no_probes)/sizeof(i2c_no_probes[0])) #endif #if defined(CONFIG_I2C_MUX) @@ -713,7 +711,7 @@ static int do_i2c_probe (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv #if defined(CONFIG_SYS_I2C_NOPROBES) skip = 0; - for (k=0; k < NUM_ELEMENTS_NOPROBE; k++) { + for (k = 0; k < ARRAY_SIZE(i2c_no_probes); k++) { if (COMPARE_BUS(bus, k) && COMPARE_ADDR(j, k)) { skip = 1; break; @@ -731,7 +729,7 @@ static int do_i2c_probe (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv #if defined(CONFIG_SYS_I2C_NOPROBES) puts ("Excluded chip addresses:"); - for (k=0; k < NUM_ELEMENTS_NOPROBE; k++) { + for (k = 0; k < ARRAY_SIZE(i2c_no_probes); k++) { if (COMPARE_BUS(bus,k)) printf(" %02X", NO_PROBE_ADDR(k)); }