diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-02-04 15:49:00 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-02-04 15:49:00 +0100 |
commit | da5fe0ba470283b384760c4976815fc20c1d45bd (patch) | |
tree | 11f2a08de885570d5d8c453f0c8b384427c666c0 /fs/tftp.c | |
parent | aacd51bfd2d20138b6f9c549fb4f1aa66e88243b (diff) | |
parent | 195310fd7b48e2c1198f216f9b4122d8f63e620e (diff) | |
download | barebox-da5fe0ba470283b384760c4976815fc20c1d45bd.tar.gz barebox-da5fe0ba470283b384760c4976815fc20c1d45bd.tar.xz |
Merge branch 'for-next/misc'
Diffstat (limited to 'fs/tftp.c')
-rw-r--r-- | fs/tftp.c | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -246,6 +246,11 @@ static void tftp_parse_oack(struct file_priv *priv, unsigned char *pkt, int len) } } +static void tftp_timer_reset(struct file_priv *priv) +{ + priv->progress_timeout = priv->resend_timeout = get_time_ns(); +} + static void tftp_handler(void *ctx, char *packet, unsigned len) { struct file_priv *priv = ctx; @@ -282,6 +287,9 @@ static void tftp_handler(void *ctx, char *packet, unsigned len) } priv->block++; + + tftp_timer_reset(priv); + if (priv->state == STATE_LAST) { priv->state = STATE_DONE; break; @@ -335,6 +343,8 @@ static void tftp_handler(void *ctx, char *packet, unsigned len) priv->last_block = priv->block; + tftp_timer_reset(priv); + kfifo_put(priv->fifo, pkt + 2, len); if (len < priv->blocksize) { @@ -364,11 +374,6 @@ static void tftp_handler(void *ctx, char *packet, unsigned len) } } -static void tftp_timer_reset(struct file_priv *priv) -{ - priv->progress_timeout = priv->resend_timeout = get_time_ns(); -} - static struct file_priv *tftp_do_open(struct device_d *dev, int accmode, const char *filename) { @@ -549,8 +554,6 @@ static int tftp_read(struct device_d *dev, FILE *f, void *buf, size_t insize) debug("%s %zu\n", __func__, insize); - tftp_timer_reset(priv); - while (insize) { now = kfifo_get(priv->fifo, buf, insize); if (priv->state == STATE_DONE) @@ -561,10 +564,8 @@ static int tftp_read(struct device_d *dev, FILE *f, void *buf, size_t insize) insize -= now; } - if (TFTP_FIFO_SIZE - kfifo_len(priv->fifo) >= priv->blocksize) { + if (TFTP_FIFO_SIZE - kfifo_len(priv->fifo) >= priv->blocksize) tftp_send(priv); - tftp_timer_reset(priv); - } ret = tftp_poll(priv); if (ret == TFTP_ERR_RESEND) |