Skip to content

Commit

Permalink
Merge tag 'gadget-for-v3.9' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/balbi/usb into usb-next

Felipe writes:
	usb: gadget: patches for v3.9 merge window

	finally getting rid of the old ->start()/->stop() methods
	in favor of the better and improved ->udc_start()/->udc_stop().

	There were surprisingly quite a few users left, but all of them
	have been converted.

	f_mass_storage removed some dead code, which is always great ;-)

	There's also a big cleanup to the gadget framework from Sebastian
	which gets us a lot closer to having only function drivers in
	kernel and move over to configfs-based binding.

	Other than these, there's the usual set of cleanups: s3c UDCs are
	moving over to devm_regulator_bulk_get() API, at91_udc removed
	an unnecessary check for work_pending() before scheduling and
	there's the removal of an unused variable from uac2_pcm_trigger().
  • Loading branch information
Greg Kroah-Hartman committed Jan 25, 2013
2 parents a9b8676 + eeef458 commit cba6c85
Show file tree
Hide file tree
Showing 55 changed files with 1,751 additions and 1,483 deletions.
20 changes: 20 additions & 0 deletions drivers/usb/gadget/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,15 @@ config USB_LIBCOMPOSITE
tristate
depends on USB_GADGET

config USB_F_ACM
tristate

config USB_F_SS_LB
tristate

config USB_U_SERIAL
tristate

choice
tristate "USB Gadget Drivers"
default USB_ETH
Expand All @@ -524,6 +533,7 @@ choice
config USB_ZERO
tristate "Gadget Zero (DEVELOPMENT)"
select USB_LIBCOMPOSITE
select USB_F_SS_LB
help
Gadget Zero is a two-configuration device. It either sinks and
sources bulk data; or it loops back a configurable number of
Expand Down Expand Up @@ -750,6 +760,8 @@ config USB_GADGET_TARGET

config USB_G_SERIAL
tristate "Serial Gadget (with CDC ACM and CDC OBEX support)"
select USB_U_SERIAL
select USB_F_ACM
select USB_LIBCOMPOSITE
help
The Serial Gadget talks to the Linux-USB generic serial driver.
Expand Down Expand Up @@ -803,6 +815,8 @@ config USB_CDC_COMPOSITE
tristate "CDC Composite Device (Ethernet and ACM)"
depends on NET
select USB_LIBCOMPOSITE
select USB_U_SERIAL
select USB_F_ACM
help
This driver provides two functions in one configuration:
a CDC Ethernet (ECM) link, and a CDC ACM (serial port) link.
Expand All @@ -818,6 +832,7 @@ config USB_G_NOKIA
tristate "Nokia composite gadget"
depends on PHONET
select USB_LIBCOMPOSITE
select USB_U_SERIAL
help
The Nokia composite gadget provides support for acm, obex
and phonet in only one composite gadget driver.
Expand All @@ -829,6 +844,8 @@ config USB_G_ACM_MS
tristate "CDC Composite Device (ACM and mass storage)"
depends on BLOCK
select USB_LIBCOMPOSITE
select USB_U_SERIAL
select USB_F_ACM
help
This driver provides two functions in one configuration:
a mass storage, and a CDC ACM (serial port) link.
Expand All @@ -841,6 +858,8 @@ config USB_G_MULTI
depends on BLOCK && NET
select USB_G_MULTI_CDC if !USB_G_MULTI_RNDIS
select USB_LIBCOMPOSITE
select USB_U_SERIAL
select USB_F_ACM
help
The Multifunction Composite Gadget provides Ethernet (RNDIS
and/or CDC Ethernet), mass storage and ACM serial link
Expand Down Expand Up @@ -916,6 +935,7 @@ config USB_G_DBGP_PRINTK

config USB_G_DBGP_SERIAL
depends on USB_G_DBGP
select USB_U_SERIAL
bool "serial"
help
Userland can interact using /dev/ttyGSxxx.
Expand Down
8 changes: 7 additions & 1 deletion drivers/usb/gadget/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG
obj-$(CONFIG_USB_GADGET) += udc-core.o
obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o
libcomposite-y := usbstring.o config.o epautoconf.o
libcomposite-y += composite.o
libcomposite-y += composite.o functions.o
obj-$(CONFIG_USB_DUMMY_HCD) += dummy_hcd.o
obj-$(CONFIG_USB_NET2272) += net2272.o
obj-$(CONFIG_USB_NET2280) += net2280.o
Expand Down Expand Up @@ -74,3 +74,9 @@ obj-$(CONFIG_USB_G_WEBCAM) += g_webcam.o
obj-$(CONFIG_USB_G_NCM) += g_ncm.o
obj-$(CONFIG_USB_G_ACM_MS) += g_acm_ms.o
obj-$(CONFIG_USB_GADGET_TARGET) += tcm_usb_gadget.o

