common: spl_fit: Default to IH_OS_U_BOOT if FIT_IMAGE_TINY enabled
[oweals/u-boot.git] / drivers / usb / gadget / f_sdp.c
index 43c5cfbb77a8a0e1ef66c978eb6d54629ba20d56..ae97ab2b497399ae8840fb12327b7f61c6581736 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * f_sdp.c -- USB HID Serial Download Protocol
  *
@@ -13,8 +14,6 @@
  * SKIP_DCD_HEADER are only stubs.
  *
  * Parts of the implementation are based on f_dfu and f_thor.
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <errno.h>
@@ -101,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;
@@ -277,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... ",
@@ -356,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) {