From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 604CEC433EF for ; Thu, 17 Mar 2022 12:52:16 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 505C383CEE; Thu, 17 Mar 2022 13:51: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="Bd+0NREJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AD45F83CF4; Thu, 17 Mar 2022 13:50:54 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (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 66F2082EBB for ; Thu, 17 Mar 2022 13:50:36 +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 4C8AB614F0; Thu, 17 Mar 2022 12:50:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 959B6C36AE2; Thu, 17 Mar 2022 12:50:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647521433; bh=gBADUNoS4pyENoMwJW18uAZRpZlRQys7x9YtU/jVmtw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bd+0NREJQj1G++rcc5KGbQ/5G3WTEgaLkkhqWo3X0BuzGcfbXfMKCmuxVd2c+Vc6/ 6CUIwQJsI/Te25fanKsbwz4c9RjqB/n/yws6kBgy8ZToYXou9Q893J4jTuy9gunXtP 5O4A5yd/RChMTiUiHXlskbPF8M4vcUlO4Heg6FaqgOzkyVZvvBV8nsj3EadNv/kchg xeEPpj9nfMs99tWqgnE/oThqLhw0yym2dBVIe661cIdwaNwxh2JtghiqLDeDoUTq3W UTD9pbl6RmrExSuAkMrUiWE1RjS4k8E6AKSjM2yYplIV6t+HOorh97ezH/w+fAuN15 mWzl+0VJ/6v5Q== From: =?UTF-8?q?Marek=20Beh=C3=BAn?= To: Joe Hershberger , Ramon Fried Cc: u-boot@lists.denx.de, =?UTF-8?q?Marek=20Beh=C3=BAn?= , Stefan Chulski , Stefan Roese , Vladimir Oltean Subject: [PATCH u-boot-net 10/14] phy: Move PHY_INTERFACE_MODE_NA to the beginning of the enum definition Date: Thu, 17 Mar 2022 13:49:54 +0100 Message-Id: <20220317124958.27921-11-kabel@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220317124958.27921-1-kabel@kernel.org> References: <20220317124958.27921-1-kabel@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Move PHY_INTERFACE_MODE_NA to the beginning of the enum definition to make it have zero value. This makes it possible (although not encouraged) to test for invalid/nonexistent interface mode with !val instead of val == PHY_INTERFACE_MODE_NA. The comment near the definition says "Must be last", because when the constant was introduced in commit 5f184715ecd3 ("Create PHY Lib for U-Boot"), it was used as the maximum value when interating over the constants. But this is no longer true - we use PHY_INTERFACE_MODE_MAX for that now, and so we can move it. Signed-off-by: Marek BehĂșn --- include/phy_interface.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/phy_interface.h b/include/phy_interface.h index 59e119a639..ce3b5004ec 100644 --- a/include/phy_interface.h +++ b/include/phy_interface.h @@ -13,6 +13,7 @@ #include typedef enum { + PHY_INTERFACE_MODE_NA, /* don't touch */ PHY_INTERFACE_MODE_MII, PHY_INTERFACE_MODE_GMII, PHY_INTERFACE_MODE_SGMII, @@ -39,12 +40,11 @@ typedef enum { PHY_INTERFACE_MODE_NCSI, PHY_INTERFACE_MODE_10GBASER, PHY_INTERFACE_MODE_USXGMII, - PHY_INTERFACE_MODE_NA, /* Must be last */ - PHY_INTERFACE_MODE_MAX, } phy_interface_t; static const char * const phy_interface_strings[] = { + [PHY_INTERFACE_MODE_NA] = "", [PHY_INTERFACE_MODE_MII] = "mii", [PHY_INTERFACE_MODE_GMII] = "gmii", [PHY_INTERFACE_MODE_SGMII] = "sgmii", @@ -71,7 +71,6 @@ static const char * const phy_interface_strings[] = { [PHY_INTERFACE_MODE_NCSI] = "NC-SI", [PHY_INTERFACE_MODE_10GBASER] = "10gbase-r", [PHY_INTERFACE_MODE_USXGMII] = "usxgmii", - [PHY_INTERFACE_MODE_NA] = "", }; /* Backplane modes: -- 2.34.1