Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cba6c850 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Merge tag 'gadget-for-v3.9' of...

Merge tag 'gadget-for-v3.9' of git://git.kernel.org/pub/scm/linux/kernel/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().
parents a9b8676c eeef4587
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -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
@@ -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
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -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
@@ -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.
+7 −1
Original line number Diff line number Diff line
@@ -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
@@ -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
+31 −11
Original line number Diff line number Diff line
@@ -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"

/*-------------------------------------------------------------------------*/
@@ -112,12 +109,15 @@ 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)) {
@@ -125,16 +125,35 @@ static int __init acm_ms_do_config(struct usb_configuration *c)
		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 = {
@@ -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;

@@ -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;
}

+14 −45
Original line number Diff line number Diff line
@@ -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 */
@@ -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);

@@ -1969,14 +1951,9 @@ __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]);

@@ -1984,23 +1961,18 @@ __acquires(dev->lock)
}

/* 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;
	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;

@@ -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;
}

+2 −0
Original line number Diff line number Diff line
@@ -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];
Loading