From patchwork Tue Mar 29 20:08:33 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: 1610806 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=KrjHPKZ1; 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 4KSgdd3Xc0z9sDX for ; Wed, 30 Mar 2022 07:09:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D88058407E; Tue, 29 Mar 2022 22:09:27 +0200 (CEST) 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="KrjHPKZ1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0AD6F84056; Tue, 29 Mar 2022 22:08:57 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 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 ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::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 B10B983FE4 for ; Tue, 29 Mar 2022 22:08:53 +0200 (CEST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 57F1EB8162E; Tue, 29 Mar 2022 20:08:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 292F9C340ED; Tue, 29 Mar 2022 20:08:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648584532; bh=cZ0mK/FKOjzp9gcWgy7l7RrEHJowi2AqErBSZKFfEVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KrjHPKZ1e2zFKyvKeBvdt49iIrIjslcYXrDlGQ4/cBheD60EIuHmndboCaGKc9moa ix3zq+USwGZa5tn9g5hydPhYiBbNrxLw+iY6cSO3mZqsE7gAmHEvWAM6z9Onyv/HZL 87V0QVdGPQo3CZwpiTnEzdhPtCmLoYHL4BO0l/J/vcSAcxAVwghAovlw7+TPXAwr4A jKV4CGX5iTw1odDEZzPohg6syxfmjFwNLobK8q9vGByUV394TrmbhglS6/YnyeJQYI idvvHPcnlUj8LtDzS36rG/koI/OYYqfSCYFYJhNgcRRJV8j/KFPt8Ic7g9XdKp2Tq2 dkeQ9temkx4mg== 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 v3 02/14] net: mdio-uclass: use ARRAY_SIZE() Date: Tue, 29 Mar 2022 22:08:33 +0200 Message-Id: <20220329200845.13435-3-kabel@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220329200845.13435-1-kabel@kernel.org> References: <20220329200845.13435-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 Reviewed-by: Vladimir Oltean --- 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);