From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, andrew@lunn.ch, rmk+kernel@armlinux.org.uk,
Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH net-next 3/4] net: phy: sfp: Separate enumerations and states
Date: Tue, 7 Nov 2017 19:49:10 -0800 [thread overview]
Message-ID: <20171108034911.16382-4-f.fainelli@gmail.com> (raw)
In-Reply-To: <20171108034911.16382-1-f.fainelli@gmail.com>
Create separate enumerations for the SFP physical state (computed from GPIOs),
device state, module state, and actual state machine. This will make it easier
to make sure the correct states are used, and also pretty print those to help
debugging.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/phy/sfp.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index dfb28b269687..e4662bc58c01 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -23,13 +23,17 @@ enum {
GPIO_TX_DISABLE,
GPIO_RATE_SELECT,
GPIO_MAX,
+};
+enum sfp_f_state {
SFP_F_PRESENT = BIT(GPIO_MODDEF0),
SFP_F_LOS = BIT(GPIO_LOS),
SFP_F_TX_FAULT = BIT(GPIO_TX_FAULT),
SFP_F_TX_DISABLE = BIT(GPIO_TX_DISABLE),
SFP_F_RATE_SELECT = BIT(GPIO_RATE_SELECT),
+};
+enum sfp_event_state {
SFP_E_INSERT = 0,
SFP_E_REMOVE,
SFP_E_DEV_DOWN,
@@ -39,15 +43,21 @@ enum {
SFP_E_LOS_HIGH,
SFP_E_LOS_LOW,
SFP_E_TIMEOUT,
+};
+enum sfp_mod_state {
SFP_MOD_EMPTY = 0,
SFP_MOD_PROBE,
SFP_MOD_PRESENT,
SFP_MOD_ERROR,
+};
+enum sfp_dev_state {
SFP_DEV_DOWN = 0,
SFP_DEV_UP,
+};
+enum sfp_sm_state {
SFP_S_DOWN = 0,
SFP_S_INIT,
SFP_S_WAIT_LOS,
@@ -115,9 +125,9 @@ struct sfp {
struct delayed_work poll;
struct delayed_work timeout;
struct mutex sm_mutex;
- unsigned char sm_mod_state;
- unsigned char sm_dev_state;
- unsigned short sm_state;
+ enum sfp_mod_state sm_mod_state;
+ enum sfp_dev_state sm_dev_state;
+ enum sfp_sm_state sm_state;
unsigned int sm_retries;
struct sfp_eeprom_id id;
--
2.14.1
next prev parent reply other threads:[~2017-11-08 3:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-08 3:49 [PATCH net-next 0/4] net: phy: sfp: Fixes and debugging improvements Florian Fainelli
2017-11-08 3:49 ` [PATCH net-next 1/4] net: phy: sfp: Do not reject soldered down modules Florian Fainelli
2017-11-08 11:15 ` Russell King - ARM Linux
2017-11-10 4:39 ` Florian Fainelli
2017-11-08 3:49 ` [PATCH net-next 2/4] net: phy: sfp: Use correct endian for sfp->id.ext.options Florian Fainelli
2017-11-08 8:56 ` Russell King - ARM Linux
2017-11-10 4:39 ` Florian Fainelli
2017-11-08 3:49 ` Florian Fainelli [this message]
2017-11-08 8:58 ` [PATCH net-next 3/4] net: phy: sfp: Separate enumerations and states Russell King - ARM Linux
2017-11-10 4:40 ` Florian Fainelli
2017-11-08 3:49 ` [PATCH net-next 4/4] net: phy: sfp: Pretty print state machine events Florian Fainelli
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=20171108034911.16382-4-f.fainelli@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=rmk+kernel@armlinux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).