lkml.org 
[lkml]   [2013]   [Nov]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 3/4] usb: ffs: check quirk to pad epout buf size when not aligned to maxpacketsize
On 11/05/2013 06:52 AM, Alan Stern wrote:
> On Mon, 4 Nov 2013, David Cohen wrote:
>
>> Check gadget.quirk_ep_out_aligned_size to decide if buffer size requires
>> to be aligned to maxpacketsize of an out endpoint. ffs_epfile_io() needs
>> to pad epout buffer to match above condition if quirk is found.
>>
>> Signed-off-by: David Cohen <david.a.cohen@linux.intel.com>
>> ---
>> drivers/usb/gadget/f_fs.c | 22 ++++++++++++++++++++++
>> 1 file changed, 22 insertions(+)
>>
>> diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
>> index 75e4b7846a8d..e7c3c3119552 100644
>> --- a/drivers/usb/gadget/f_fs.c
>> +++ b/drivers/usb/gadget/f_fs.c
>> @@ -755,10 +755,13 @@ static ssize_t ffs_epfile_io(struct file *file,
>> char __user *buf, size_t len, int read)
>> {
>> struct ffs_epfile *epfile = file->private_data;
>> + struct usb_gadget *gadget = epfile->ffs->gadget;
>> struct ffs_ep *ep;
>> char *data = NULL;
>> + size_t data_len = 0;
>> ssize_t ret;
>> int halt;
>> + size_t orig_len = len;
>>
>> goto first_try;
>> do {
>> @@ -794,11 +797,30 @@ first_try:
>> goto error;
>> }
>>
>> + /*
>> + * Controller requires buffer size to be aligned to
>> + * maxpacketsize of an out endpoint.
>> + */
>> + if (gadget->quirk_ep_out_aligned_size && read) {
>> + /*
>> + * We pass 'orig_len' to usp_ep_align_maxpacketsize()
>> + * due to we're in a loop and 'len' may have been
>> + * changed.
>> + */
>> + len = usb_ep_align_maxpacketsize(ep->ep, orig_len);
>> + if (data && len > data_len) {
>> + kfree(data);
>> + data = NULL;
>> + data_len = 0;
>> + }
>> + }
>
> Since the value of orig_len never changes, there's no point calling
> usb_ep_align_maxpacketsize() inside the loop. You should call it only
> once, before the loop starts. Once you do that, you won't need
> orig_len at all.

orig_len doesn't change but ep->ep does. If USB specs say max packet
size won't change even if ep does, than we can call it from outside the
loop.

Br, David


\
 
 \ /
  Last update: 2013-11-05 17:21    [W:0.083 / U:0.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site