Re: [PATCH v2 1/3] usb: chipidea: udc: add OTG status request handling

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

 



On Wed, May 28, 2014 at 03:09:16PM +0800, Li Jun wrote:
> From: Li Jun <b47624@xxxxxxxxxxxxx>
> 
> Peripheral answers OTG status selector request from host according to
> host request flag of gadget, length is 1. this flag may be set by application
> via kernel interface.

via ioctl or sysfs?

Does the HNP polling be used when the B-device wants to give up host
role?

Peter

> 
> Signed-off-by: Li Jun <b47624@xxxxxxxxxxxxx>
> ---
>  drivers/usb/chipidea/udc.c |   22 +++++++++++++++++-----
>  1 file changed, 17 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> index d683968..163adf9 100644
> --- a/drivers/usb/chipidea/udc.c
> +++ b/drivers/usb/chipidea/udc.c
> @@ -815,7 +815,10 @@ __acquires(hwep->lock)
>  		return -ENOMEM;
>  
>  	req->complete = isr_get_status_complete;
> -	req->length   = 2;
> +	if (setup->wIndex == OTG_STS_SELECTOR)
> +		req->length = 1;
> +	else
> +		req->length = 2;
>  	req->buf      = kzalloc(req->length, gfp_flags);
>  	if (req->buf == NULL) {
>  		retval = -ENOMEM;
> @@ -823,8 +826,16 @@ __acquires(hwep->lock)
>  	}
>  
>  	if ((setup->bRequestType & USB_RECIP_MASK) == USB_RECIP_DEVICE) {
> -		/* Assume that device is bus powered for now. */
> -		*(u16 *)req->buf = ci->remote_wakeup << 1;
> +		if ((setup->wIndex == OTG_STS_SELECTOR) &&
> +					ci_otg_is_fsm_mode(ci)) {
> +			if (ci->gadget.host_request_flag)
> +				*(u8 *)req->buf = HOST_REQUEST_FLAG;
> +			else
> +				*(u8 *)req->buf = 0;
> +		} else {
> +			/* Assume that device is bus powered for now. */
> +			*(u16 *)req->buf = ci->remote_wakeup << 1;
> +		}
>  		retval = 0;
>  	} else if ((setup->bRequestType & USB_RECIP_MASK) \
>  		   == USB_RECIP_ENDPOINT) {
> @@ -1003,8 +1014,9 @@ __acquires(ci->lock)
>  		    type != (USB_DIR_IN|USB_RECIP_ENDPOINT) &&
>  		    type != (USB_DIR_IN|USB_RECIP_INTERFACE))
>  			goto delegate;
> -		if (le16_to_cpu(req.wLength) != 2 ||
> -		    le16_to_cpu(req.wValue)  != 0)
> +		if ((le16_to_cpu(req.wLength) != 2 &&
> +			le16_to_cpu(req.wLength) != 1) ||
> +				le16_to_cpu(req.wValue) != 0)
>  			break;
>  		err = isr_get_status_response(ci, &req);
>  		break;
> -- 
> 1.7.9.5
> 

-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




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

  Powered by Linux