Hi, On Thu, Nov 29, 2012 at 05:43:21PM +0100, Sebastian Andrzej Siewior wrote: > |# modprobe dummy_hcd num=2 > > |# find /sys/kernel/config/ -ls > > | 557 0 drwxr-xr-x 3 root root 0 Nov 29 17:26 /sys/kernel/config/ > | 558 0 drwxr-xr-x 5 root root 0 Nov 29 17:26 /sys/kernel/config/usb_gadget > | 561 0 drwxr-xr-x 4 root root 0 Nov 29 17:26 /sys/kernel/config/usb_gadget/udcs > | 569 0 drwxr-xr-x 2 root root 0 Nov 29 17:26 /sys/kernel/config/usb_gadget/udcs/dummy_udc.1 > | 568 0 drwxr-xr-x 2 root root 0 Nov 29 17:26 /sys/kernel/config/usb_gadget/udcs/dummy_udc.0 > | 560 0 drwxr-xr-x 2 root root 0 Nov 29 17:26 /sys/kernel/config/usb_gadget/gadgets > | 559 0 drwxr-xr-x 2 root root 0 Nov 29 17:26 /sys/kernel/config/usb_gadget/functions > > | # lsmod > | Module Size Used by > | dummy_hcd 20287 0 > | udc 10219 1 dummy_hcd > > |# mkdir /sys/kernel/config/usb_gadget/functions/acm.one I dont think this is enough. It doesn't cope with multiple usb configurations. Or is this just to show how we could probe functions to the framework before even binding them to a UDC ??? Anyway, what I wanted to see was something like: # mkdir -p /sys/kernel/config/usb_gadget/dwc3.0/gadget0/config0 \ /sys/kernel/config/usb_gadget/dwc3.0/gadget0/config1 # echo acm.2,obex.3,msc > \ /sys/kernel/config/usb_gadget/dwc3.0/gadget0/config0/functions # echo ffs,sourcesink > \ /sys/kernel/config/usb_gadget/dwc3.0/gadget0/config1/functions Then when you echo the function name to the functions file under the configuration, if the function isn't registered, then a try_module_get() will tell udev to load it and increment the usage counter. Also, it will create files and other directories for every part of the every descriptor, but, of course, only strings will be writable, everything else is read-only. This means that the following should allocate and expose a device descriptor: # mkdir /sys/kernel/config/usb_gadget/dwc3.0/gadget.0/ # ls /sys/kernel/config/usb_gadget/dwc3.0/gadget.0/ bLength bDescriptorType bcdUSB bDeviceClass bDeviceSubClass bDeviceProtocol bMaxPacketSize0 idVendor idProduct bcdDevice iManufacturer iProduct iSerialNumber bNumConfigurations likewise the following would allocate and expose a configuration descriptor: # mkdir /sys/kernel/config/usb_gadget/dwc3.0/gadget.0/config0/ # ls /sys/kernel/config/usb_gadget/dwc3.0/gadget.0/config0/ bLength bDescriptorType wTotalLength bNumInterfaces bConfigurationValue iConfiguration bmAttributes bMaxPower When we echo "function0,function1,...,functionN" > functions file, that would create one intf%d directory for each of functions interfaces (in order) and one ep$addr directory for each endpoint. Does that make sense to you ??? It would remove the need to even create a functions/$function.$num directory for everybody before being able to use the function. The way you've setup configfs it means that if I'm going to use ACM on multiple configurations or even multiple gadgets, I will have to know how many of them I will need before hand. With my approach, however, we could allocate ACM instances on a per-configuration/per-gadget basis. The only problem with that is the damn struct tty_driver. Maybe we initialize ACM with e.g. 32 ports always or we request Greg KH/Alan Cox to help out with ideas for TTY dynamic port allocation. Comments ? -- balbi
Attachment:
signature.asc
Description: Digital signature