[PATCH 0/4] Add Gadget Bus

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

 



Hi Felipe & Alan,

To continue with topic discussed at
http://www.spinics.net/lists/linux-usb/msg105279.html,
I implement the gadget bus to bind udc to gadget driver follow
most ideas from your two.

Now this problem is really annoying, many gadget build-in platforms
(Eg, Android) will fail to enable usb peripheral function due to
udc is probe deferral, I hope we can fix this problem asap.

The current "udc class" design can't cover auto-bind/manual bind
by device model, so the first patch changes "udc class" to
"gadget bus".

The second patch adds the implementation of gadget bus, and the
udc will bind to gadget driver automatically when they are matched.
The rule of auto-binding is: if the udc is not in use and the
gadget driver is not used by any udcs, it is matched successfully,
and will be binded. Each gadget driver can only be binded at one
udc. For example, there are two udcs, "udc-0" and "udc-1", and
two gadget drivers, "g_mass_storage" and "g_serial", assumed the
udcs is added to bus first, then, the "udc-0" will be binded to
"g_mass_storage", and "udc-1" will be binded to "g_seiral".

The third patch adds one "tricky" solution for manual bind if both
udc and gadget driver are built in.

The fifth patch delete the __init marker from all gadget driver's bind
function, since the bind may not be executed after gadget driver has
loaded due to udc is not ready.

Below tests are done:

One gadget driver build in and two udcs, udc devices are created first
One gadget driver build in and two udcs, gadget driver is created first 
Two gadget driver build as modules and two udcs build in
Two gadget driver build as modules and the udc driver build as module,
and no matter which is loaded first.

Manual binding/unbinding with different udcs:
- Both udc and gadget driver are build in, udc-core.manual_binding=1
echo 0 > /sys/module/udc_core/parameters/manual_binding
echo udc-0 > /sys/bus/usb_gadget/drivers/g_serial/bind
echo udc-0 > /sys/bus/usb_gadget/drivers/g_serial/unbind
echo udc-1 > /sys/bus/usb_gadget/drivers/g_serial/bind
echo udc-1 > /sys/bus/usb_gadget/drivers/g_serial/unbind
echo udc-0 > /sys/bus/usb_gadget/drivers/g_serial/bind
- After auto-bind, unbind current udc and do manual bind
echo udc-0 > /sys/bus/usb_gadget/drivers/g_serial/unbind
echo udc-1 > /sys/bus/usb_gadget/drivers/g_serial/bind

P.S: The mass storage gadget driver still not has problem if unload
udc before unload gadget driver due to device_release_driver is
called recursion (test_and_clear_bit is called by msg_thread_exits first),
I will try to post a patch to fix it.

Peter Chen (4):
  usb: gadget: core: change udc class to gadget bus
  usb: gadget: core: add implementation of gadget bus
  usb: gadget: core: add manual binding
  usb: gadget: remove __init from gadget driver bind function

 drivers/usb/gadget/acm_ms.c       |    4 +-
 drivers/usb/gadget/audio.c        |    4 +-
 drivers/usb/gadget/cdc2.c         |    4 +-
 drivers/usb/gadget/dbgp.c         |    4 +-
 drivers/usb/gadget/ether.c        |    6 +-
 drivers/usb/gadget/f_hid.c        |    6 +-
 drivers/usb/gadget/f_midi.c       |   12 +-
 drivers/usb/gadget/f_uac1.c       |   12 +-
 drivers/usb/gadget/f_uac2.c       |    2 +-
 drivers/usb/gadget/f_uvc.c        |   28 +++---
 drivers/usb/gadget/gmidi.c        |    4 +-
 drivers/usb/gadget/hid.c          |    6 +-
 drivers/usb/gadget/mass_storage.c |    4 +-
 drivers/usb/gadget/multi.c        |    4 +-
 drivers/usb/gadget/ncm.c          |    4 +-
 drivers/usb/gadget/nokia.c        |    4 +-
 drivers/usb/gadget/printer.c      |    6 +-
 drivers/usb/gadget/serial.c       |    2 +-
 drivers/usb/gadget/u_uac1.c       |    2 +-
 drivers/usb/gadget/udc-core.c     |  234 ++++++++++++++++++++++++-------------
 drivers/usb/gadget/webcam.c       |    4 +-
 drivers/usb/gadget/zero.c         |    2 +-
 22 files changed, 216 insertions(+), 142 deletions(-)

-- 
1.7.8

--
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




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux