public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Joe Hershberger <joe.hershberger@ni.com>,
	Ramon Fried <rfried.dev@gmail.com>
Cc: u-boot@lists.denx.de, "Marek Behún" <marek.behun@nic.cz>,
	"Stefan Roese" <sr@denx.de>
Subject: [PATCH u-boot-net v3 10/14] phy: Move PHY_INTERFACE_MODE_NA to the beginning of the enum definition
Date: Tue, 29 Mar 2022 22:08:41 +0200	[thread overview]
Message-ID: <20220329200845.13435-11-kabel@kernel.org> (raw)
In-Reply-To: <20220329200845.13435-1-kabel@kernel.org>

From: Marek Behún <marek.behun@nic.cz>

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 <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
---
 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 <string.h>
 
 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


  parent reply	other threads:[~2022-03-29 20:10 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29 20:08 [PATCH u-boot-net v3 00/14] u-boot-net refactors, fixes, cleanups Marek Behún
2022-03-29 20:08 ` [PATCH u-boot-net v3 01/14] net: mdio-uclass: fix type for phy_mode_str and phy_handle_str Marek Behún
2022-04-06 13:12   ` Vladimir Oltean
2022-03-29 20:08 ` [PATCH u-boot-net v3 02/14] net: mdio-uclass: use ARRAY_SIZE() Marek Behún
2022-04-06 13:13   ` Vladimir Oltean
2022-03-29 20:08 ` [PATCH u-boot-net v3 03/14] net: introduce helpers to get PHY ofnode from MAC Marek Behún
2022-03-29 20:08 ` [PATCH u-boot-net v3 04/14] net: mdio-uclass: add wrappers for read/write/reset operations Marek Behún
2022-04-06 13:14   ` Vladimir Oltean
2022-03-29 20:08 ` [PATCH u-boot-net v3 05/14] treewide: use dm_mdio_read/write/reset() wrappers Marek Behún
2022-04-06 13:15   ` Vladimir Oltean
2022-03-29 20:08 ` [PATCH u-boot-net v3 06/14] net: phy: fix parsing wrong property Marek Behún
2022-04-06 13:16   ` Vladimir Oltean
2022-03-29 20:08 ` [PATCH u-boot-net v3 07/14] net: introduce helpers to get PHY interface mode from a device/ofnode Marek Behún
2022-04-06 14:03   ` Patrice CHOTARD
2022-03-29 20:08 ` [PATCH u-boot-net v3 08/14] treewide: Rename PHY_INTERFACE_MODE_COUNT to PHY_INTERFACE_MODE_MAX Marek Behún
2022-04-06 13:22   ` Vladimir Oltean
2022-03-29 20:08 ` [PATCH u-boot-net v3 09/14] treewide: Rename PHY_INTERFACE_MODE_NONE to PHY_INTERFACE_MODE_NA Marek Behún
2022-04-06 13:24   ` Vladimir Oltean
2022-03-29 20:08 ` Marek Behún [this message]
2022-03-29 20:08 ` [PATCH u-boot-net v3 11/14] net: phy: xilinx: Check interface type in ->config(), not ->probe() Marek Behún
2022-03-29 20:08 ` [PATCH u-boot-net v3 12/14] net: phy: use ->is_c45 instead of is_10g_interface() Marek Behún
2022-03-29 20:08 ` [PATCH u-boot-net v3 13/14] bcmgenet, sun8i_emac: Don't connect PHY two times Marek Behún
2022-03-29 20:08 ` [PATCH u-boot-net v3 14/14] net: phy: don't require PHY interface mode during PHY creation Marek Behún
2022-04-06 13:38   ` Vladimir Oltean
2022-04-01 19:39 ` [PATCH u-boot-net v3 00/14] u-boot-net refactors, fixes, cleanups Ramon Fried

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220329200845.13435-11-kabel@kernel.org \
    --to=kabel@kernel.org \
    --cc=joe.hershberger@ni.com \
    --cc=marek.behun@nic.cz \
    --cc=rfried.dev@gmail.com \
    --cc=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox