On 23 January 2017 at 13:20, Mathias Nyman <mathias.nyman@xxxxxxxxxxxxxxx> wrote: > From: Felipe Balbi <felipe.balbi@xxxxxxxxxxxxxxx> > > If we just provide a helper to convert completion code to string, we can > combine all debugging messages into a single print. > > [keep the old debug messages, for warn and grep -Mathias] > Signed-off-by: Felipe Balbi <felipe.balbi@xxxxxxxxxxxxxxx> > Signed-off-by: Mathias Nyman <mathias.nyman@xxxxxxxxxxxxxxx> > --- > drivers/usb/host/xhci.h | 80 +++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 80 insertions(+) > > diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h > index aa63e38..ebdd920 100644 > --- a/drivers/usb/host/xhci.h > +++ b/drivers/usb/host/xhci.h > @@ -1097,6 +1097,86 @@ struct xhci_transfer_event { > #define COMP_SECONDARY_BANDWIDTH_ERROR 35 > #define COMP_SPLIT_TRANSACTION_ERROR 36 > > +static inline const char *xhci_trb_comp_code_string(u8 status) > +{ BTW, maybe in the future we should use enum for status and next: #define C2S(x) case x: return #x static inline const char *xhci_trb_comp_code_string(enum xhci_trb_comp_code code) { switch(code) { C2S(COMP_INVALID); C2S(COMP_SUCCESS); ... default: return "Unknown!!"; } } #undef C2S After that in dbgmsg/trace we will have same enum and we don't need translate msg->enum while debugging. > + switch (status) { > + case COMP_INVALID: > + return "Invalid"; > + case COMP_SUCCESS: > + return "Success"; > + case COMP_DATA_BUFFER_ERROR: > + return "Data Buffer Error"; > + case COMP_BABBLE_DETECTED_ERROR: > + return "Babble Detected"; > + case COMP_USB_TRANSACTION_ERROR: > + return "USB Transaction Error"; > + case COMP_TRB_ERROR: > + return "TRB Error"; > + case COMP_STALL_ERROR: > + return "Stall Error"; > + case COMP_RESOURCE_ERROR: > + return "Resource Error"; > + case COMP_BANDWIDTH_ERROR: > + return "Bandwidth Error"; > + case COMP_NO_SLOTS_AVAILABLE_ERROR: > + return "No Slots Available Error"; > + case COMP_INVALID_STREAM_TYPE_ERROR: > + return "Invalid Stream Type Error"; > + case COMP_SLOT_NOT_ENABLED_ERROR: > + return "Slot Not Enabled Error"; > + case COMP_ENDPOINT_NOT_ENABLED_ERROR: > + return "Endpoint Not Enabled Error"; > + case COMP_SHORT_PACKET: > + return "Short Packet"; > + case COMP_RING_UNDERRUN: > + return "Ring Underrun"; > + case COMP_RING_OVERRUN: > + return "Ring Overrun"; > + case COMP_VF_EVENT_RING_FULL_ERROR: > + return "VF Event Ring Full Error"; > + case COMP_PARAMETER_ERROR: > + return "Parameter Error"; > + case COMP_BANDWIDTH_OVERRUN_ERROR: > + return "Bandwidth Overrun Error"; > + case COMP_CONTEXT_STATE_ERROR: > + return "Context State Error"; > + case COMP_NO_PING_RESPONSE_ERROR: > + return "No Ping Response Error"; > + case COMP_EVENT_RING_FULL_ERROR: > + return "Event Ring Full Error"; > + case COMP_INCOMPATIBLE_DEVICE_ERROR: > + return "Incompatible Device Error"; > + case COMP_MISSED_SERVICE_ERROR: > + return "Missed Service Error"; > + case COMP_COMMAND_RING_STOPPED: > + return "Command Ring Stopped"; > + case COMP_COMMAND_ABORTED: > + return "Command Aborted"; > + case COMP_STOPPED: > + return "Stopped"; > + case COMP_STOPPED_LENGTH_INVALID: > + return "Stopped - Length Invalid"; > + case COMP_STOPPED_SHORT_PACKET: > + return "Stopped - Short Packet"; > + case COMP_MAX_EXIT_LATENCY_TOO_LARGE_ERROR: > + return "Max Exit Latency Too Large Error"; > + case COMP_ISOCH_BUFFER_OVERRUN: > + return "Isoch Buffer Overrun"; > + case COMP_EVENT_LOST_ERROR: > + return "Event Lost Error"; > + case COMP_UNDEFINED_ERROR: > + return "Undefined Error"; > + case COMP_INVALID_STREAM_ID_ERROR: > + return "Invalid Stream ID Error"; > + case COMP_SECONDARY_BANDWIDTH_ERROR: > + return "Secondary Bandwidth Error"; > + case COMP_SPLIT_TRANSACTION_ERROR: > + return "Split Transaction Error"; > + default: > + return "Unknown!!"; > + } > +} > + > struct xhci_link_trb { > /* 64-bit segment pointer*/ > __le64 segment_ptr; > -- > 1.9.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html