From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Fainelli Subject: [PATCH net-next 4/4] net: phy: sfp: Pretty print state machine events Date: Tue, 7 Nov 2017 19:49:11 -0800 Message-ID: <20171108034911.16382-5-f.fainelli@gmail.com> References: <20171108034911.16382-1-f.fainelli@gmail.com> Cc: davem@davemloft.net, andrew@lunn.ch, rmk+kernel@armlinux.org.uk, Florian Fainelli To: netdev@vger.kernel.org Return-path: Received: from mail-ot0-f193.google.com ([74.125.82.193]:50023 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752642AbdKHDt0 (ORCPT ); Tue, 7 Nov 2017 22:49:26 -0500 Received: by mail-ot0-f193.google.com with SMTP id c47so1223172otj.6 for ; Tue, 07 Nov 2017 19:49:26 -0800 (PST) In-Reply-To: <20171108034911.16382-1-f.fainelli@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: Pretty print the entry and exit of the state machine by using human readable strings. Signed-off-by: Florian Fainelli --- 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