Commit 08f37148 authored by Vincent Pelletier's avatar Vincent Pelletier Committed by Felipe Balbi

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: default avatarVincent Pelletier <plr.vincent@gmail.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent 9383e084
...@@ -1806,7 +1806,7 @@ static void ffs_func_eps_disable(struct ffs_function *func) ...@@ -1806,7 +1806,7 @@ static void ffs_func_eps_disable(struct ffs_function *func)
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&func->ffs->eps_lock, flags); spin_lock_irqsave(&func->ffs->eps_lock, flags);
do { while (count--) {
/* pending requests get nuked */ /* pending requests get nuked */
if (likely(ep->ep)) if (likely(ep->ep))
usb_ep_disable(ep->ep); usb_ep_disable(ep->ep);
...@@ -1817,7 +1817,7 @@ static void ffs_func_eps_disable(struct ffs_function *func) ...@@ -1817,7 +1817,7 @@ static void ffs_func_eps_disable(struct ffs_function *func)
__ffs_epfile_read_buffer_free(epfile); __ffs_epfile_read_buffer_free(epfile);
++epfile; ++epfile;
} }
} while (--count); }
spin_unlock_irqrestore(&func->ffs->eps_lock, flags); spin_unlock_irqrestore(&func->ffs->eps_lock, flags);
} }
...@@ -1831,7 +1831,7 @@ static int ffs_func_eps_enable(struct ffs_function *func) ...@@ -1831,7 +1831,7 @@ static int ffs_func_eps_enable(struct ffs_function *func)
int ret = 0; int ret = 0;
spin_lock_irqsave(&func->ffs->eps_lock, flags); spin_lock_irqsave(&func->ffs->eps_lock, flags);
do { while(count--) {
struct usb_endpoint_descriptor *ds; struct usb_endpoint_descriptor *ds;
int desc_idx; int desc_idx;
...@@ -1867,7 +1867,7 @@ static int ffs_func_eps_enable(struct ffs_function *func) ...@@ -1867,7 +1867,7 @@ static int ffs_func_eps_enable(struct ffs_function *func)
++ep; ++ep;
++epfile; ++epfile;
} while (--count); }
spin_unlock_irqrestore(&func->ffs->eps_lock, flags); spin_unlock_irqrestore(&func->ffs->eps_lock, flags);
return ret; return ret;
...@@ -3448,12 +3448,12 @@ static void ffs_func_unbind(struct usb_configuration *c, ...@@ -3448,12 +3448,12 @@ static void ffs_func_unbind(struct usb_configuration *c,
/* cleanup after autoconfig */ /* cleanup after autoconfig */
spin_lock_irqsave(&func->ffs->eps_lock, flags); spin_lock_irqsave(&func->ffs->eps_lock, flags);
do { while (count--) {
if (ep->ep && ep->req) if (ep->ep && ep->req)
usb_ep_free_request(ep->ep, ep->req); usb_ep_free_request(ep->ep, ep->req);
ep->req = NULL; ep->req = NULL;
++ep; ++ep;
} while (--count); }
spin_unlock_irqrestore(&func->ffs->eps_lock, flags); spin_unlock_irqrestore(&func->ffs->eps_lock, flags);
kfree(func->eps); kfree(func->eps);
func->eps = NULL; func->eps = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment