Hi all,
I've backported some commits to my kernel (3.4) to get gadget state
tracking.
I think that I missed something or there is a small error on this one
that hasn't been spotted:
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=49401f4169c0e5a1b38f1a676d6f12eecaf77485
-----------------
+void usb_gadget_set_state(struct usb_gadget *gadget,
+ enum usb_device_state state)
+{
+ gadget->state = state;
+ sysfs_notify(&gadget->dev.kobj, NULL, "status");
+}
-----------------
The sysfs_notify is done on the gadget kobject and the sysfs group is
under the udc kobject :
-----------------
static struct attribute *usb_udc_attrs[] = {
(...)
+ &dev_attr_state.attr,
int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget
*gadget,
(...)
udc->dev.groups = usb_udc_attr_groups;
-----------------
To make it work correctly we need to do the sysfs_notify on the udc
kobject too.
We've done this using this following patch :
-----------------
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
index 7d8d839..03e9f49 100644
--- a/drivers/usb/gadget/udc-core.c
+++ b/drivers/usb/gadget/udc-core.c
@@ -129,8 +129,18 @@ static inline int usb_gadget_start(struct
usb_gadget *gadget,
static void usb_gadget_state_work(struct work_struct *work)
{
struct usb_gadget *gadget = work_to_gadget(work);
+ struct usb_udc *udc = NULL;
+
+ mutex_lock(&udc_lock);
+ list_for_each_entry(udc, &udc_list, list)
+ if (udc->gadget == gadget)
+ goto found;
+ udc = NULL;
+found:
+ mutex_unlock(&udc_lock);
- sysfs_notify(&gadget->dev.kobj, NULL, "state");
+ if(udc)
+ sysfs_notify(&udc->dev.kobj, NULL, "state");
}
void usb_gadget_set_state(struct usb_gadget *gadget,
-----------------
If there is something I missed, please tell me.
Best Regards,
François MULLER
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html