From: Patrick Delaunay <patrick.delaunay73@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] usb: gadget: dfu: add result for handle_getstatus()
Date: Fri, 16 Dec 2016 18:41:32 +0100 [thread overview]
Message-ID: <1481910092-13844-3-git-send-email-patrick.delaunay73@gmail.com> (raw)
In-Reply-To: <1481910092-13844-1-git-send-email-patrick.delaunay73@gmail.com>
From: Patrick Delaunay <patrick.delaunay@st.com>
harmonize result with other handle_XXX() functions: return int for size
remove the define RET_STAT_LEN : no more necessary
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com>
---
drivers/usb/gadget/f_dfu.c | 34 +++++++++++++---------------------
drivers/usb/gadget/f_dfu.h | 1 -
2 files changed, 13 insertions(+), 22 deletions(-)
diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
index 2790ddb..b9dd170 100644
--- a/drivers/usb/gadget/f_dfu.c
+++ b/drivers/usb/gadget/f_dfu.c
@@ -178,7 +178,7 @@ static inline int dfu_get_manifest_timeout(struct dfu_entity *dfu)
DFU_MANIFEST_POLL_TIMEOUT;
}
-static void handle_getstatus(struct usb_request *req)
+static int handle_getstatus(struct usb_request *req)
{
struct dfu_status *dstat = (struct dfu_status *)req->buf;
struct f_dfu *f_dfu = req->context;
@@ -210,6 +210,8 @@ static void handle_getstatus(struct usb_request *req)
dstat->bStatus = f_dfu->dfu_status;
dstat->bState = f_dfu->dfu_state;
dstat->iString = 0;
+
+ return sizeof(struct dfu_status);
}
static int handle_getstate(struct usb_request *req)
@@ -268,8 +270,7 @@ static int state_app_idle(struct f_dfu *f_dfu,
switch (ctrl->bRequest) {
case USB_REQ_DFU_GETSTATUS:
- handle_getstatus(req);
- value = RET_STAT_LEN;
+ value = handle_getstatus(req);
break;
case USB_REQ_DFU_GETSTATE:
value = handle_getstate(req);
@@ -296,8 +297,7 @@ static int state_app_detach(struct f_dfu *f_dfu,
switch (ctrl->bRequest) {
case USB_REQ_DFU_GETSTATUS:
- handle_getstatus(req);
- value = RET_STAT_LEN;
+ value = handle_getstatus(req);
break;
case USB_REQ_DFU_GETSTATE:
value = handle_getstate(req);
@@ -341,8 +341,7 @@ static int state_dfu_idle(struct f_dfu *f_dfu,
value = RET_ZLP;
break;
case USB_REQ_DFU_GETSTATUS:
- handle_getstatus(req);
- value = RET_STAT_LEN;
+ value = handle_getstatus(req);
break;
case USB_REQ_DFU_GETSTATE:
value = handle_getstate(req);
@@ -381,8 +380,7 @@ static int state_dfu_dnload_sync(struct f_dfu *f_dfu,
switch (ctrl->bRequest) {
case USB_REQ_DFU_GETSTATUS:
- handle_getstatus(req);
- value = RET_STAT_LEN;
+ value = handle_getstatus(req);
break;
case USB_REQ_DFU_GETSTATE:
value = handle_getstate(req);
@@ -405,8 +403,7 @@ static int state_dfu_dnbusy(struct f_dfu *f_dfu,
switch (ctrl->bRequest) {
case USB_REQ_DFU_GETSTATUS:
- handle_getstatus(req);
- value = RET_STAT_LEN;
+ value = handle_getstatus(req);
break;
default:
f_dfu->dfu_state = DFU_STATE_dfuERROR;
@@ -437,8 +434,7 @@ static int state_dfu_dnload_idle(struct f_dfu *f_dfu,
value = RET_ZLP;
break;
case USB_REQ_DFU_GETSTATUS:
- handle_getstatus(req);
- value = RET_STAT_LEN;
+ value = handle_getstatus(req);
break;
case USB_REQ_DFU_GETSTATE:
value = handle_getstate(req);
@@ -463,9 +459,8 @@ static int state_dfu_manifest_sync(struct f_dfu *f_dfu,
case USB_REQ_DFU_GETSTATUS:
/* We're MainfestationTolerant */
f_dfu->dfu_state = DFU_STATE_dfuMANIFEST;
- handle_getstatus(req);
+ value = handle_getstatus(req);
f_dfu->blk_seq_num = 0;
- value = RET_STAT_LEN;
req->complete = dnload_request_flush;
break;
case USB_REQ_DFU_GETSTATE:
@@ -491,9 +486,8 @@ static int state_dfu_manifest(struct f_dfu *f_dfu,
case USB_REQ_DFU_GETSTATUS:
/* We're MainfestationTolerant */
f_dfu->dfu_state = DFU_STATE_dfuIDLE;
- handle_getstatus(req);
+ value = handle_getstatus(req);
f_dfu->blk_seq_num = 0;
- value = RET_STAT_LEN;
puts("DOWNLOAD ... OK\nCtrl+C to exit ...\n");
break;
case USB_REQ_DFU_GETSTATE:
@@ -530,8 +524,7 @@ static int state_dfu_upload_idle(struct f_dfu *f_dfu,
value = RET_ZLP;
break;
case USB_REQ_DFU_GETSTATUS:
- handle_getstatus(req);
- value = RET_STAT_LEN;
+ value = handle_getstatus(req);
break;
case USB_REQ_DFU_GETSTATE:
value = handle_getstate(req);
@@ -554,8 +547,7 @@ static int state_dfu_error(struct f_dfu *f_dfu,
switch (ctrl->bRequest) {
case USB_REQ_DFU_GETSTATUS:
- handle_getstatus(req);
- value = RET_STAT_LEN;
+ value = handle_getstatus(req);
break;
case USB_REQ_DFU_GETSTATE:
value = handle_getstate(req);
diff --git a/drivers/usb/gadget/f_dfu.h b/drivers/usb/gadget/f_dfu.h
index 0c29954..a256577 100644
--- a/drivers/usb/gadget/f_dfu.h
+++ b/drivers/usb/gadget/f_dfu.h
@@ -51,7 +51,6 @@
#define RET_STALL -1
#define RET_ZLP 0
-#define RET_STAT_LEN 6
enum dfu_state {
DFU_STATE_appIDLE = 0,
--
1.9.1
next prev parent reply other threads:[~2016-12-16 17:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-16 17:41 [U-Boot] [PATCH 0/2] Series to clean handle_XXX() in f_dfu.c Patrick Delaunay
2016-12-16 17:41 ` [U-Boot] [PATCH 1/2] usb: gadget: dfu: correct size for USB_REQ_DFU_GETSTATE result Patrick Delaunay
2016-12-16 17:41 ` Patrick Delaunay [this message]
2017-02-21 22:36 ` [U-Boot] [PATCH 0/2] Series to clean handle_XXX() in f_dfu.c Lukasz Majewski
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=1481910092-13844-3-git-send-email-patrick.delaunay73@gmail.com \
--to=patrick.delaunay73@gmail.com \
--cc=u-boot@lists.denx.de \
/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