Re: [PATCH 07/17] usb/gadget: convert source sink to new function interface

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

 



Hi.

On Wed, Nov 07, 2012 at 07:23:53PM +0100, Sebastian Andrzej Siewior wrote:

missing commit log

> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> ---
>  drivers/usb/gadget/Kconfig        |    4 +
>  drivers/usb/gadget/Makefile       |    3 +
>  drivers/usb/gadget/f_sourcesink.c |  193 ++++++++++++++++++++++++++-----------
>  drivers/usb/gadget/zero.c         |   97 +++++++++++++++++--
>  4 files changed, 235 insertions(+), 62 deletions(-)
> 
> diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
> index d381d720..881cd63 100644
> --- a/drivers/usb/gadget/Kconfig
> +++ b/drivers/usb/gadget/Kconfig
> @@ -500,6 +500,9 @@ config USB_LIBCOMPOSITE
>  	tristate
>  	depends on USB_GADGET
>  
> +config USB_F_SOURCESINK
> +	tristate
> +
>  choice
>  	tristate "USB Gadget Drivers"
>  	default USB_ETH
> @@ -524,6 +527,7 @@ choice
>  config USB_ZERO
>  	tristate "Gadget Zero (DEVELOPMENT)"
>  	select USB_LIBCOMPOSITE
> +	select USB_F_SOURCESINK

select will force USB_F_SOURCESINK to 'y'.

> diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
> index fa65050..a68f306 100644
> --- a/drivers/usb/gadget/Makefile
> +++ b/drivers/usb/gadget/Makefile
> @@ -76,3 +76,6 @@ 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_SOURCESINK) += f_sourcesink.o
> diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c
> index 1afe562..8e5591e 100644
> --- a/drivers/usb/gadget/f_sourcesink.c
> +++ b/drivers/usb/gadget/f_sourcesink.c
> @@ -16,11 +16,10 @@
>  #include <linux/kernel.h>
>  #include <linux/device.h>
>  #include <linux/module.h>
> +#include <linux/usb/composite.h>
>  
> -#include "g_zero.h"
>  #include "gadget_chips.h"
>  
> -
>  /*
>   * SOURCE/SINK FUNCTION ... a primary testing vehicle for USB peripheral
>   * controller drivers.
> @@ -62,24 +61,11 @@ static inline struct f_sourcesink *func_to_ss(struct usb_function *f)
>  }
>  
>  static unsigned pattern;
> -module_param(pattern, uint, S_IRUGO|S_IWUSR);
> -MODULE_PARM_DESC(pattern, "0 = all zeroes, 1 = mod63, 2 = none");
> -
> -static unsigned isoc_interval = 4;
> -module_param(isoc_interval, uint, S_IRUGO|S_IWUSR);
> -MODULE_PARM_DESC(isoc_interval, "1 - 16");
> -
> -static unsigned isoc_maxpacket = 1024;
> -module_param(isoc_maxpacket, uint, S_IRUGO|S_IWUSR);
> -MODULE_PARM_DESC(isoc_maxpacket, "0 - 1023 (fs), 0 - 1024 (hs/ss)");
> -
> +static unsigned isoc_interval;
> +static unsigned isoc_maxpacket;
>  static unsigned isoc_mult;
> -module_param(isoc_mult, uint, S_IRUGO|S_IWUSR);
> -MODULE_PARM_DESC(isoc_mult, "0 - 2 (hs/ss only)");
> -
>  static unsigned isoc_maxburst;
> -module_param(isoc_maxburst, uint, S_IRUGO|S_IWUSR);
> -MODULE_PARM_DESC(isoc_maxburst, "0 - 15 (ss only)");
> +static unsigned buflen;
>  
>  /*-------------------------------------------------------------------------*/
>  
> @@ -313,7 +299,75 @@ static struct usb_gadget_strings *sourcesink_strings[] = {
>  
>  /*-------------------------------------------------------------------------*/
>  
> -static int __init
> +static struct usb_request *alloc_ep_req(struct usb_ep *ep, int len)
> +{
> +	struct usb_request      *req;
> +
> +	req = usb_ep_alloc_request(ep, GFP_ATOMIC);
> +	if (req) {
> +		if (len)
> +			req->length = len;
> +		else
> +			req->length = buflen;
> +		req->buf = kmalloc(req->length, GFP_ATOMIC);
> +		if (!req->buf) {
> +			usb_ep_free_request(ep, req);
> +			req = NULL;
> +		}
> +	}
> +	return req;
> +}
> +
> +static void free_ep_req(struct usb_ep *ep, struct usb_request *req)
> +{
> +	kfree(req->buf);
> +	usb_ep_free_request(ep, req);
> +}
> +
> +static void disable_ep(struct usb_composite_dev *cdev, struct usb_ep *ep)
> +{
> +	int			value;
> +
> +	if (ep->driver_data) {
> +		value = usb_ep_disable(ep);
> +		if (value < 0)
> +			DBG(cdev, "disable %s --> %d\n",
> +					ep->name, value);
> +		ep->driver_data = NULL;
> +	}
> +}
> +
> +static void disable_endpoints(struct usb_composite_dev *cdev,
> +		struct usb_ep *in, struct usb_ep *out,
> +		struct usb_ep *iso_in, struct usb_ep *iso_out)
> +{
> +	disable_ep(cdev, in);
> +	disable_ep(cdev, out);
> +	if (iso_in)
> +		disable_ep(cdev, iso_in);
> +	if (iso_out)
> +		disable_ep(cdev, iso_out);
> +}
> +
> +static int ss_check_param(void)
> +{
> +	if (pattern > 2)
> +		return -EINVAL;
> +	if (isoc_interval > 16 || isoc_interval == 0)
> +		return -EINVAL;
> +	if (isoc_maxpacket > 1024)
> +		return -EINVAL;
> +	if (isoc_mult > 2)
> +		return -EINVAL;
> +	if (isoc_maxburst > 15)
> +		return -EINVAL;
> +	if (!buflen)
> +		return -EINVAL;
> +	return 0;
> +}
> +
> +
> +static int
>  sourcesink_bind(struct usb_configuration *c, struct usb_function *f)
>  {
>  	struct usb_composite_dev *cdev = c->cdev;
> @@ -321,6 +375,10 @@ sourcesink_bind(struct usb_configuration *c, struct usb_function *f)
>  	int	id;
>  	int ret;
>  
> +	ret = ss_check_param();
> +	if (ret)
> +		return ret;

looks like ss_check_param() doesn't fit $SUBJECT.

-- 
balbi

Attachment: signature.asc
Description: Digital signature


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

  Powered by Linux