[PATCH 0/3] usb: gadget: remove legacy g_target and its f_tcm hooks
From: Slawomir Stepien
Date: Thu Dec 03 2026 - 03:15:37 EST
This series removes the legacy g_target gadget driver (tcm_usb_gadget)
and the f_tcm code that existed only to support it, as discussed on v1
of the f_tcm TPG fixes:
https://lore.kernel.org/all/2026112324-trailside-hanky-1986@gregkh/
g_target is the only user of the dependent-module handling in f_tcm,
which pins the module with try_module_get()/module_put() while a TPG
exists, and of the tcm_register_callback/tcm_unregister_callback hooks.
The same gadget can be built with the configfs TCM function, which has
been available since v4.5. Patch 1 shows the equivalent configfs setup.
No defconfig enables CONFIG_USB_GADGET_TARGET.
1. Remove the g_target driver.
2. Drop the dependent-module support (has_dep, dependent,
try_module_get()/module_put()).
3. Call usbg_attach()/usbg_detach() directly instead of through the
callbacks, and remove them from struct f_tcm_opts.
This applies on top of the f_tcm TPG lifetime fixes (v2), which have not
been merged yet:
https://lore.kernel.org/all/20261123142513.204652-1-sst@xxxxxxxxx/
The base-commit and prerequisite-patch-id lines below identify that v2
series. The two series together apply cleanly to usb-next.
Tested on top of v2 with dummy_hcd, KASAN and lockdep:
- link the function before the TPG exists;
- rmdir of an enabled, bound TPG;
- recreate the TPG and rebind;
- rmdir of functions/tcm.0 while a TPG exists (-EBUSY).
No new warnings.
AI assistance: these patches, the changelogs and this cover letter were
written with Claude (claude-opus-5-5), which also ran the tests above.
Slawomir Stepien (3):
usb: gadget: legacy: remove the tcm_usb_gadget (g_target) driver
usb: gadget: f_tcm: drop dependent-module support
usb: gadget: f_tcm: call attach/detach directly instead of through
callbacks
drivers/usb/gadget/function/f_tcm.c | 81 +++-------
drivers/usb/gadget/function/u_tcm.h | 20 +--
drivers/usb/gadget/legacy/Kconfig | 12 --
drivers/usb/gadget/legacy/Makefile | 2 -
drivers/usb/gadget/legacy/tcm_usb_gadget.c | 173 ---------------------
5 files changed, 22 insertions(+), 266 deletions(-)
delete mode 100644 drivers/usb/gadget/legacy/tcm_usb_gadget.c
base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
prerequisite-patch-id: 19bf9bc67cbbdcbaa7414733bb961f376fe0e847
prerequisite-patch-id: 7f7d6361238d694c8229831d2e123e38d56c6f29
prerequisite-patch-id: 607e018c2241a10807fcc29ac4152bce400f2170
--
2.56.1