usb: dwc3: gadget: improve gcmd trace
Just like we did for endpoint commands, let's have a single trace output for the command and its status. This will improve trace readability Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
This commit is contained in:
parent
88811f7b72
commit
71f7e70270
@ -296,6 +296,20 @@ static inline const char *dwc3_ep_cmd_status_string(int status)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline const char *dwc3_gadget_generic_cmd_status_string(int status)
|
||||||
|
{
|
||||||
|
switch (status) {
|
||||||
|
case -ETIMEDOUT:
|
||||||
|
return "Timed Out";
|
||||||
|
case 0:
|
||||||
|
return "Successful";
|
||||||
|
case 1:
|
||||||
|
return "Error";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void dwc3_trace(void (*trace)(struct va_format *), const char *fmt, ...);
|
void dwc3_trace(void (*trace)(struct va_format *), const char *fmt, ...);
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_FS
|
#ifdef CONFIG_DEBUG_FS
|
||||||
|
@ -207,32 +207,30 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
|
|||||||
int dwc3_send_gadget_generic_command(struct dwc3 *dwc, unsigned cmd, u32 param)
|
int dwc3_send_gadget_generic_command(struct dwc3 *dwc, unsigned cmd, u32 param)
|
||||||
{
|
{
|
||||||
u32 timeout = 500;
|
u32 timeout = 500;
|
||||||
|
int status = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
u32 reg;
|
u32 reg;
|
||||||
|
|
||||||
trace_dwc3_gadget_generic_cmd(cmd, param);
|
|
||||||
|
|
||||||
dwc3_writel(dwc->regs, DWC3_DGCMDPAR, param);
|
dwc3_writel(dwc->regs, DWC3_DGCMDPAR, param);
|
||||||
dwc3_writel(dwc->regs, DWC3_DGCMD, cmd | DWC3_DGCMD_CMDACT);
|
dwc3_writel(dwc->regs, DWC3_DGCMD, cmd | DWC3_DGCMD_CMDACT);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
reg = dwc3_readl(dwc->regs, DWC3_DGCMD);
|
reg = dwc3_readl(dwc->regs, DWC3_DGCMD);
|
||||||
if (!(reg & DWC3_DGCMD_CMDACT)) {
|
if (!(reg & DWC3_DGCMD_CMDACT)) {
|
||||||
dwc3_trace(trace_dwc3_gadget,
|
status = DWC3_DGCMD_STATUS(reg);
|
||||||
"Command Complete --> %d",
|
if (status)
|
||||||
DWC3_DGCMD_STATUS(reg));
|
|
||||||
if (DWC3_DGCMD_STATUS(reg))
|
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (timeout--);
|
} while (timeout--);
|
||||||
|
|
||||||
if (!timeout) {
|
if (!timeout) {
|
||||||
dwc3_trace(trace_dwc3_gadget,
|
|
||||||
"Command Timed Out");
|
|
||||||
ret = -ETIMEDOUT;
|
ret = -ETIMEDOUT;
|
||||||
|
status = -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trace_dwc3_gadget_generic_cmd(cmd, param, status);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,25 +167,28 @@ DEFINE_EVENT(dwc3_log_request, dwc3_gadget_giveback,
|
|||||||
);
|
);
|
||||||
|
|
||||||
DECLARE_EVENT_CLASS(dwc3_log_generic_cmd,
|
DECLARE_EVENT_CLASS(dwc3_log_generic_cmd,
|
||||||
TP_PROTO(unsigned int cmd, u32 param),
|
TP_PROTO(unsigned int cmd, u32 param, int status),
|
||||||
TP_ARGS(cmd, param),
|
TP_ARGS(cmd, param, status),
|
||||||
TP_STRUCT__entry(
|
TP_STRUCT__entry(
|
||||||
__field(unsigned int, cmd)
|
__field(unsigned int, cmd)
|
||||||
__field(u32, param)
|
__field(u32, param)
|
||||||
|
__field(int, status)
|
||||||
),
|
),
|
||||||
TP_fast_assign(
|
TP_fast_assign(
|
||||||
__entry->cmd = cmd;
|
__entry->cmd = cmd;
|
||||||
__entry->param = param;
|
__entry->param = param;
|
||||||
|
__entry->status = status;
|
||||||
),
|
),
|
||||||
TP_printk("cmd '%s' [%d] param %08x",
|
TP_printk("cmd '%s' [%d] param %08x --> status: %s",
|
||||||
dwc3_gadget_generic_cmd_string(__entry->cmd),
|
dwc3_gadget_generic_cmd_string(__entry->cmd),
|
||||||
__entry->cmd, __entry->param
|
__entry->cmd, __entry->param,
|
||||||
|
dwc3_gadget_generic_cmd_status_string(__entry->status)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
DEFINE_EVENT(dwc3_log_generic_cmd, dwc3_gadget_generic_cmd,
|
DEFINE_EVENT(dwc3_log_generic_cmd, dwc3_gadget_generic_cmd,
|
||||||
TP_PROTO(unsigned int cmd, u32 param),
|
TP_PROTO(unsigned int cmd, u32 param, int status),
|
||||||
TP_ARGS(cmd, param)
|
TP_ARGS(cmd, param, status)
|
||||||
);
|
);
|
||||||
|
|
||||||
DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd,
|
DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user