Commit 430fdbd3 authored by Daniel Mack's avatar Daniel Mack Committed by Felipe Balbi

usb: gadget: f_uac2: restructure some code in afunc_set_alt()

Restructure some code to make it easier to read.

While at it, return -ENOMEM instead of -EINVAL if
usb_ep_alloc_request() fails, and omit the logging in such cases
(the mm core will complain loud enough).
Signed-off-by: default avatarDaniel Mack <zonque@gmail.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 4953ef65
...@@ -1104,19 +1104,10 @@ afunc_set_alt(struct usb_function *fn, unsigned intf, unsigned alt) ...@@ -1104,19 +1104,10 @@ afunc_set_alt(struct usb_function *fn, unsigned intf, unsigned alt)
usb_ep_enable(ep); usb_ep_enable(ep);
for (i = 0; i < USB_XFERS; i++) { for (i = 0; i < USB_XFERS; i++) {
if (prm->ureq[i].req) { if (!prm->ureq[i].req) {
if (usb_ep_queue(ep, prm->ureq[i].req, GFP_ATOMIC))
dev_err(&uac2->pdev.dev, "%d Error!\n",
__LINE__);
continue;
}
req = usb_ep_alloc_request(ep, GFP_ATOMIC); req = usb_ep_alloc_request(ep, GFP_ATOMIC);
if (req == NULL) { if (req == NULL)
dev_err(&uac2->pdev.dev, return -ENOMEM;
"%s:%d Error!\n", __func__, __LINE__);
return -EINVAL;
}
prm->ureq[i].req = req; prm->ureq[i].req = req;
prm->ureq[i].pp = prm; prm->ureq[i].pp = prm;
...@@ -1126,9 +1117,11 @@ afunc_set_alt(struct usb_function *fn, unsigned intf, unsigned alt) ...@@ -1126,9 +1117,11 @@ afunc_set_alt(struct usb_function *fn, unsigned intf, unsigned alt)
req->length = prm->max_psize; req->length = prm->max_psize;
req->complete = agdev_iso_complete; req->complete = agdev_iso_complete;
req->buf = prm->rbuf + i * req->length; req->buf = prm->rbuf + i * req->length;
}
if (usb_ep_queue(ep, req, GFP_ATOMIC)) if (usb_ep_queue(ep, prm->ureq[i].req, GFP_ATOMIC))
dev_err(&uac2->pdev.dev, "%d Error!\n", __LINE__); dev_err(&uac2->pdev.dev, "%s:%d Error!\n",
__func__, __LINE__);
} }
return 0; return 0;
......
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