Re: [PATCH/RFC 3/5] usb:g_zero: bulk in/out unittest support

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

 



Hi,

On Thu, Jun 16, 2011 at 04:31:05PM +0300, Tatyana Brokhman wrote:
> This commit adds a new vendor specific request to be handled by the
> g_zero module in it's sourcesink configuration. The purpose if this
> request is to update the length of the BULK transfer to a given value.
> The bRequest value of the new control request is 0x5e.
> It is used by the user-space Unit testing application for bulk in/out
> tests.
> 
> Signed-off-by: Tatyana Brokhman <tlinder@xxxxxxxxxxxxxx>
> 
> ---
>  drivers/usb/gadget/f_sourcesink.c |   12 ++++++++++++
>  1 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c
> index caf2f95..d417b8a 100644
> --- a/drivers/usb/gadget/f_sourcesink.c
> +++ b/drivers/usb/gadget/f_sourcesink.c
> @@ -70,6 +70,7 @@ static unsigned pattern;
>  module_param(pattern, uint, 0);
>  MODULE_PARM_DESC(pattern, "0 = all zeroes, 1 = mod63 ");
>  
> +static struct f_sourcesink	*the_sourcesink;

this is a big no-no. f_*.c should always be able to be instantiated as
many times as we need.

>  /*-------------------------------------------------------------------------*/
>  
>  static struct usb_interface_descriptor source_sink_intf = {
> @@ -197,6 +198,7 @@ static void
>  sourcesink_unbind(struct usb_configuration *c, struct usb_function *f)
>  {
>  	kfree(func_to_ss(f));
> +	the_sourcesink = NULL;
>  }
>  
>  /* optionally require specific source/sink data patterns  */
> @@ -425,6 +427,7 @@ static int __init sourcesink_bind_config(struct usb_configuration *c)
>  	status = usb_add_function(c, &ss->function);
>  	if (status)
>  		kfree(ss);
> +	the_sourcesink = ss;
>  	return status;
>  }
>  
> @@ -472,6 +475,15 @@ static int sourcesink_setup(struct usb_configuration *c,
>  		value = w_length;
>  		break;
>  
> +	case 0x5e:
> +		/*
> +		 * Change bulk ep buffer size. buflen is the length of
> +		 * the BULK transfer (req->length=buflen). Defined in g_zero.h
> +		 */
> +		disable_source_sink(the_sourcesink);
> +		buflen = w_value;
> +		value = enable_source_sink(c->cdev, the_sourcesink);
> +		break;
>  	default:

I think this request, should be handled by the f_sourcesink interface.
Meaning you'd need to introduce another f_sourcesink_setup(); to be
added to the function, rather then the configuration.

Please change that.

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