diff options
| author | Daniel Mack <zonque@gmail.com> | 2014-08-27 13:09:03 -0400 |
|---|---|---|
| committer | Felipe Balbi <balbi@ti.com> | 2014-09-02 10:17:04 -0400 |
| commit | 430fdbd3b7ea4a820d4c1aa936ede77433cfa818 (patch) | |
| tree | f62b88c86a66d554c2fe51596189861a5393bfe0 /drivers/usb/gadget/function | |
| parent | 4953ef658910416655cdb4b61618458aa11302ab (diff) | |
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: Daniel Mack <zonque@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/function')
| -rw-r--r-- | drivers/usb/gadget/function/f_uac2.c | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c index 0d65e7c08a93..ab4652e423ce 100644 --- a/drivers/usb/gadget/function/f_uac2.c +++ b/drivers/usb/gadget/function/f_uac2.c | |||
| @@ -1104,31 +1104,24 @@ afunc_set_alt(struct usb_function *fn, unsigned intf, unsigned alt) | |||
| 1104 | usb_ep_enable(ep); | 1104 | usb_ep_enable(ep); |
| 1105 | 1105 | ||
| 1106 | for (i = 0; i < USB_XFERS; i++) { | 1106 | for (i = 0; i < USB_XFERS; i++) { |
| 1107 | if (prm->ureq[i].req) { | 1107 | if (!prm->ureq[i].req) { |
| 1108 | if (usb_ep_queue(ep, prm->ureq[i].req, GFP_ATOMIC)) | 1108 | req = usb_ep_alloc_request(ep, GFP_ATOMIC); |
| 1109 | dev_err(&uac2->pdev.dev, "%d Error!\n", | 1109 | if (req == NULL) |
| 1110 | __LINE__); | 1110 | return -ENOMEM; |
| 1111 | continue; | 1111 | |
| 1112 | } | 1112 | prm->ureq[i].req = req; |
| 1113 | 1113 | prm->ureq[i].pp = prm; | |
| 1114 | req = usb_ep_alloc_request(ep, GFP_ATOMIC); | 1114 | |
| 1115 | if (req == NULL) { | 1115 | req->zero = 0; |
| 1116 | dev_err(&uac2->pdev.dev, | 1116 | req->context = &prm->ureq[i]; |
| 1117 | "%s:%d Error!\n", __func__, __LINE__); | 1117 | req->length = prm->max_psize; |
| 1118 | return -EINVAL; | 1118 | req->complete = agdev_iso_complete; |
| 1119 | req->buf = prm->rbuf + i * req->length; | ||
| 1119 | } | 1120 | } |
| 1120 | 1121 | ||
| 1121 | prm->ureq[i].req = req; | 1122 | if (usb_ep_queue(ep, prm->ureq[i].req, GFP_ATOMIC)) |
| 1122 | prm->ureq[i].pp = prm; | 1123 | dev_err(&uac2->pdev.dev, "%s:%d Error!\n", |
| 1123 | 1124 | __func__, __LINE__); | |
| 1124 | req->zero = 0; | ||
| 1125 | req->context = &prm->ureq[i]; | ||
| 1126 | req->length = prm->max_psize; | ||
| 1127 | req->complete = agdev_iso_complete; | ||
| 1128 | req->buf = prm->rbuf + i * req->length; | ||
| 1129 | |||
| 1130 | if (usb_ep_queue(ep, req, GFP_ATOMIC)) | ||
| 1131 | dev_err(&uac2->pdev.dev, "%d Error!\n", __LINE__); | ||
| 1132 | } | 1125 | } |
| 1133 | 1126 | ||
| 1134 | return 0; | 1127 | return 0; |
