Message ID | 1398352186-4686-1-git-send-email-balbi@ti.com |
---|---|
State | New |
Headers | show |
> From: linux-usb-owner@vger.kernel.org [mailto:linux-usb-owner@vger.kernel.org] On Behalf Of Felipe Balbi > Sent: Thursday, April 24, 2014 8:10 AM > > this makes it slightly easier to read link state > change interrupt logs. > > Signed-off-by: Felipe Balbi <balbi@ti.com> > --- > drivers/usb/dwc3/gadget.c | 39 ++++++++++++++++++++++++++++++++++++++- > 1 file changed, 38 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c > index f0dc0ee..a8cf87b 100644 > --- a/drivers/usb/dwc3/gadget.c > +++ b/drivers/usb/dwc3/gadget.c > @@ -302,6 +302,42 @@ static const char *dwc3_gadget_ep_cmd_string(u8 cmd) > } > } > > +static const char *dwc3_gadget_link_string(enum dwc3_link_state link_state) > +{ > + switch (link_state) { > + case DWC3_LINK_STATE_U0: > + return "U0"; > + case DWC3_LINK_STATE_U1: > + return "U1"; > + case DWC3_LINK_STATE_U2: > + return "U2"; > + case DWC3_LINK_STATE_U3: > + return "U3"; > + case DWC3_LINK_STATE_SS_DIS: > + return "SS.Disabled"; > + case DWC3_LINK_STATE_RX_DET: > + return "RX.Detect"; Hi Felipe, For the non-obvious link states, could we have both the name and the number in the message perhaps? i.e. case DWC3_LINK_STATE_SS_DIS: return "SS.Disabled (4)"; case DWC3_LINK_STATE_RX_DET: return "RX.Detect (5)"; and so on. If I'm looking at the link state in a register and comparing it to the log, it helps if I don't have to look up the values in the databook ;)
On Thu, Apr 24, 2014 at 09:18:08PM +0000, Paul Zimmerman wrote: > > From: linux-usb-owner@vger.kernel.org [mailto:linux-usb-owner@vger.kernel.org] On Behalf Of Felipe Balbi > > Sent: Thursday, April 24, 2014 8:10 AM > > > > this makes it slightly easier to read link state > > change interrupt logs. > > > > Signed-off-by: Felipe Balbi <balbi@ti.com> > > --- > > drivers/usb/dwc3/gadget.c | 39 ++++++++++++++++++++++++++++++++++++++- > > 1 file changed, 38 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c > > index f0dc0ee..a8cf87b 100644 > > --- a/drivers/usb/dwc3/gadget.c > > +++ b/drivers/usb/dwc3/gadget.c > > @@ -302,6 +302,42 @@ static const char *dwc3_gadget_ep_cmd_string(u8 cmd) > > } > > } > > > > +static const char *dwc3_gadget_link_string(enum dwc3_link_state link_state) > > +{ > > + switch (link_state) { > > + case DWC3_LINK_STATE_U0: > > + return "U0"; > > + case DWC3_LINK_STATE_U1: > > + return "U1"; > > + case DWC3_LINK_STATE_U2: > > + return "U2"; > > + case DWC3_LINK_STATE_U3: > > + return "U3"; > > + case DWC3_LINK_STATE_SS_DIS: > > + return "SS.Disabled"; > > + case DWC3_LINK_STATE_RX_DET: > > + return "RX.Detect"; > > Hi Felipe, > > For the non-obvious link states, could we have both the name and the > number in the message perhaps? i.e. > > case DWC3_LINK_STATE_SS_DIS: > return "SS.Disabled (4)"; > case DWC3_LINK_STATE_RX_DET: > return "RX.Detect (5)"; > > and so on. > > If I'm looking at the link state in a register and comparing it to the > log, it helps if I don't have to look up the values in the databook ;) Sure, makes sense. ps: funny thing, when I was debugging this I was tired of looking at numbers because I always had to look at the Databook to figure out what they were :-p
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index f0dc0ee..a8cf87b 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -302,6 +302,42 @@ static const char *dwc3_gadget_ep_cmd_string(u8 cmd) } } +static const char *dwc3_gadget_link_string(enum dwc3_link_state link_state) +{ + switch (link_state) { + case DWC3_LINK_STATE_U0: + return "U0"; + case DWC3_LINK_STATE_U1: + return "U1"; + case DWC3_LINK_STATE_U2: + return "U2"; + case DWC3_LINK_STATE_U3: + return "U3"; + case DWC3_LINK_STATE_SS_DIS: + return "SS.Disabled"; + case DWC3_LINK_STATE_RX_DET: + return "RX.Detect"; + case DWC3_LINK_STATE_SS_INACT: + return "SS.Inactive"; + case DWC3_LINK_STATE_POLL: + return "Polling"; + case DWC3_LINK_STATE_RECOV: + return "Recovery"; + case DWC3_LINK_STATE_HRESET: + return "Hot Reset"; + case DWC3_LINK_STATE_CMPLY: + return "Compliance"; + case DWC3_LINK_STATE_LPBK: + return "Loopback"; + case DWC3_LINK_STATE_RESET: + return "Reset"; + case DWC3_LINK_STATE_RESUME: + return "Resume"; + default: + return "UNKNOWN link state\n"; + } +} + int dwc3_send_gadget_generic_command(struct dwc3 *dwc, int cmd, u32 param) { u32 timeout = 500; @@ -2468,7 +2504,8 @@ static void dwc3_gadget_linksts_change_interrupt(struct dwc3 *dwc, break; } - dev_vdbg(dwc->dev, "%s link %d\n", __func__, dwc->link_state); + dev_vdbg(dwc->dev, "%s link %s\n", __func__, + dwc3_gadget_link_string(dwc->link_state)); } static void dwc3_gadget_hibernation_interrupt(struct dwc3 *dwc,
this makes it slightly easier to read link state change interrupt logs. Signed-off-by: Felipe Balbi <balbi@ti.com> --- drivers/usb/dwc3/gadget.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-)