Linux USB
 help / color / mirror / Atom feed
* [PATCH 0/3] usb: gadget: remove legacy g_target and its f_tcm hooks
@ 2026-12-03  8:15 Slawomir Stepien
  2026-12-03  8:15 ` [PATCH 1/3] usb: gadget: legacy: remove the tcm_usb_gadget (g_target) driver Slawomir Stepien
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Slawomir Stepien @ 2026-12-03  8:15 UTC (permalink / raw)
  To: gregkh, bigeasy, nab; +Cc: Slawomir Stepien, linux-usb, linux-kernel

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@poczta.fm/

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] usb: gadget: legacy: remove the tcm_usb_gadget (g_target) driver
  2026-12-03  8:15 [PATCH 0/3] usb: gadget: remove legacy g_target and its f_tcm hooks Slawomir Stepien
@ 2026-12-03  8:15 ` Slawomir Stepien
  2026-12-03  8:15 ` [PATCH 2/3] usb: gadget: f_tcm: drop dependent-module support Slawomir Stepien
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Slawomir Stepien @ 2026-12-03  8:15 UTC (permalink / raw)
  To: gregkh, bigeasy, nab; +Cc: Slawomir Stepien, linux-usb, linux-kernel

The legacy g_target driver (tcm_usb_gadget.ko) builds a fixed USB
gadget with a single TCM function. It obtains the function instance
programmatically and registers a composite driver whenever its TPG is
enabled.

The same gadget can be set up with the configfs TCM function
(CONFIG_USB_CONFIGFS_F_TCM), which has been available since v4.5. The
legacy driver has had no functional changes since then, and no
defconfig enables it.

Keeping it requires f_tcm to support a second, non-configfs way of
attaching a function instance: a dependent module pinned with
try_module_get()/module_put() while a TPG exists, and attach/detach
callbacks set by the legacy driver. Remove the driver so that f_tcm
can drop that code in the following patches.

The equivalent configfs setup is:

  cd /sys/kernel/config/usb_gadget
  mkdir g1 && cd g1
  echo 0x0525 > idVendor; echo 0xa4a5 > idProduct
  mkdir strings/0x409 configs/c.1 functions/tcm.0
  echo "Target Manufacturer" > strings/0x409/manufacturer
  echo "Target Product" > strings/0x409/product
  printf '%012d' 1 > strings/0x409/serialnumber
  echo 0xc0 > configs/c.1/bmAttributes
  ln -s functions/tcm.0 configs/c.1/

followed by creating and enabling the TPG under
/sys/kernel/config/target/usb_gadget/ as with g_target, and writing
the UDC name to UDC. Unlike g_target, re-enabling a disabled TPG does
not re-attach the gadget; UDC has to be written again.

Signed-off-by: Slawomir Stepien <sst@poczta.fm>
---
 drivers/usb/gadget/legacy/Kconfig          |  12 --
 drivers/usb/gadget/legacy/Makefile         |   2 -
 drivers/usb/gadget/legacy/tcm_usb_gadget.c | 173 ---------------------
 3 files changed, 187 deletions(-)
 delete mode 100644 drivers/usb/gadget/legacy/tcm_usb_gadget.c

diff --git a/drivers/usb/gadget/legacy/Kconfig b/drivers/usb/gadget/legacy/Kconfig
index 0a7b382fbe27..629d923bc01d 100644
--- a/drivers/usb/gadget/legacy/Kconfig
+++ b/drivers/usb/gadget/legacy/Kconfig
@@ -276,18 +276,6 @@ config USB_MASS_STORAGE
 	  Say "y" to link the driver statically, or "m" to build
 	  a dynamically linked module called "g_mass_storage".
 
-config USB_GADGET_TARGET
-	tristate "USB Gadget Target Fabric Module"
-	depends on TARGET_CORE
-	select USB_LIBCOMPOSITE
-	select USB_F_TCM
-	help
-	  This fabric is an USB gadget. Two USB protocols are supported that is
-	  BBB or BOT (Bulk Only Transport) and UAS (USB Attached SCSI). BOT is
-	  advertised on alternative interface 0 (primary) and UAS is on
-	  alternative interface 1. Both protocols can work on USB2.0 and USB3.0.
-	  UAS utilizes the USB 3.0 feature called streams support.
-
 config USB_G_SERIAL
 	tristate "Serial Gadget (with CDC ACM and CDC OBEX support)"
 	depends on TTY
diff --git a/drivers/usb/gadget/legacy/Makefile b/drivers/usb/gadget/legacy/Makefile
index 4d864bf82799..aa69a58fcd00 100644
--- a/drivers/usb/gadget/legacy/Makefile
+++ b/drivers/usb/gadget/legacy/Makefile
@@ -23,7 +23,6 @@ g_nokia-y			:= nokia.o
 g_webcam-y			:= webcam.o
 g_ncm-y				:= ncm.o
 g_acm_ms-y			:= acm_ms.o
-g_tcm_usb_gadget-y		:= tcm_usb_gadget.o
 
 obj-$(CONFIG_USB_ZERO)		+= g_zero.o
 obj-$(CONFIG_USB_AUDIO)		+= g_audio.o
@@ -42,5 +41,4 @@ obj-$(CONFIG_USB_G_NOKIA)	+= g_nokia.o
 obj-$(CONFIG_USB_G_WEBCAM)	+= g_webcam.o
 obj-$(CONFIG_USB_G_NCM)		+= g_ncm.o
 obj-$(CONFIG_USB_G_ACM_MS)	+= g_acm_ms.o
-obj-$(CONFIG_USB_GADGET_TARGET)	+= tcm_usb_gadget.o
 obj-$(CONFIG_USB_RAW_GADGET)	+= raw_gadget.o
diff --git a/drivers/usb/gadget/legacy/tcm_usb_gadget.c b/drivers/usb/gadget/legacy/tcm_usb_gadget.c
deleted file mode 100644
index fc1e06246d9d..000000000000
--- a/drivers/usb/gadget/legacy/tcm_usb_gadget.c
+++ /dev/null
@@ -1,173 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Target based USB-Gadget
- *
- * UAS protocol handling, target callbacks, configfs handling,
- * BBB (USB Mass Storage Class Bulk-Only (BBB) and Transport protocol handling.
- *
- * Author: Sebastian Andrzej Siewior <bigeasy at linutronix dot de>
- */
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/string.h>
-#include <linux/configfs.h>
-#include <linux/ctype.h>
-#include <linux/usb/ch9.h>
-#include <linux/usb/composite.h>
-#include <linux/usb/gadget.h>
-#include <linux/usb/storage.h>
-#include <scsi/scsi_tcq.h>
-#include <target/target_core_base.h>
-#include <target/target_core_fabric.h>
-#include <linux/unaligned.h>
-
-#include "u_tcm.h"
-
-USB_GADGET_COMPOSITE_OPTIONS();
-
-#define UAS_VENDOR_ID	0x0525	/* NetChip */
-#define UAS_PRODUCT_ID	0xa4a5	/* Linux-USB File-backed Storage Gadget */
-
-static struct usb_device_descriptor usbg_device_desc = {
-	.bLength =		sizeof(usbg_device_desc),
-	.bDescriptorType =	USB_DT_DEVICE,
-	/* .bcdUSB = DYNAMIC */
-	.bDeviceClass =		USB_CLASS_PER_INTERFACE,
-	.idVendor =		cpu_to_le16(UAS_VENDOR_ID),
-	.idProduct =		cpu_to_le16(UAS_PRODUCT_ID),
-	.bNumConfigurations =   1,
-};
-
-#define USB_G_STR_CONFIG USB_GADGET_FIRST_AVAIL_IDX
-
-static struct usb_string	usbg_us_strings[] = {
-	[USB_GADGET_MANUFACTURER_IDX].s	= "Target Manufacturer",
-	[USB_GADGET_PRODUCT_IDX].s	= "Target Product",
-	[USB_GADGET_SERIAL_IDX].s	= "000000000001",
-	[USB_G_STR_CONFIG].s		= "default config",
-	{ },
-};
-
-static struct usb_gadget_strings usbg_stringtab = {
-	.language = 0x0409,
-	.strings = usbg_us_strings,
-};
-
-static struct usb_gadget_strings *usbg_strings[] = {
-	&usbg_stringtab,
-	NULL,
-};
-
-static struct usb_function_instance *fi_tcm;
-static struct usb_function *f_tcm;
-
-static int guas_unbind(struct usb_composite_dev *cdev)
-{
-	if (!IS_ERR_OR_NULL(f_tcm))
-		usb_put_function(f_tcm);
-
-	return 0;
-}
-
-static int tcm_do_config(struct usb_configuration *c)
-{
-	int status;
-
-	f_tcm = usb_get_function(fi_tcm);
-	if (IS_ERR(f_tcm))
-		return PTR_ERR(f_tcm);
-
-	status = usb_add_function(c, f_tcm);
-	if (status < 0) {
-		usb_put_function(f_tcm);
-		return status;
-	}
-
-	return 0;
-}
-
-static struct usb_configuration usbg_config_driver = {
-	.label                  = "Linux Target",
-	.bConfigurationValue    = 1,
-	.bmAttributes           = USB_CONFIG_ATT_SELFPOWER,
-};
-
-static int usbg_attach(struct usb_function_instance *f);
-static void usbg_detach(struct usb_function_instance *f);
-
-static int usb_target_bind(struct usb_composite_dev *cdev)
-{
-	int ret;
-
-	ret = usb_string_ids_tab(cdev, usbg_us_strings);
-	if (ret)
-		return ret;
-
-	usbg_device_desc.iManufacturer =
-		usbg_us_strings[USB_GADGET_MANUFACTURER_IDX].id;
-	usbg_device_desc.iProduct = usbg_us_strings[USB_GADGET_PRODUCT_IDX].id;
-	usbg_device_desc.iSerialNumber =
-		usbg_us_strings[USB_GADGET_SERIAL_IDX].id;
-	usbg_config_driver.iConfiguration =
-		usbg_us_strings[USB_G_STR_CONFIG].id;
-
-	ret = usb_add_config(cdev, &usbg_config_driver, tcm_do_config);
-	if (ret)
-		return ret;
-	usb_composite_overwrite_options(cdev, &coverwrite);
-	return 0;
-}
-
-static struct usb_composite_driver usbg_driver = {
-	.name           = "g_target",
-	.dev            = &usbg_device_desc,
-	.strings        = usbg_strings,
-	.max_speed      = USB_SPEED_SUPER,
-	.bind		= usb_target_bind,
-	.unbind         = guas_unbind,
-};
-
-static int usbg_attach(struct usb_function_instance *f)
-{
-	return usb_composite_probe(&usbg_driver);
-}
-
-static void usbg_detach(struct usb_function_instance *f)
-{
-	usb_composite_unregister(&usbg_driver);
-}
-
-static int __init usb_target_gadget_init(void)
-{
-	struct f_tcm_opts *tcm_opts;
-
-	fi_tcm = usb_get_function_instance("tcm");
-	if (IS_ERR(fi_tcm))
-		return PTR_ERR(fi_tcm);
-
-	tcm_opts = container_of(fi_tcm, struct f_tcm_opts, func_inst);
-	mutex_lock(&tcm_opts->dep_lock);
-	tcm_opts->tcm_register_callback = usbg_attach;
-	tcm_opts->tcm_unregister_callback = usbg_detach;
-	tcm_opts->dependent = THIS_MODULE;
-	tcm_opts->can_attach = true;
-	tcm_opts->has_dep = true;
-	mutex_unlock(&tcm_opts->dep_lock);
-
-	fi_tcm->set_inst_name(fi_tcm, "tcm-legacy");
-
-	return 0;
-}
-module_init(usb_target_gadget_init);
-
-static void __exit usb_target_gadget_exit(void)
-{
-	if (!IS_ERR_OR_NULL(fi_tcm))
-		usb_put_function_instance(fi_tcm);
-
-}
-module_exit(usb_target_gadget_exit);
-
-MODULE_AUTHOR("Sebastian Andrzej Siewior <bigeasy@linutronix.de>");
-MODULE_DESCRIPTION("usb-gadget fabric");
-MODULE_LICENSE("GPL v2");
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] usb: gadget: f_tcm: drop dependent-module support
  2026-12-03  8:15 [PATCH 0/3] usb: gadget: remove legacy g_target and its f_tcm hooks Slawomir Stepien
  2026-12-03  8:15 ` [PATCH 1/3] usb: gadget: legacy: remove the tcm_usb_gadget (g_target) driver Slawomir Stepien
