Hello, On 08/13/2015 09:12 PM, Amit Pundir wrote:
This is more of an RFC than an actual submission. There are few scattered #ifdefs..#endifs here and there which still need to be taken care of before going for actual submission. Currently there is no way with the upstream ConfigFS gadget to communicate state changes (connected, disconnected, configured), at the gadget level. Instead such state changes are handled function by function independently I presume. This is problematic, because some coordination between the functions, across the state changes, may be desired at the userspace level. Thus to address this issue, this patch send uevents to allow userspace to be notified of these usb state changes, allowing userspace to respond and configure the configfs gadget appropriately. This patch is based on an Android patchset originaly authored by Badhri Jagan Sridharan<Badhri@xxxxxxxxxx> to send uevent notifications to Android userpace for USB state changes. I've folded his patches together and modified it enough that I don't want him to be blamed for any mistakes I've made condensing his patches down. This patch introduces USB_CONFIGFS_UEVENT Kconfig to handle userspace notifications of usb state changes, and add setup and disconnect functions to intercept the setup requests from the usb_core. It also creates a sysfs device class entry and a device attribute (state) to read and respond to gadget's current state from userspace. As of now this sysfs device class (/sys/class/android_usb) and gadget device (/sys/class/android_usb/android0) with state attribute (/sys/class/android_usb/android0/state) are strictly tied up to facilitate Android userspace requests. But going forward we may want to bring all function devices (hid, printer etc) under a unified usb gadget device class e.g. /sys/class/usb_gadget/g_{func0,func1} etc.. Also I think it make sense to add this state attribute to the configfs usb gadget itself i.e. have something like /config/usb_gadget/g1/state to read USB gadget's current state. Since it is going to be consistent throughout all the functions tied up to that gadget. Again this is just an initial RFC, thoughts and feedback would be greatly appreciated. Cc: Mike Lockwood<lockwood@xxxxxxxxxxx> Cc: Benoit Goby<benoit@xxxxxxxxxxx> Cc: Colin Cross<ccross@xxxxxxxxxxx> Cc: Arve Hjønnevåg<arve@xxxxxxxxxxx> Cc: Peter Oh<poh@xxxxxxxxxxxx> Cc: Greg Hackmann<ghackmann@xxxxxxxxxx> Cc: Badhri Jagan Sridharan<Badhri@xxxxxxxxxx> Cc: Android Kernel Team<kernel-team@xxxxxxxxxxx> Cc: Greg Kroah-Hartman<gregkh@xxxxxxxxxxxxxxxxxxx> Cc: Jonathan Corbet<corbet@xxxxxxx> Cc: Felipe Balbi<balbi@xxxxxx> Cc: Andrzej Pietrasiewicz<andrzej.p@xxxxxxxxxxx> Cc: Laurent Pinchart<laurent.pinchart@xxxxxxxxxxxxxxxx> Cc: Yegor Yefremov<yegorslists@xxxxxxxxxxxxxx> Cc: Philippe Reynes<tremyfr@xxxxxxxxx> Cc: John Stultz<john.stultz@xxxxxxxxxx> Cc: Sumit Semwal<sumit.semwal@xxxxxxxxxx> Signed-off-by: Amit Pundir<amit.pundir@xxxxxxxxxx>
Generally I agree that there should be some way of notifying userspace about gadget state but I'm not sure if this is proper way to go. In my opinion gadget-bus which has been discussed some time ago on linux-usb makes much more sense than this.
Maybe I will be wrong but I guess that you are adding this feature to make android mtp-responder working properly in Linux (not android). Again if we use FFS instead of adding mtp function we don't need this notification as mtp-responder can get all the required informations about gadget (function) via ep0 using functionfs events.
Best regards, -- Krzysztof Opasiak Samsung R&D Institute Poland Samsung Electronics -- 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