# USB Functions
obj-$(CONFIG_USB_F_ACM) += f_acm.o
f_ss_lb-y := f_loopback.o f_sourcesink.o
obj-$(CONFIG_USB_F_SS_LB) += f_ss_lb.o
obj-$(CONFIG_USB_U_SERIAL) += u_serial.o
42 changes: 31 additions & 11 deletions drivers/usb/gadget/acm_ms.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
* the runtime footprint, and giving us at least some parts of what
* a "gcc --combine ... part1.c part2.c part3.c ... " build would.
*/

#include "u_serial.c"
#include "f_acm.c"
#include "f_mass_storage.c"

/*-------------------------------------------------------------------------*/
Expand Down Expand Up @@ -112,29 +109,51 @@ FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data);
static struct fsg_common fsg_common;

/*-------------------------------------------------------------------------*/

static unsigned char tty_line;
static struct usb_function *f_acm;
static struct usb_function_instance *f_acm_inst;
/*
* We _always_ have both ACM and mass storage functions.
*/
static int __init acm_ms_do_config(struct usb_configuration *c)
{
struct f_serial_opts *opts;
int status;

if (gadget_is_otg(c->cdev->gadget)) {
c->descriptors = otg_desc;
c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}

f_acm_inst = usb_get_function_instance("acm");
if (IS_ERR(f_acm_inst))
return PTR_ERR(f_acm_inst);

opts = container_of(f_acm_inst, struct f_serial_opts, func_inst);
opts->port_num = tty_line;

f_acm = usb_get_function(f_acm_inst);
if (IS_ERR(f_acm)) {
status = PTR_ERR(f_acm);
goto err_func;
}

status = acm_bind_config(c, 0);
status = usb_add_function(c, f_acm);
if (status < 0)
return status;
goto err_conf;

status = fsg_bind_config(c->cdev, c, &fsg_common);
if (status < 0)
return status;
goto err_fsg;

return 0;
err_fsg:
usb_remove_function(c, f_acm);
err_conf:
usb_put_function(f_acm);
err_func:
usb_put_function_instance(f_acm_inst);
return status;
}

static struct usb_configuration acm_ms_config_driver = {
Expand All @@ -153,7 +172,7 @@ static int __init acm_ms_bind(struct usb_composite_dev *cdev)
void *retp;

/* set up serial link layer */
status = gserial_setup(cdev->gadget, 1);
status = gserial_alloc_line(&tty_line);
if (status < 0)
return status;

Expand Down Expand Up @@ -189,14 +208,15 @@ static int __init acm_ms_bind(struct usb_composite_dev *cdev)
fail1:
fsg_common_put(&fsg_common);
fail0:
gserial_cleanup();
gserial_free_line(tty_line);
return status;
}

static int __exit acm_ms_unbind(struct usb_composite_dev *cdev)
{
gserial_cleanup();

usb_put_function(f_acm);
usb_put_function_instance(f_acm_inst);
gserial_free_line(tty_line);
return 0;
}

Expand Down
59 changes: 14 additions & 45 deletions drivers/usb/gadget/amd5536udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1400,15 +1400,16 @@ static int udc_wakeup(struct usb_gadget *gadget)
return 0;
}

static int amd5536_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
static int amd5536_stop(struct usb_gadget_driver *driver);
static int amd5536_udc_start(struct usb_gadget *g,
struct usb_gadget_driver *driver);
static int amd5536_udc_stop(struct usb_gadget *g,
struct usb_gadget_driver *driver);
/* gadget operations */
static const struct usb_gadget_ops udc_ops = {
.wakeup = udc_wakeup,
.get_frame = udc_get_frame,
.start = amd5536_start,
.stop = amd5536_stop,
.udc_start = amd5536_udc_start,
.udc_stop = amd5536_udc_stop,
};

/* Setups endpoint parameters, adds endpoints to linked list */
Expand Down Expand Up @@ -1913,41 +1914,22 @@ static int setup_ep0(struct udc *dev)
}

