mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/7] usb: gadget: fastboot: drop unnecessary global variable
Date: Fri,  7 Dec 2018 11:34:00 +0100	[thread overview]
Message-ID: <20181207103405.27365-3-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20181207103405.27365-1-s.hauer@pengutronix.de>

Polling for the status of a request does not require a global variable.
We can poll for the status directly.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/usb/gadget/f_fastboot.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index a5b2564814..61cc0b2e62 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -182,15 +182,8 @@ static struct usb_gadget_strings *fastboot_strings[] = {
 
 static void rx_handler_command(struct usb_ep *ep, struct usb_request *req);
 
-static int in_req_complete;
-
 static void fastboot_complete(struct usb_ep *ep, struct usb_request *req)
 {
-	int status = req->status;
-
-	in_req_complete = 1;
-
-	pr_debug("status: %d ep '%s' trans: %d\n", status, ep->name, req->actual);
 }
 
 static struct usb_request *fastboot_alloc_request(struct usb_ep *ep)
@@ -540,19 +533,22 @@ static int fastboot_tx_write(struct f_fastboot *f_fb, const char *buffer, unsign
 
 	memcpy(in_req->buf, buffer, buffer_size);
 	in_req->length = buffer_size;
-	in_req_complete = 0;
+
 	ret = usb_ep_queue(f_fb->in_ep, in_req);
 	if (ret)
 		pr_err("Error %d on queue\n", ret);
 
 	start = get_time_ns();
 
-	while (!in_req_complete) {
+	while (in_req->status == -EINPROGRESS) {
 		if (is_timeout(start, 2 * SECOND))
 			return -ETIMEDOUT;
 		usb_gadget_poll();
 	}
 
+	if (in_req->status)
+		pr_err("Failed to send answer: %d\n", in_req->status);
+
 	return 0;
 }
 
-- 
2.19.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2018-12-07 10:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-07 10:33 [PATCH 0/7] Fastboot improvements Sascha Hauer
2018-12-07 10:33 ` [PATCH 1/7] usb: gadget: fastboot: pass message type as enum Sascha Hauer
2018-12-07 10:34 ` Sascha Hauer [this message]
2018-12-07 10:34 ` [PATCH 3/7] usb: gadget: fastboot: remove unnecessary context setting Sascha Hauer
2018-12-07 10:34 ` [PATCH 4/7] usb: gadget: fastboot: tell host that we are going to shutdown Sascha Hauer
2018-12-07 10:34 ` [PATCH 5/7] usb: gadget: fastboot: be more informative on booting Sascha Hauer
2018-12-07 10:34 ` [PATCH 6/7] usb: gadget: fastboot: simplify reboot Sascha Hauer
2018-12-07 10:34 ` [PATCH 7/7] usb: gadget: fastboot: print fastboot messages also to the logs Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181207103405.27365-3-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox