netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 4/4] net: phy: sfp: Pretty print state machine events
Date: Tue,  7 Nov 2017 19:49:11 -0800	[thread overview]
Message-ID: <20171108034911.16382-5-f.fainelli@gmail.com> (raw)
In-Reply-To: <20171108034911.16382-1-f.fainelli@gmail.com>

Pretty print the entry and exit of the state machine by using human readable
strings.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/sfp.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 4 deletions(-)

diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index e4662bc58c01..8f938404e8ba 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -45,6 +45,18 @@ enum sfp_event_state {
 	SFP_E_TIMEOUT,
 };
 
+static const char *sfp_even_to_str[] = {
+	"insert",
+	"remove",
+	"device down",
+	"device up",
+	"TX fault",
+	"TX clear",
+	"LOS high",
+	"LOS low",
+	"timeout"
+};
+
 enum sfp_mod_state {
 	SFP_MOD_EMPTY = 0,
 	SFP_MOD_PROBE,
@@ -52,11 +64,23 @@ enum sfp_mod_state {
 	SFP_MOD_ERROR,
 };
 
+static const char *sfp_mod_state_to_str[] = {
+	"empty",
+	"probe",
+	"present",
+	"error",
+};
+
 enum sfp_dev_state {
 	SFP_DEV_DOWN = 0,
 	SFP_DEV_UP,
 };
 
+static const char *sfp_dev_state_to_str[] = {
+	"UP",
+	"DOWN",
+};
+
 enum sfp_sm_state {
 	SFP_S_DOWN = 0,
 	SFP_S_INIT,
@@ -67,6 +91,16 @@ enum sfp_sm_state {
 	SFP_S_TX_DISABLE,
 };
 
+static const char *sfp_state_to_str[] = {
+	"down",
+	"init",
+	"wait LOS",
+	"link UP",
+	"TX fault",
+	"re-initialization",
+	"TX disable",
+};
+
 static const char *gpio_of_names[] = {
 	"mod-def0",
 	"los",
@@ -502,8 +536,10 @@ static void sfp_sm_event(struct sfp *sfp, unsigned int event)
 {
 	mutex_lock(&sfp->sm_mutex);
 
-	dev_dbg(sfp->dev, "SM: enter %u:%u:%u event %u\n",
-		sfp->sm_mod_state, sfp->sm_dev_state, sfp->sm_state, event);
+	dev_dbg(sfp->dev, "SM: enter %s:%s:%s event: %s\n",
+		sfp_mod_state_to_str[sfp->sm_mod_state],
+		sfp_dev_state_to_str[sfp->sm_dev_state],
+		sfp_state_to_str[sfp->sm_state], sfp_even_to_str[event]);
 
 	/* This state machine tracks the insert/remove state of
 	 * the module, and handles probing the on-board EEPROM.
@@ -632,8 +668,10 @@ static void sfp_sm_event(struct sfp *sfp, unsigned int event)
 		break;
 	}
 
-	dev_dbg(sfp->dev, "SM: exit %u:%u:%u\n",
-		sfp->sm_mod_state, sfp->sm_dev_state, sfp->sm_state);
+	dev_dbg(sfp->dev, "SM: exit %s:%s:%s\n",
+		sfp_mod_state_to_str[sfp->sm_mod_state],
+		sfp_dev_state_to_str[sfp->sm_dev_state],
+		sfp_state_to_str[sfp->sm_state]);
 
 	mutex_unlock(&sfp->sm_mutex);
 }
-- 
2.14.1

      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 ` [PATCH net-next 3/4] net: phy: sfp: Separate enumerations and states Florian Fainelli
2017-11-08  8:58   ` Russell King - ARM Linux
2017-11-10  4:40     ` Florian Fainelli
2017-11-08  3:49 ` Florian Fainelli [this message]

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-5-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).