/* Called by gadget driver to register itself */
static int amd5536_start(struct usb_gadget_driver *driver,
int (*bind)(struct usb_gadget *, struct usb_gadget_driver *))
static int amd5536_udc_start(struct usb_gadget *g,
struct usb_gadget_driver *driver)
{
struct udc *dev = udc;
int retval;
struct udc *dev = to_amd5536_udc(g);
u32 tmp;

if (!driver || !bind || !driver->setup
|| driver->max_speed < USB_SPEED_HIGH)
return -EINVAL;
if (!dev)
return -ENODEV;
if (dev->driver)
return -EBUSY;

driver->driver.bus = NULL;
dev->driver = driver;
dev->gadget.dev.driver = &driver->driver;

retval = bind(&dev->gadget, driver);

/* Some gadget drivers use both ep0 directions.
* NOTE: to gadget driver, ep0 is just one endpoint...
*/
dev->ep[UDC_EP0OUT_IX].ep.driver_data =
dev->ep[UDC_EP0IN_IX].ep.driver_data;

if (retval) {
DBG(dev, "binding to %s returning %d\n",
driver->driver.name, retval);
dev->driver = NULL;
dev->gadget.dev.driver = NULL;
return retval;
}

/* get ready for ep0 traffic */
setup_ep0(dev);

Expand All @@ -1969,38 +1951,28 @@ __acquires(dev->lock)
{
int tmp;

if (dev->gadget.speed != USB_SPEED_UNKNOWN) {
spin_unlock(&dev->lock);
driver->disconnect(&dev->gadget);
spin_lock(&dev->lock);
}

/* empty queues and init hardware */
udc_basic_init(dev);

for (tmp = 0; tmp < UDC_EP_NUM; tmp++)
empty_req_queue(&dev->ep[tmp]);

udc_setup_endpoints(dev);
}

/* Called by gadget driver to unregister itself */
static int amd5536_stop(struct usb_gadget_driver *driver)
static int amd5536_udc_stop(struct usb_gadget *g,
struct usb_gadget_driver *driver)
{
struct udc *dev = udc;
unsigned long flags;
struct udc *dev = to_amd5536_udc(g);
unsigned long flags;
u32 tmp;

if (!dev)
return -ENODEV;
if (!driver || driver != dev->driver || !driver->unbind)
return -EINVAL;

spin_lock_irqsave(&dev->lock, flags);
udc_mask_unused_interrupts(dev);
shutdown(dev, driver);
spin_unlock_irqrestore(&dev->lock, flags);

driver->unbind(&dev->gadget);
dev->gadget.dev.driver = NULL;
dev->driver = NULL;

Expand All @@ -2009,9 +1981,6 @@ static int amd5536_stop(struct usb_gadget_driver *driver)
tmp |= AMD_BIT(UDC_DEVCTL_SD);
writel(tmp, &dev->regs->ctl);


DBG(dev, "%s: unregistered\n", driver->driver.name);

return 0;
}

Expand Down
2 changes: 2 additions & 0 deletions drivers/usb/gadget/amd5536udc.h
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@ struct udc {
u16 cur_alt;
};

#define to_amd5536_udc(g) (container_of((g), struct udc, gadget))

/* setup request data */
union udc_setup_data {
u32 data[2];
Expand Down
5 changes: 2 additions & 3 deletions drivers/usb/gadget/at91_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1621,8 +1621,7 @@ static void at91_vbus_timer(unsigned long data)
* bus such as i2c or spi which may sleep, so schedule some work
* to read the vbus gpio
*/
if (!work_pending(&udc->vbus_timer_work))
schedule_work(&udc->vbus_timer_work);
schedule_work(&udc->vbus_timer_work);
}

static int at91_start(struct usb_gadget *gadget,
Expand Down Expand Up @@ -1739,7 +1738,7 @@ static int at91udc_probe(struct platform_device *pdev)

/* rm9200 needs manual D+ pullup; off by default */
if (cpu_is_at91rm9200()) {
if (gpio_is_valid(udc->board.pullup_pin)) {
if (!gpio_is_valid(udc->board.pullup_pin)) {
DBG("no D+ pullup?\n");
retval = -ENODEV;
goto fail0;
Expand Down
Loading

0 comments on commit cba6c85

Please sign in to comment.