Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757788AbcKCNRG (ORCPT ); Thu, 3 Nov 2016 09:17:06 -0400 Received: from mail.ispras.ru ([83.149.199.45]:56958 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756863AbcKCNRD (ORCPT ); Thu, 3 Nov 2016 09:17:03 -0400 From: Alexey Khoroshilov To: Felipe Balbi Cc: Alexey Khoroshilov , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH v2 2/2] usb: gadget: mv_u3d: mv_u3d_start_queue() refactoring Date: Thu, 3 Nov 2016 16:16:32 +0300 Message-Id: <1478178992-28317-2-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1478178992-28317-1-git-send-email-khoroshilov@ispras.ru> References: <871sytndwo.fsf@linux.intel.com> <1478178992-28317-1-git-send-email-khoroshilov@ispras.ru> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1722 Lines: 63 The patch improves readability of mv_u3d_start_queue() by rearranging its code with two semantic modifications: - assignment zero to ep->processing if usb_gadget_map_request() fails; - propagation of error code from mv_u3d_req_to_trb() instead of hardcoded -ENOMEM. Signed-off-by: Alexey Khoroshilov --- drivers/usb/gadget/udc/mv_u3d_core.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/usb/gadget/udc/mv_u3d_core.c b/drivers/usb/gadget/udc/mv_u3d_core.c index 6f3be0ba9ac8..8d726bd767fd 100644 --- a/drivers/usb/gadget/udc/mv_u3d_core.c +++ b/drivers/usb/gadget/udc/mv_u3d_core.c @@ -493,30 +493,32 @@ mv_u3d_start_queue(struct mv_u3d_ep *ep) ret = usb_gadget_map_request(&u3d->gadget, &req->req, mv_u3d_ep_dir(ep)); if (ret) - return ret; + goto break_processing; req->req.status = -EINPROGRESS; req->req.actual = 0; req->trb_count = 0; - /* build trbs and push them to device queue */ - if (!mv_u3d_req_to_trb(req)) { - ret = mv_u3d_queue_trb(ep, req); - if (ret) { - ep->processing = 0; - return ret; - } - } else { - ep->processing = 0; + /* build trbs */ + ret = mv_u3d_req_to_trb(req); + if (ret) { dev_err(u3d->dev, "%s, mv_u3d_req_to_trb fail\n", __func__); - return -ENOMEM; + goto break_processing; } + /* and push them to device queue */ + ret = mv_u3d_queue_trb(ep, req); + if (ret) + goto break_processing; + /* irq handler advances the queue */ - if (req) - list_add_tail(&req->queue, &ep->queue); + list_add_tail(&req->queue, &ep->queue); return 0; + +break_processing: + ep->processing = 0; + return ret; } static int mv_u3d_ep_enable(struct usb_ep *_ep, -- 2.7.4