Patch "USB: gadget: core: create sysfs link between udc and gadget" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    USB: gadget: core: create sysfs link between udc and gadget

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     usb-gadget-core-create-sysfs-link-between-udc-and-ga.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit b1e7b4ac6d8af9f53e3cc4beb2bea5f38caf86ed
Author: Roy Luo <royluo@xxxxxxxxxx>
Date:   Thu Mar 7 03:09:22 2024 +0000

    USB: gadget: core: create sysfs link between udc and gadget
    
    [ Upstream commit 0ef40f399aa2be8c04aee9b7430705612c104ce5 ]
    
    udc device and gadget device are tightly coupled, yet there's no good
    way to corelate the two. Add a sysfs link in udc that points to the
    corresponding gadget device.
    An example use case: userspace configures a f_midi configfs driver and
    bind the udc device, then it tries to locate the corresponding midi
    device, which is a child device of the gadget device. The gadget device
    that's associated to the udc device has to be identified in order to
    index the midi device. Having a sysfs link would make things much
    easier.
    
    Signed-off-by: Roy Luo <royluo@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240307030922.3573161-1-royluo@xxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Stable-dep-of: 399a45e5237c ("usb: gadget: core: flush gadget workqueue after device removal")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 6d7f8e98ba2a8..5085580eeb3ad 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -1419,8 +1419,16 @@ int usb_add_gadget(struct usb_gadget *gadget)
 	if (ret)
 		goto err_free_id;
 
+	ret = sysfs_create_link(&udc->dev.kobj,
+				&gadget->dev.kobj, "gadget");
+	if (ret)
+		goto err_del_gadget;
+
 	return 0;
 
+ err_del_gadget:
+	device_del(&gadget->dev);
+
  err_free_id:
 	ida_free(&gadget_id_numbers, gadget->id_number);
 
@@ -1529,6 +1537,7 @@ void usb_del_gadget(struct usb_gadget *gadget)
 	mutex_unlock(&udc_lock);
 
 	kobject_uevent(&udc->dev.kobj, KOBJ_REMOVE);
+	sysfs_remove_link(&udc->dev.kobj, "gadget");
 	flush_work(&gadget->work);
 	device_del(&gadget->dev);
 	ida_free(&gadget_id_numbers, gadget->id_number);




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux