diff mbox series

[U-Boot] usb: gadget: f_sdp: Provide filesize env variable for downloaded images

Message ID 1542964884-30204-1-git-send-email-ynezz@true.cz
State Superseded
Delegated to: Lukasz Majewski
Headers show
Series [U-Boot] usb: gadget: f_sdp: Provide filesize env variable for downloaded images | expand

Commit Message

Petr Štetiar Nov. 23, 2018, 9:21 a.m. UTC
Currently it's not possible to get filesize of downloaded images and
it's impossible to automate some tasks in scripts.

Cc: Lukasz Majewski <lukma@denx.de>
Cc: Marek Vasut <marex@denx.de>
Cc: Stefan Agner <stefan.agner@toradex.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 drivers/usb/gadget/f_sdp.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Marek Vasut Nov. 23, 2018, 1:20 p.m. UTC | #1
On 11/23/2018 10:21 AM, Petr Štetiar wrote:
> Currently it's not possible to get filesize of downloaded images and
> it's impossible to automate some tasks in scripts.

... so ... what does this patch do about it ? That sort of thing should
be in the commit message.

> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Stefan Agner <stefan.agner@toradex.com>
> Signed-off-by: Petr Štetiar <ynezz@true.cz>
> ---
>  drivers/usb/gadget/f_sdp.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
> index 00a9f88..ae97ab2 100644
> --- a/drivers/usb/gadget/f_sdp.c
> +++ b/drivers/usb/gadget/f_sdp.c
> @@ -100,6 +100,7 @@ struct f_sdp {
>  	enum sdp_state			state;
>  	enum sdp_state			next_state;
>  	u32				dnl_address;
> +	u32				dnl_bytes;
>  	u32				dnl_bytes_remaining;
>  	u32				jmp_address;
>  	bool				always_send_status;
> @@ -276,6 +277,7 @@ static void sdp_rx_command_complete(struct usb_ep *ep, struct usb_request *req)
>  		sdp->state = SDP_STATE_RX_FILE_DATA;
>  		sdp->dnl_address = be32_to_cpu(cmd->addr);
>  		sdp->dnl_bytes_remaining = be32_to_cpu(cmd->cnt);
> +		sdp->dnl_bytes = sdp->dnl_bytes_remaining;
>  		sdp->next_state = SDP_STATE_IDLE;
>  
>  		printf("Downloading file of size %d to 0x%08x... ",
> @@ -355,6 +357,9 @@ static void sdp_rx_data_complete(struct usb_ep *ep, struct usb_request *req)
>  	if (sdp->dnl_bytes_remaining)
>  		return;
>  
> +#ifndef CONFIG_SPL_BUILD
> +	env_set_hex("filesize", sdp->dnl_bytes);
> +#endif
>  	printf("done\n");
>  
>  	switch (sdp->state) {
>
Stefan Agner Nov. 23, 2018, 3:52 p.m. UTC | #2
On 23.11.18 14:37, Petr Štetiar wrote:
> Currently it's not possible to get filesize of downloaded images and
> it's impossible to automate some tasks in scripts. So this patch adds
> `filesize` environment variable with size (as hex number in bytes) of
> the last successfully downloaded file via `sdp` command.

Nice addition!

Looks good to me:

Reviewed-by: Stefan Agner <stefan.agner@toradex.com>


--

Stefan

>
> Cc: Lukasz Majewski <lukma@denx.de>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Stefan Agner <stefan.agner@toradex.com>
> Signed-off-by: Petr Štetiar <ynezz@true.cz>
> ---
>
> Changes since v1:
>  * added more details to the commit message
>
>  drivers/usb/gadget/f_sdp.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
> index 00a9f88..ae97ab2 100644
> --- a/drivers/usb/gadget/f_sdp.c
> +++ b/drivers/usb/gadget/f_sdp.c
> @@ -100,6 +100,7 @@ struct f_sdp {
>  	enum sdp_state			state;
>  	enum sdp_state			next_state;
>  	u32				dnl_address;
> +	u32				dnl_bytes;
>  	u32				dnl_bytes_remaining;
>  	u32				jmp_address;
>  	bool				always_send_status;
> @@ -276,6 +277,7 @@ static void sdp_rx_command_complete(struct usb_ep *ep, struct usb_request *req)
>  		sdp->state = SDP_STATE_RX_FILE_DATA;
>  		sdp->dnl_address = be32_to_cpu(cmd->addr);
>  		sdp->dnl_bytes_remaining = be32_to_cpu(cmd->cnt);
> +		sdp->dnl_bytes = sdp->dnl_bytes_remaining;
>  		sdp->next_state = SDP_STATE_IDLE;
>  
>  		printf("Downloading file of size %d to 0x%08x... ",
> @@ -355,6 +357,9 @@ static void sdp_rx_data_complete(struct usb_ep *ep, struct usb_request *req)
>  	if (sdp->dnl_bytes_remaining)
>  		return;
>  
> +#ifndef CONFIG_SPL_BUILD
> +	env_set_hex("filesize", sdp->dnl_bytes);
> +#endif
>  	printf("done\n");
>  
>  	switch (sdp->state) {
diff mbox series

Patch

diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
index 00a9f88..ae97ab2 100644
--- a/drivers/usb/gadget/f_sdp.c
+++ b/drivers/usb/gadget/f_sdp.c
@@ -100,6 +100,7 @@  struct f_sdp {
 	enum sdp_state			state;
 	enum sdp_state			next_state;
 	u32				dnl_address;
+	u32				dnl_bytes;
 	u32				dnl_bytes_remaining;
 	u32				jmp_address;
 	bool				always_send_status;
@@ -276,6 +277,7 @@  static void sdp_rx_command_complete(struct usb_ep *ep, struct usb_request *req)
 		sdp->state = SDP_STATE_RX_FILE_DATA;
 		sdp->dnl_address = be32_to_cpu(cmd->addr);
 		sdp->dnl_bytes_remaining = be32_to_cpu(cmd->cnt);
+		sdp->dnl_bytes = sdp->dnl_bytes_remaining;
 		sdp->next_state = SDP_STATE_IDLE;
 
 		printf("Downloading file of size %d to 0x%08x... ",
@@ -355,6 +357,9 @@  static void sdp_rx_data_complete(struct usb_ep *ep, struct usb_request *req)
 	if (sdp->dnl_bytes_remaining)
 		return;
 
+#ifndef CONFIG_SPL_BUILD
+	env_set_hex("filesize", sdp->dnl_bytes);
+#endif
 	printf("done\n");
 
 	switch (sdp->state) {