This code is required for tftpput, so move it into separate functions. Signed-off-by: Simon Glass <sjg@chromium.org>