usb: udc: Add trace event for usb_gadget_set_state

While the userspace program can be notified of gadget state changes,
timing issue can lead to missed transitions when reading the state
value.

Introduce a trace event for usb_gadget_set_state to reliably track state
transitions.

Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
Link: https://lore.kernel.org/r/20250818082722.2952867-1-khtsai@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Kuen-Han Tsai 2025-08-18 16:27:19 +08:00 committed by Greg Kroah-Hartman
parent e77ee1d2a8
commit 7bf1158514
2 changed files with 6 additions and 0 deletions

@ -1125,6 +1125,7 @@ void usb_gadget_set_state(struct usb_gadget *gadget,
{
gadget->state = state;
schedule_work(&gadget->work);
trace_usb_gadget_set_state(gadget, 0);
}
EXPORT_SYMBOL_GPL(usb_gadget_set_state);

@ -81,6 +81,11 @@ DECLARE_EVENT_CLASS(udc_log_gadget,
__entry->ret)
);
DEFINE_EVENT(udc_log_gadget, usb_gadget_set_state,
TP_PROTO(struct usb_gadget *g, int ret),
TP_ARGS(g, ret)
);
DEFINE_EVENT(udc_log_gadget, usb_gadget_frame_number,
TP_PROTO(struct usb_gadget *g, int ret),
TP_ARGS(g, ret)