@ 2026-12-03  8:15 ` Slawomir Stepien
  2026-12-03  8:15 ` [PATCH 3/3] usb: gadget: f_tcm: call attach/detach directly instead of through callbacks Slawomir Stepien
  2026-12-03  8:31 ` [PATCH 0/3] usb: gadget: remove legacy g_target and its f_tcm hooks sashiko-bot
  3 siblings, 0 replies; 5+ messages in thread
From: Slawomir Stepien @ 2026-12-03  8:15 UTC (permalink / raw)
  To: gregkh, bigeasy, nab; +Cc: Slawomir Stepien, linux-usb, linux-kernel

The dependent module was only used by the legacy g_target driver, which
had no configfs item that a TPG could depend on. Instead, f_tcm pinned
the g_target module with try_module_get() while a TPG existed, so the
function instance and the attach/detach callbacks it provided could not
go away underneath the TPG.

With g_target gone, every function instance is a configfs item, and the
TPG keeps it alive with configfs_depend_item_unlocked(). Remove
has_dep, dependent and the try_module_get()/module_put() calls.

usbg_drop_tpg() took dep_lock only to read has_dep, as
configfs_undepend_item_unlocked() just takes configfs_dirent_lock, so
drop dep_lock there. Update the kerneldoc of dep_lock and ready, which
still described the dependent module.

Signed-off-by: Slawomir Stepien <sst@poczta.fm>
---
 drivers/usb/gadget/function/f_tcm.c | 40 +++++++++--------------------
 drivers/usb/gadget/function/u_tcm.h | 10 ++------
 2 files changed, 14 insertions(+), 36 deletions(-)

diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c
index 469939a3329c..8f405f0a5cbd 100644
--- a/drivers/usb/gadget/function/f_tcm.c
+++ b/drivers/usb/gadget/function/f_tcm.c
@@ -1678,23 +1678,16 @@ static struct se_portal_group *usbg_make_tpg(struct se_wwn *wwn,
 	if (!READ_ONCE(opts->ready))
 		goto unlock_inst;
 
-	if (opts->has_dep) {
-		if (!try_module_get(opts->dependent))
-			goto unlock_inst;
-	} else {
-		/*
-		 * configfs_depend_item_unlocked() may acquire the configfs
-		 * root inode lock when the target belongs to a different
-		 * subsystem. Calling it under dep_lock would create a
-		 * circular dependency:
-		 *   dep_lock -> configfs inode lock -> su_mutex -> dep_lock
-		 */
-		ret = configfs_depend_item_unlocked(
-			wwn->wwn_group.cg_subsys,
-			&opts->func_inst.group.cg_item);
-		if (ret)
-			goto unlock_inst;
-	}
+	/*
+	 * configfs_depend_item_unlocked() may acquire the configfs root inode
+	 * lock when the target belongs to a different subsystem. Calling it
+	 * under dep_lock would create a circular dependency:
+	 *   dep_lock -> configfs inode lock -> su_mutex -> dep_lock
+	 */
+	ret = configfs_depend_item_unlocked(wwn->wwn_group.cg_subsys,
+					    &opts->func_inst.group.cg_item);
+	if (ret)
+		goto unlock_inst;
 
 	tpg = kzalloc_obj(struct usbg_tpg);
 	ret = -ENOMEM;
@@ -1729,10 +1722,7 @@ static struct se_portal_group *usbg_make_tpg(struct se_wwn *wwn,
 free_tpg:
 	kfree(tpg);
 unref_dep:
-	if (opts->has_dep)
-		module_put(opts->dependent);
-	else
-		configfs_undepend_item_unlocked(&opts->func_inst.group.cg_item);
+	configfs_undepend_item_unlocked(&opts->func_inst.group.cg_item);
 unlock_inst:
 	mutex_unlock(&tpg_instances_lock);
 
@@ -1765,13 +1755,7 @@ static void usbg_drop_tpg(struct se_portal_group *se_tpg)
 		opts = container_of(tpg_instances[i].func_inst,
 			struct f_tcm_opts, func_inst);
 		opts->tpg = NULL;
-		mutex_lock(&opts->dep_lock);
-		if (opts->has_dep)
-			module_put(opts->dependent);
-		else
-			configfs_undepend_item_unlocked(
-				&opts->func_inst.group.cg_item);
-		mutex_unlock(&opts->dep_lock);
+		configfs_undepend_item_unlocked(&opts->func_inst.group.cg_item);
 	}
 	mutex_unlock(&tpg_instances_lock);
 
diff --git a/drivers/usb/gadget/function/u_tcm.h b/drivers/usb/gadget/function/u_tcm.h
index 68ce03d3fb6f..93d3deb9a408 100644
--- a/drivers/usb/gadget/function/u_tcm.h
+++ b/drivers/usb/gadget/function/u_tcm.h
@@ -18,13 +18,9 @@
 struct usbg_tpg;
 
 /**
- * @dependent: optional dependent module. Meant for legacy gadget.
- * If non-null its refcount will be increased when a tpg is created and
- * decreased when tpg is dropped.
- * @dep_lock: lock for dependent module operations.
- * @ready: true if the dependent module information is set.
+ * @dep_lock: protects @can_attach.
+ * @ready: true once the function instance has been given a name.
  * @can_attach: true a function can be bound to gadget
- * @has_dep: true if there is a dependent module
  * @tpg: target portal group associated with this function instance. Set
  * when the TPG is created, before it can be enabled, and cleared after it
  * has been detached, so it never changes while the function is bound.
@@ -33,11 +29,9 @@ struct usbg_tpg;
 struct f_tcm_opts {
 	struct usb_function_instance	func_inst;
 	struct usbg_tpg			*tpg;
-	struct module			*dependent;
 	struct mutex			dep_lock;
 	bool				ready;
 	bool				can_attach;
-	bool				has_dep;
 
 	/*
 	 * Callbacks to be removed when legacy tcm gadget disappears.
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] usb: gadget: f_tcm: call attach/detach directly instead of through callbacks
  2026-12-03  8:15 [PATCH 0/3] usb: gadget: remove legacy g_target and its f_tcm hooks Slawomir Stepien
  2026-12-03  8:15 ` [PATCH 1/3] usb: gadget: legacy: remove the tcm_usb_gadget (g_target) driver Slawomir Stepien
  2026-12-03  8:15 ` [PATCH 2/3] usb: gadget: f_tcm: drop dependent-module support Slawomir Stepien
@ 2026-12-03  8:15 ` Slawomir Stepien
  2026-12-03  8:31 ` [PATCH 0/3] usb: gadget: remove legacy g_target and its f_tcm hooks sashiko-bot
  3 siblings, 0 replies; 5+ messages in thread
From: Slawomir Stepien @ 2026-12-03  8:15 UTC (permalink / raw)
  To: gregkh, bigeasy, nab; +Cc: Slawomir Stepien, linux-usb, linux-kernel

struct f_tcm_opts carried tcm_register_callback and
tcm_unregister_callback so that the legacy g_target driver could
register and unregister its own composite driver when a TPG was
enabled or disabled. As u_tcm.h noted, they were meant to go away
together with that driver.

Only the configfs implementations are left, so fold them into
usbg_attach() and usbg_detach() and remove the pointers. Attaching
cannot fail any more, so make usbg_attach() return void.

Signed-off-by: Slawomir Stepien <sst@poczta.fm>
---
 drivers/usb/gadget/function/f_tcm.c | 41 ++++++-----------------------
 drivers/usb/gadget/function/u_tcm.h | 10 -------
 2 files changed, 8 insertions(+), 43 deletions(-)

diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c
index 8f405f0a5cbd..bcd9a60589c5 100644
--- a/drivers/usb/gadget/function/f_tcm.c
+++ b/drivers/usb/gadget/function/f_tcm.c
@@ -1806,20 +1806,17 @@ static struct configfs_attribute *usbg_wwn_attrs[] = {
 	NULL,
 };
 
-static int usbg_attach(struct usbg_tpg *);
+static void usbg_attach(struct usbg_tpg *);
 static void usbg_detach(struct usbg_tpg *);
 
 static int usbg_enable_tpg(struct se_portal_group *se_tpg, bool enable)
 {
 	struct usbg_tpg  *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg);
-	int ret = 0;
 
 	if (enable)
-		ret = usbg_attach(tpg);
+		usbg_attach(tpg);
 	else
 		usbg_detach(tpg);
-	if (ret)
-		return ret;
 
 	tpg->gadget_connect = enable;
 
@@ -2616,20 +2613,20 @@ static void tcm_free_inst(struct usb_function_instance *f)
 	kfree(opts);
 }
 
-static int tcm_register_callback(struct usb_function_instance *f)
+static void usbg_attach(struct usbg_tpg *tpg)
 {
-	struct f_tcm_opts *opts = container_of(f, struct f_tcm_opts, func_inst);
+	struct f_tcm_opts *opts = container_of(tpg->fi, struct f_tcm_opts,
+					       func_inst);
 
 	mutex_lock(&opts->dep_lock);
 	opts->can_attach = true;
 	mutex_unlock(&opts->dep_lock);
-
-	return 0;
 }
 
-static void tcm_unregister_callback(struct usb_function_instance *f)
+static void usbg_detach(struct usbg_tpg *tpg)
 {
-	struct f_tcm_opts *opts = container_of(f, struct f_tcm_opts, func_inst);
+	struct f_tcm_opts *opts = container_of(tpg->fi, struct f_tcm_opts,
+					       func_inst);
 
 	mutex_lock(&opts->dep_lock);
 	opts->can_attach = false;
@@ -2639,26 +2636,6 @@ static void tcm_unregister_callback(struct usb_function_instance *f)
 	unregister_gadget_item(opts->func_inst.group.cg_item.ci_parent->ci_parent);
 }
 
-static int usbg_attach(struct usbg_tpg *tpg)
-{
-	struct usb_function_instance *f = tpg->fi;
-	struct f_tcm_opts *opts = container_of(f, struct f_tcm_opts, func_inst);
-
-	if (opts->tcm_register_callback)
-		return opts->tcm_register_callback(f);
-
-	return 0;
-}
-
-static void usbg_detach(struct usbg_tpg *tpg)
-{
-	struct usb_function_instance *f = tpg->fi;
-	struct f_tcm_opts *opts = container_of(f, struct f_tcm_opts, func_inst);
-
-	if (opts->tcm_unregister_callback)
-		opts->tcm_unregister_callback(f);
-}
-
 static int tcm_set_name(struct usb_function_instance *f, const char *name)
 {
 	struct f_tcm_opts *opts = container_of(f, struct f_tcm_opts, func_inst);
@@ -2696,8 +2673,6 @@ static struct usb_function_instance *tcm_alloc_inst(void)
 	mutex_init(&opts->dep_lock);
 	opts->func_inst.set_inst_name = tcm_set_name;
 	opts->func_inst.free_func_inst = tcm_free_inst;
-	opts->tcm_register_callback = tcm_register_callback;
-	opts->tcm_unregister_callback = tcm_unregister_callback;
 
 	config_group_init_type_name(&opts->func_inst.group, "",
 			&tcm_func_type);
diff --git a/drivers/usb/gadget/function/u_tcm.h b/drivers/usb/gadget/function/u_tcm.h
index 93d3deb9a408..c882acba8d3d 100644
--- a/drivers/usb/gadget/function/u_tcm.h
+++ b/drivers/usb/gadget/function/u_tcm.h
@@ -32,16 +32,6 @@ struct f_tcm_opts {
 	struct mutex			dep_lock;
 	bool				ready;
 	bool				can_attach;
-
-	/*
-	 * Callbacks to be removed when legacy tcm gadget disappears.
-	 *
-	 * If you use the new function registration interface
-	 * programmatically, you MUST set these callbacks to
-	 * something sensible (e.g. probe/remove the composite).
-	 */
-	int (*tcm_register_callback)(struct usb_function_instance *);
-	void (*tcm_unregister_callback)(struct usb_function_instance *);
 };
 
 #endif /* U_TCM_H */
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] usb: gadget: remove legacy g_target and its f_tcm hooks
  2026-12-03  8:15 [PATCH 0/3] usb: gadget: remove legacy g_target and its f_tcm hooks Slawomir Stepien
                   ` (2 preceding siblings ...)
  2026-12-03  8:15 ` [PATCH 3/3] usb: gadget: f_tcm: call attach/detach directly instead of through callbacks Slawomir Stepien
@ 2026-12-03  8:31 ` sashiko-bot
  3 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-12-03  8:31 UTC (permalink / raw)
  To: Slawomir Stepien; +Cc: linux-usb

Sashiko has reviewed this 3-patch series and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203081505.1336691-1-sst@poczta.fm

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-03  8:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03  8:15 [PATCH 0/3] usb: gadget: remove legacy g_target and its f_tcm hooks Slawomir Stepien
2026-12-03  8:15 ` [PATCH 1/3] usb: gadget: legacy: remove the tcm_usb_gadget (g_target) driver Slawomir Stepien
2026-12-03  8:15 ` [PATCH 2/3] usb: gadget: f_tcm: drop dependent-module support Slawomir Stepien
2026-12-03  8:15 ` [PATCH 3/3] usb: gadget: f_tcm: call attach/detach directly instead of through callbacks Slawomir Stepien
2026-12-03  8:31 ` [PATCH 0/3] usb: gadget: remove legacy g_target and its f_tcm hooks sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox