Hi Matthieu, On 3/15/2011 9:38 PM, Matthieu CASTET wrote: > Even if the usb gadget framework is limited to work with one driver, it > could be useful to have a kernel build with more than driver. > This allow to make generic kernel that work with different udc controller. > > The only blocker to do that is usb_gadget_register_driver > and usb_gadget_unregister_driver function are declared in each driver. > > For avoiding that a redirection is done for these functions : > At probe time the driver register them (usb_gadget_register and > usb_gadget_unregister), and the generic usb_gadget_register_driver and > usb_gadget_unregister_driver call these callback. > We pass struct *usb_gadget in usb_gadget_register and usb_gadget_unregister > for flexibility (we can latter do a more complex dispatcher). > > Signed-off-by: Matthieu CASTET <matthieu.castet@xxxxxxxxxx> > Ack-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> > --- <snip> > diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig > index d500996..d088bb0 100644 > --- a/drivers/usb/gadget/Kconfig > +++ b/drivers/usb/gadget/Kconfig > @@ -559,6 +559,12 @@ config USB_CI13XXX_MSM > default USB_GADGET > select USB_GADGET_SELECTED > > +config USB_GADGET_MULTIUDC > + boolean "multi USB Device Port" > + select USB_GADGET_SELECTED > + help > + Allow to build more than one udc. > + default n ? > # > # LAST -- dummy/emulated controller > # > diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile > index 55f5e8a..5798697 100644 > --- a/drivers/usb/gadget/Makefile > +++ b/drivers/usb/gadget/Makefile > @@ -29,6 +29,8 @@ obj-$(CONFIG_USB_PXA_U2O) += mv_udc.o > mv_udc-y := mv_udc_core.o mv_udc_phy.o > obj-$(CONFIG_USB_CI13XXX_MSM) += ci13xxx_msm.o > > +obj-$(CONFIG_USB_GADGET_MULTIUDC) += core_udc.o > + > # > # USB gadget drivers > # > diff --git a/drivers/usb/gadget/core_udc.c b/drivers/usb/gadget/core_udc.c > new file mode 100644 > index 0000000..8339883 > --- /dev/null > +++ b/drivers/usb/gadget/core_udc.c > @@ -0,0 +1,61 @@ > +/* > + * Copyright (C) 2010 Matthieu CASTET <matthieu.castet@xxxxxxxxxx> > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU Lesser General Public License as published > + * by the Free Software Foundation; either version 2.1 of the License, or > + * (at your option) any later version. > + */ > + > +#include <linux/kernel.h> > +#include <linux/module.h> > +#include <linux/init.h> > +#include <linux/errno.h> > +#include <linux/dma-mapping.h> > +#include <linux/platform_device.h> > +#include <linux/usb/ch9.h> Most of the above .h are not required. > +#include <linux/usb/gadget.h> > + > +static struct usb_gadget *usb_gadget_udc; > + > +int usb_gadget_register(struct usb_gadget *gadget) > +{ > + if (!gadget->udc || > + !gadget->udc->probe_driver || !gadget->udc->unregister_driver) > + return -EINVAL; > + > + if (usb_gadget_udc) > + return -EBUSY; > + > + usb_gadget_udc = gadget; > + > + return device_register(&gadget->dev); > +} Any special reason for having device registration in this function. All udc drivers are doing this in their probe() method. > +EXPORT_SYMBOL(usb_gadget_register); > + Thanks, Pavan -- Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum. -- 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