net: dsa: remove NULL check for priv and platform data
[platform/kernel/u-boot.git] / net / tftp.c
index 6fdb1a8..00ab7ca 100644 (file)
@@ -14,6 +14,7 @@
 #include <log.h>
 #include <mapmem.h>
 #include <net.h>
+#include <asm/global_data.h>
 #include <net/tftp.h>
 #include "bootp.h"
 #ifdef CONFIG_SYS_DIRECT_FLASH_TFTP
@@ -329,6 +330,12 @@ static void tftp_complete(void)
                        time_start * 1000, "/s");
        }
        puts("\ndone\n");
+       if (IS_ENABLED(CONFIG_CMD_BOOTEFI)) {
+               if (!tftp_put_active)
+                       efi_set_bootdev("Net", "", tftp_filename,
+                                       map_sysmem(tftp_load_addr, 0),
+                                       net_boot_file_size);
+       }
        net_set_state(NETLOOP_SUCCESS);
 }
 
@@ -624,8 +631,10 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
                tftp_cur_block++;
                tftp_cur_block %= TFTP_SEQUENCE_SIZE;
 
-               if (tftp_state == STATE_SEND_RRQ)
+               if (tftp_state == STATE_SEND_RRQ) {
                        debug("Server did not acknowledge any options!\n");
+                       tftp_next_ack = tftp_windowsize;
+               }
 
                if (tftp_state == STATE_SEND_RRQ || tftp_state == STATE_OACK ||
                    tftp_state == STATE_RECV_WRQ) {
@@ -660,6 +669,12 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
                        break;
                }
 
+               if (len < tftp_block_size) {
+                       tftp_send();
+                       tftp_complete();
+                       break;
+               }
+
                /*
                 *      Acknowledge the block just received, which will prompt
                 *      the remote for the next one.
@@ -668,11 +683,6 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
                        tftp_send();
                        tftp_next_ack += tftp_windowsize;
                }
-
-               if (len < tftp_block_size) {
-                       tftp_send();
-                       tftp_complete();
-               }
                break;
 
        case TFTP_ERROR:
@@ -841,9 +851,6 @@ void tftp_start(enum proto_t protocol)
                printf("Load address: 0x%lx\n", tftp_load_addr);
                puts("Loading: *\b");
                tftp_state = STATE_SEND_RRQ;
-#ifdef CONFIG_CMD_BOOTEFI
-               efi_set_bootdev("Net", "", tftp_filename);
-#endif
        }
 
        time_start = get_timer(0);