diff options
author | Vincent Pelletier <plr.vincent@gmail.com> | 2017-01-09 08:46:00 -0500 |
---|---|---|
committer | Felipe Balbi <felipe.balbi@linux.intel.com> | 2017-01-12 03:00:30 -0500 |
commit | 08f37148b6a915a6996c7dbef87769b9efee2dba (patch) | |
tree | 7779671975d52ece5ebda1f48a9bc4a7b2e408e4 /drivers/usb | |
parent | 9383e084a88d04d442ea2dce128edff05f344e5c (diff) |
usb: gadget: f_fs: Fix iterations on endpoints.
When zero endpoints are declared for a function, there is no endpoint
to disable, enable or free, so replace do...while loops with while loops.
Change pre-decrement to post-decrement to iterate the same number of times
when there are endpoints to process.
Signed-off-by: Vincent Pelletier <plr.vincent@gmail.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/gadget/function/f_fs.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 5e746adc8a2d..5490fc51638e 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c | |||
@@ -1806,7 +1806,7 @@ static void ffs_func_eps_disable(struct ffs_function *func) | |||
1806 | unsigned long flags; | 1806 | unsigned long flags; |
1807 | 1807 | ||
1808 | spin_lock_irqsave(&func->ffs->eps_lock, flags); | 1808 | spin_lock_irqsave(&func->ffs->eps_lock, flags); |
1809 | do { | 1809 | while (count--) { |
1810 | /* pending requests get nuked */ | 1810 | /* pending requests get nuked */ |
1811 | if (likely(ep->ep)) | 1811 | if (likely(ep->ep)) |
1812 | usb_ep_disable(ep->ep); | 1812 | usb_ep_disable(ep->ep); |
@@ -1817,7 +1817,7 @@ static void ffs_func_eps_disable(struct ffs_function *func) | |||
1817 | __ffs_epfile_read_buffer_free(epfile); | 1817 | __ffs_epfile_read_buffer_free(epfile); |
1818 | ++epfile; | 1818 | ++epfile; |
1819 | } | 1819 | } |
1820 | } while (--count); | 1820 | } |
1821 | spin_unlock_irqrestore(&func->ffs->eps_lock, flags); | 1821 | spin_unlock_irqrestore(&func->ffs->eps_lock, flags); |
1822 | } | 1822 | } |
1823 | 1823 | ||
@@ -1831,7 +1831,7 @@ static int ffs_func_eps_enable(struct ffs_function *func) | |||
1831 | int ret = 0; | 1831 | int ret = 0; |
1832 | 1832 | ||
1833 | spin_lock_irqsave(&func->ffs->eps_lock, flags); | 1833 | spin_lock_irqsave(&func->ffs->eps_lock, flags); |
1834 | do { | 1834 | while(count--) { |
1835 | struct usb_endpoint_descriptor *ds; | 1835 | struct usb_endpoint_descriptor *ds; |
1836 | int desc_idx; | 1836 | int desc_idx; |
1837 | 1837 | ||
@@ -1867,7 +1867,7 @@ static int ffs_func_eps_enable(struct ffs_function *func) | |||
1867 | 1867 | ||
1868 | ++ep; | 1868 | ++ep; |
1869 | ++epfile; | 1869 | ++epfile; |
1870 | } while (--count); | 1870 | } |
1871 | spin_unlock_irqrestore(&func->ffs->eps_lock, flags); | 1871 | spin_unlock_irqrestore(&func->ffs->eps_lock, flags); |
1872 | 1872 | ||
1873 | return ret; | 1873 | return ret; |
@@ -3448,12 +3448,12 @@ static void ffs_func_unbind(struct usb_configuration *c, | |||
3448 | 3448 | ||
3449 | /* cleanup after autoconfig */ | 3449 | /* cleanup after autoconfig */ |
3450 | spin_lock_irqsave(&func->ffs->eps_lock, flags); | 3450 | spin_lock_irqsave(&func->ffs->eps_lock, flags); |
3451 | do { | 3451 | while (count--) { |
3452 | if (ep->ep && ep->req) | 3452 | if (ep->ep && ep->req) |
3453 | usb_ep_free_request(ep->ep, ep->req); | 3453 | usb_ep_free_request(ep->ep, ep->req); |
3454 | ep->req = NULL; | 3454 | ep->req = NULL; |
3455 | ++ep; | 3455 | ++ep; |
3456 | } while (--count); | 3456 | } |
3457 | spin_unlock_irqrestore(&func->ffs->eps_lock, flags); | 3457 | spin_unlock_irqrestore(&func->ffs->eps_lock, flags); |
3458 | kfree(func->eps); | 3458 | kfree(func->eps); |
3459 | func->eps = NULL; | 3459 | func->eps = NULL; |