From 3754e108b2c6052e4c6f383e45af4e7810476868 Mon Sep 17 00:00:00 2001 From: William Wu Date: Fri, 22 Aug 2025 10:19:15 +0800 Subject: [PATCH] FROMLIST: usb: gadget: configfs: Correctly set use_os_string at bind Once the use_os_string flag is set to true for some functions (e.g. adb/mtp) which need to response the OS string, and then if we re-bind the ConfigFS gadget to use the other functions (e.g. hid) which should not to response the OS string, however, because the use_os_string flag is still true, so the usb gadget response the OS string descriptor incorrectly, this can cause the USB device to be unrecognizable on the Windows system. An example of this as follows: echo 1 > os_desc/use ln -s functions/ffs.adb configs/b.1/function0 start adbd echo "" > UDC #succeed stop adbd rm configs/b.1/function0 echo 0 > os_desc/use ln -s functions/hid.gs0 configs/b.1/function0 echo "" > UDC #fail to connect on Windows This patch sets the use_os_string flag to false at bind if the functions not support OS Descriptors. Fixes: 87213d388e92 ("usb: gadget: configfs: OS String support") Link: https://patchwork.kernel.org/project/linux-usb/patch/1755833769-25434-1-git-send-email-william.wu@rock-chips.com/ Change-Id: I79fce9ad19b5ceaf5ded84894d6b509a3d0c75f4 Signed-off-by: William Wu --- drivers/usb/gadget/configfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 4dbbbfdf8d71..c5db03466f39 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -1389,6 +1389,8 @@ static int configfs_composite_bind(struct usb_gadget *gadget, cdev->use_os_string = true; cdev->b_vendor_code = gi->b_vendor_code; memcpy(cdev->qw_sign, gi->qw_sign, OS_STRING_QW_SIGN_LEN); + } else { + cdev->use_os_string = false; } if (gadget_is_otg(gadget) && !otg_desc[0]) {