
This patch adds WATCHDOG_RESET() to loops for read/write/erase to avoid watchdog not being feeded in a long period.
Cc: Vignesh Raghavendra vigneshr@ti.com Signed-off-by: Weijie Gao weijie.gao@mediatek.com --- drivers/mtd/spi/spi-nor-core.c | 13 +++++++++++++ drivers/mtd/spi/spi-nor-tiny.c | 3 +++ 2 files changed, 16 insertions(+)
diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index 1acff745d1a..2049661f3ad 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -10,6 +10,7 @@ */
#include <common.h> +#include <watchdog.h> #include <linux/err.h> #include <linux/errno.h> #include <linux/log2.h> @@ -103,6 +104,8 @@ static ssize_t spi_nor_read_data(struct spi_nor *nor, loff_t from, size_t len, op.addr.val += op.data.nbytes; remaining -= op.data.nbytes; op.data.buf.in += op.data.nbytes; + + WATCHDOG_RESET(); }
return len; @@ -571,6 +574,8 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) ret = spi_nor_wait_till_ready(nor); if (ret) goto erase_err; + + WATCHDOG_RESET(); }
erase_err: @@ -963,6 +968,9 @@ static int sst_write_byteprogram(struct spi_nor *nor, loff_t to, size_t len, if (ret) goto sst_write_err; to++; + + if (actual % 0x100 == 0) + WATCHDOG_RESET(); }
sst_write_err: @@ -1014,6 +1022,9 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, goto sst_write_err; to += 2; nor->sst_write_second = true; + + if (actual % 0x100 == 0) + WATCHDOG_RESET(); } nor->sst_write_second = false;
@@ -1094,6 +1105,8 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len, goto write_err; *retlen += written; i += written; + + WATCHDOG_RESET(); }
write_err: diff --git a/drivers/mtd/spi/spi-nor-tiny.c b/drivers/mtd/spi/spi-nor-tiny.c index c19d468d62c..197a796b8af 100644 --- a/drivers/mtd/spi/spi-nor-tiny.c +++ b/drivers/mtd/spi/spi-nor-tiny.c @@ -10,6 +10,7 @@ */
#include <common.h> +#include <watchdog.h> #include <linux/err.h> #include <linux/errno.h> #include <linux/log2.h> @@ -103,6 +104,8 @@ static ssize_t spi_nor_read_data(struct spi_nor *nor, loff_t from, size_t len, op.addr.val += op.data.nbytes; remaining -= op.data.nbytes; op.data.buf.in += op.data.nbytes; + + WATCHDOG_RESET(); }
return len;