This series refactors f_loopback and f_tcm function drivers to use
automatic, scope-based cleanup mechansim for usb_request objects.
Specific considerations in each driver:
- In f_loopback.c, the shared buffer between in_req and out_req is
handled by nullifying in_req->buf before returning on usb_ep_queue
failure. This ensures the buffer is only freed once by the out_req
cleanup.
- In f_tcm.c, explicit nullification of request pointers in the f_uas
structure on error is no longer necessary. The pointers are now only
updated after all allocations within the respective functions
(bot_prepare_reqs, uasp_alloc_stream_res, uasp_alloc_cmd) succeed.
Existing cleanup functions handle any stale pointers if an error
occurs before the structure is updated.
Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
---
Kuen-Han Tsai (2):
usb: gadget: f_tcm: Use auto-cleanup for usb_request
usb: gadget: f_loopback: Use auto-cleanup for usb_request
drivers/usb/gadget/function/f_loopback.c | 30 +++----
drivers/usb/gadget/function/f_tcm.c | 141 +++++++++++++++----------------
2 files changed, 80 insertions(+), 91 deletions(-)
---
base-commit: dcb6fa37fd7bc9c3d2b066329b0d27dedf8becaa
change-id: 20251029-auto-cleanup-e0240f2d7f2a
Best regards,
--
Kuen-Han Tsai <khtsai@google.com>