public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] dfu, nand: add medium specific polltimeout function
Date: Thu, 10 Apr 2014 07:08:06 +0200	[thread overview]
Message-ID: <1397106486-1233-2-git-send-email-hs@denx.de> (raw)
In-Reply-To: <1397106486-1233-1-git-send-email-hs@denx.de>

add a possibility to add a medium specific polltimeout
function. So it is possible to define different
poll timeouts.

Used on nand medium, for setting the DFU_MANIFEST_POLL_TIMEOUT
only on nand ubi partitions, which is currently the only
usecase.

Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
---
 drivers/dfu/dfu_nand.c     | 13 +++++++++++++
 drivers/usb/gadget/f_dfu.c | 14 +++++++++++++-
 include/dfu.h              |  1 +
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/drivers/dfu/dfu_nand.c b/drivers/dfu/dfu_nand.c
index 2d07097..ccdbef6 100644
--- a/drivers/dfu/dfu_nand.c
+++ b/drivers/dfu/dfu_nand.c
@@ -163,6 +163,18 @@ static int dfu_flush_medium_nand(struct dfu_entity *dfu)
 	return ret;
 }
 
+unsigned int dfu_polltimeout_nand(struct dfu_entity *dfu)
+{
+	/*
+	 * Currently, Poll Timeout != 0 is only needed on nand
+	 * ubi partition, as the not used sectors need an erase
+	 */
+	if (dfu->data.nand.ubi)
+		return DFU_MANIFEST_POLL_TIMEOUT;
+
+	return DFU_DEFAULT_POLL_TIMEOUT;
+}
+
 int dfu_fill_entity_nand(struct dfu_entity *dfu, char *s)
 {
 	char *st;
@@ -211,6 +223,7 @@ int dfu_fill_entity_nand(struct dfu_entity *dfu, char *s)
 	dfu->read_medium = dfu_read_medium_nand;
 	dfu->write_medium = dfu_write_medium_nand;
 	dfu->flush_medium = dfu_flush_medium_nand;
+	dfu->poll_timeout = dfu_polltimeout_nand;
 
 	/* initial state */
 	dfu->inited = 0;
diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
index de75ff1..9128add 100644
--- a/drivers/usb/gadget/f_dfu.c
+++ b/drivers/usb/gadget/f_dfu.c
@@ -174,6 +174,17 @@ static void dnload_request_flush(struct usb_ep *ep, struct usb_request *req)
 		  req->length, f_dfu->blk_seq_num);
 }
 
+static void dfu_set_poll_timeout_manifest(struct dfu_status *dstat,
+					  struct f_dfu *f_dfu)
+{
+	struct dfu_entity *dfu = dfu_get_entity(f_dfu->altsetting);
+
+	if (dfu->poll_timeout)
+		dfu_set_poll_timeout(dstat, dfu->poll_timeout(dfu));
+	else
+		dfu_set_poll_timeout(dstat, DFU_MANIFEST_POLL_TIMEOUT);
+}
+
 static void handle_getstatus(struct usb_request *req)
 {
 	struct dfu_status *dstat = (struct dfu_status *)req->buf;
@@ -190,7 +201,8 @@ static void handle_getstatus(struct usb_request *req)
 		f_dfu->dfu_state = DFU_STATE_dfuMANIFEST;
 		break;
 	case DFU_STATE_dfuMANIFEST:
-		dfu_set_poll_timeout(dstat, DFU_MANIFEST_POLL_TIMEOUT);
+		dfu_set_poll_timeout_manifest(dstat, f_dfu);
+		break;
 	default:
 		break;
 	}
diff --git a/include/dfu.h b/include/dfu.h
index 6c71ecb..c7fd270 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -105,6 +105,7 @@ struct dfu_entity {
 			u64 offset, void *buf, long *len);
 
 	int (*flush_medium)(struct dfu_entity *dfu);
+	unsigned int (*poll_timeout)(struct dfu_entity *dfu);
 
 	struct list_head list;
 
-- 
1.8.3.1

  reply	other threads:[~2014-04-10  5:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-10  5:08 [U-Boot] [PATCH 1/2] musb-new, dfu: first send request answer then call completions Heiko Schocher
2014-04-10  5:08 ` Heiko Schocher [this message]
2014-04-10  7:54   ` [U-Boot] [PATCH 2/2] dfu, nand: add medium specific polltimeout function Marek Vasut
2014-04-10  8:29     ` Pantelis Antoniou
2014-04-10 10:08       ` Lukasz Majewski
2014-04-10 10:21         ` Heiko Schocher
2014-04-10 14:31           ` Lukasz Majewski
2014-04-11  4:22             ` Heiko Schocher
2014-04-11  7:20               ` Lukasz Majewski
2014-04-10 11:10         ` Marek Vasut
2014-04-10  7:50 ` [U-Boot] [PATCH 1/2] musb-new, dfu: first send request answer then call completions Marek Vasut
2014-05-08  8:47 ` 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=1397106486-1233-2-git-send-email-hs@denx.de \
    --to=hs@denx.de \
    --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