Re: [PATCH 06/16] usb/gadget: convert source sink and loopback to new function interface

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

 



On Wed, Nov 14, 2012 at 06:14:56PM +0100, Sebastian Andrzej Siewior wrote:
> This patch converts the f_sourcesink and f_loopback file to the USB-function
> module. Both functions shares a few common utility functions which are
> currently implemented in g_zero.c itself. This patch moves the common
> code into the sourcesink file and creates one module out of the the two
> functions (source sink and loop back).
> The g_zero gadget is function specific to source sink and loop back to
> set a few options. This Symbol dependency enforces a modul load right
> now.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> ---
>  drivers/usb/gadget/Kconfig        |    4 +
>  drivers/usb/gadget/Makefile       |    4 +
>  drivers/usb/gadget/f_loopback.c   |   59 ++++++++-----
>  drivers/usb/gadget/f_sourcesink.c |  148 ++++++++++++++++++++------------
>  drivers/usb/gadget/g_zero.h       |   18 +++-
>  drivers/usb/gadget/zero.c         |  168 +++++++++++++++++++------------------
>  6 files changed, 246 insertions(+), 155 deletions(-)
> 
> diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
> index d381d720..0eb8b6f 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_SS_LB
> +	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_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
> diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
> index fa65050..0903972 100644
> --- a/drivers/usb/gadget/Makefile
> +++ b/drivers/usb/gadget/Makefile
> @@ -76,3 +76,7 @@ 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
> +f_ss_lb-y			:= f_loopback.o f_sourcesink.o
> +obj-$(CONFIG_USB_F_SS_LB)	+= f_ss_lb.o
> diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c
> index 3d103a2..2d5aade 100644
> --- a/drivers/usb/gadget/f_loopback.c
> +++ b/drivers/usb/gadget/f_loopback.c
> @@ -15,10 +15,11 @@
>  #include <linux/slab.h>
>  #include <linux/kernel.h>
>  #include <linux/device.h>
> +#include <linux/module.h>
> +#include <linux/err.h>
> +#include <linux/usb/composite.h>
>  
>  #include "g_zero.h"
> -#include "gadget_chips.h"
> -
>  
>  /*
>   * LOOPBACK FUNCTION ... a testing vehicle for USB peripherals,
> @@ -44,9 +45,17 @@ static inline struct f_loopback *func_to_loop(struct usb_function *f)
>  	return container_of(f, struct f_loopback, function);
>  }
>  
> -static unsigned qlen = 32;
> -module_param(qlen, uint, 0);
> -MODULE_PARM_DESC(qlenn, "depth of loopback queue");
> +static unsigned qlen;
> +static unsigned buflen;
> +
> +void lb_set_options(struct usb_function *f, struct usb_zero_options *lb_opt)
> +{
> +	buflen = lb_opt->bulk_buflen;
> +	qlen = lb_opt->qlen;
> +	if (!qlen)
> +		qlen = 32;
> +}
> +EXPORT_SYMBOL_GPL(lb_set_options);

now this looks awfully wrong. Why don't you just expose the modules to
userland (in fact they already are) and if user wants to change
something it needs to do it via sysfs before enabling the function ?

would that work ?

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