From patchwork Fri Mar 18 14:50:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1607097 X-Patchwork-Delegate: rfried.dev@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=uJhNIaA3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KKn502k7bz9s3q for ; Sat, 19 Mar 2022 01:51:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 20659839BD; Fri, 18 Mar 2022 15:50:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="uJhNIaA3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 846A6839BD; Fri, 18 Mar 2022 15:50:46 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 637728395D for ; Fri, 18 Mar 2022 15:50:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kabel@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1A03161AEC; Fri, 18 Mar 2022 14:50:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80E5AC340E8; Fri, 18 Mar 2022 14:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647615041; bh=cZ0mK/FKOjzp9gcWgy7l7RrEHJowi2AqErBSZKFfEVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uJhNIaA34nV9M+nkaqBaizAjuTyAKplf7qKkLG+TcaDF8/lohjSzN8pLQVyhpRCk/ LwG24GnwNv2wl7ze7djE8dwugeT9vh3eBIpSaim51+oIzpqk+2nTmcFoMFw+CpiPD7 ziQwdToZ8Xzn385CKhOoS1k3hvix6ixfT0NmBtK/k/LCxBvHhdMLwnuzDn686cD2JW Xn5neKg26S7xMxBnag478LxTP2UgRgMCZ/6Sc5tT9ffvtVAZl6zww1qqZkukUNOZyt vGPUaI2xiLiVHdUF2w/OW52FlmD67pnnEoU0nyzt/YMhn8uWrm586zoV4AwY85MWe3 FmJJkKLdRuoZw== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Joe Hershberger , Ramon Fried Cc: u-boot@lists.denx.de, =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH u-boot-net v2 02/14] net: mdio-uclass: use ARRAY_SIZE() Date: Fri, 18 Mar 2022 15:50:23 +0100 Message-Id: <20220318145035.10148-3-kabel@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220318145035.10148-1-kabel@kernel.org> References: <20220318145035.10148-1-kabel@kernel.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean From: Marek BehĂșn Use the ARRAY_SIZE() macro instead of hardcoding sizes of arrays in macros. Signed-off-by: Marek BehĂșn --- net/mdio-uclass.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c index 5735afe49e..649dc60f73 100644 --- a/net/mdio-uclass.c +++ b/net/mdio-uclass.c @@ -16,13 +16,12 @@ #include /* DT node properties for MAC-PHY interface */ -#define PHY_MODE_STR_CNT 2 -static const char * const phy_mode_str[PHY_MODE_STR_CNT] = { +static const char * const phy_mode_str[] = { "phy-mode", "phy-connection-type" }; + /* DT node properties that reference a PHY node */ -#define PHY_HANDLE_STR_CNT 3 -static const char * const phy_handle_str[PHY_HANDLE_STR_CNT] = { +static const char * const phy_handle_str[] = { "phy-handle", "phy", "phy-device" }; @@ -149,7 +148,7 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev, goto out; } - for (i = 0; i < PHY_HANDLE_STR_CNT; i++) + for (i = 0; i < ARRAY_SIZE(phy_handle_str); i++) if (!dev_read_phandle_with_args(ethdev, phy_handle_str[i], NULL, 0, 0, &phandle)) break; @@ -199,7 +198,7 @@ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev) } interface = PHY_INTERFACE_MODE_NONE; - for (i = 0; i < PHY_MODE_STR_CNT; i++) { + for (i = 0; i < ARRAY_SIZE(phy_mode_str); i++) { if_str = dev_read_string(ethdev, phy_mode_str[i]); if (if_str) { interface = phy_get_interface_by_name(if_str);