diff mbox series

[U-Boot,RFC,05/14] dfu: allow read with 0 data for EOF indication

Message ID 1563541046-6432-6-git-send-email-patrick.delaunay@st.com
State Superseded
Delegated to: Patrick Delaunay
Headers show
Series dfu: update dfu stack and use them for stm32mp1 | expand

Commit Message

Patrick DELAUNAY July 19, 2019, 12:57 p.m. UTC
This patch allows into the DFU backend to indicate that there is no
remaining data (for EOF for example). That allows users to read a
buffer greater than the device size; the dfu stack stops the read
request when the backend return a length=0 without error.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

 drivers/dfu/dfu.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Lukasz Majewski July 22, 2019, 8:05 a.m. UTC | #1
Hi Patrick,

> This patch allows into the DFU backend to indicate that there is no
> remaining data (for EOF for example). That allows users to read a
> buffer greater than the device size; the dfu stack stops the read
> request when the backend return a length=0 without error.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
> 
>  drivers/dfu/dfu.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
> index 01ec690..bcfa170 100644
> --- a/drivers/dfu/dfu.c
> +++ b/drivers/dfu/dfu.c
> @@ -395,6 +395,8 @@ static int dfu_read_buffer_fill(struct dfu_entity
> *dfu, void *buf, int size) debug("%s: Read error!\n", __func__);
>  				return ret;
>  			}
> +			if (dfu->b_left == 0)
> +				break;
>  			dfu->offset += dfu->b_left;
>  			dfu->r_left -= dfu->b_left;
>  

Reviewed-by: Lukasz Majewski <lukma@denx.de>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
diff mbox series

Patch

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 01ec690..bcfa170 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -395,6 +395,8 @@  static int dfu_read_buffer_fill(struct dfu_entity *dfu, void *buf, int size)
 				debug("%s: Read error!\n", __func__);
 				return ret;
 			}
+			if (dfu->b_left == 0)
+				break;
 			dfu->offset += dfu->b_left;
 			dfu->r_left -= dfu->b_left;