* [U-Boot] [PATCH v2] dfu, nand: add medium specific polltimeout function
@ 2014-04-11 5:59 Heiko Schocher
2014-04-11 7:44 ` Marek Vasut
2014-05-08 8:46 ` Lukasz Majewski
0 siblings, 2 replies; 3+ messages in thread
From: Heiko Schocher @ 2014-04-11 5:59 UTC (permalink / raw)
To: u-boot
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>
---
- changes for v2:
- add comment from Pantelis Antoniou
- add simple accessor for getting the poll timeout
dfu_get_manifest_timeout()
drivers/dfu/dfu_nand.c | 13 +++++++++++++
drivers/usb/gadget/f_dfu.c | 10 +++++++++-
include/dfu.h | 1 +
3 files changed, 23 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..e32b742 100644
--- a/drivers/usb/gadget/f_dfu.c
+++ b/drivers/usb/gadget/f_dfu.c
@@ -174,10 +174,17 @@ static void dnload_request_flush(struct usb_ep *ep, struct usb_request *req)
req->length, f_dfu->blk_seq_num);
}
+static inline int dfu_get_manifest_timeout(struct dfu_entity *dfu)
+{
+ return dfu->poll_timeout ? dfu->poll_timeout(dfu) :
+ DFU_MANIFEST_POLL_TIMEOUT;
+}
+
static void handle_getstatus(struct usb_request *req)
{
struct dfu_status *dstat = (struct dfu_status *)req->buf;
struct f_dfu *f_dfu = req->context;
+ struct dfu_entity *dfu = dfu_get_entity(f_dfu->altsetting);
dfu_set_poll_timeout(dstat, 0);
@@ -190,7 +197,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(dstat, dfu_get_manifest_timeout(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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH v2] dfu, nand: add medium specific polltimeout function
2014-04-11 5:59 [U-Boot] [PATCH v2] dfu, nand: add medium specific polltimeout function Heiko Schocher
@ 2014-04-11 7:44 ` Marek Vasut
2014-05-08 8:46 ` Lukasz Majewski
1 sibling, 0 replies; 3+ messages in thread
From: Marek Vasut @ 2014-04-11 7:44 UTC (permalink / raw)
To: u-boot
On Friday, April 11, 2014 at 07:59:47 AM, Heiko Schocher wrote:
> 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>
>
> ---
> - changes for v2:
> - add comment from Pantelis Antoniou
> - add simple accessor for getting the poll timeout
> dfu_get_manifest_timeout()
>
> drivers/dfu/dfu_nand.c | 13 +++++++++++++
> drivers/usb/gadget/f_dfu.c | 10 +++++++++-
> include/dfu.h | 1 +
> 3 files changed, 23 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
Don't you have to erase sectors before writing into them even on RAW NAND ?
[..]
Other than that:
Reviewed-by: Marek Vasut <marex@denx.de>
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH v2] dfu, nand: add medium specific polltimeout function
2014-04-11 5:59 [U-Boot] [PATCH v2] dfu, nand: add medium specific polltimeout function Heiko Schocher
2014-04-11 7:44 ` Marek Vasut
@ 2014-05-08 8:46 ` Lukasz Majewski
1 sibling, 0 replies; 3+ messages in thread
From: Lukasz Majewski @ 2014-05-08 8:46 UTC (permalink / raw)
To: u-boot
Hi Heiko,
> 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>
Applied to u-boot-dfu. Thanks.
--
Best regards,
Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-05-08 8:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-11 5:59 [U-Boot] [PATCH v2] dfu, nand: add medium specific polltimeout function Heiko Schocher
2014-04-11 7:44 ` Marek Vasut
2014-05-08 8:46 ` Lukasz Majewski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.