0015-MTD-lantiq-xway-remove-endless-loop.patch 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. From 76e153079f02d26e3357302d2886a0c8aaaec64d Mon Sep 17 00:00:00 2001
  2. From: John Crispin <blogic@openwrt.org>
  3. Date: Sun, 28 Jul 2013 18:02:06 +0200
  4. Subject: [PATCH 15/36] MTD: lantiq: xway: remove endless loop
  5. The reset loop logic could run into a endless loop. Lets fix it as requested.
  6. --> http://lists.infradead.org/pipermail/linux-mtd/2012-September/044240.html
  7. Signed-off-by: John Crispin <blogic@openwrt.org>
  8. ---
  9. drivers/mtd/nand/xway_nand.c | 10 ++++++++--
  10. 1 file changed, 8 insertions(+), 2 deletions(-)
  11. --- a/drivers/mtd/nand/xway_nand.c
  12. +++ b/drivers/mtd/nand/xway_nand.c
  13. @@ -59,16 +59,22 @@ static u32 xway_latchcmd;
  14. static void xway_reset_chip(struct nand_chip *chip)
  15. {
  16. unsigned long nandaddr = (unsigned long) chip->IO_ADDR_W;
  17. + unsigned long timeout;
  18. unsigned long flags;
  19. nandaddr &= ~NAND_WRITE_ADDR;
  20. nandaddr |= NAND_WRITE_CMD;
  21. /* finish with a reset */
  22. + timeout = jiffies + msecs_to_jiffies(20);
  23. +
  24. spin_lock_irqsave(&ebu_lock, flags);
  25. writeb(NAND_WRITE_CMD_RESET, (void __iomem *) nandaddr);
  26. - while ((ltq_ebu_r32(EBU_NAND_WAIT) & NAND_WAIT_WR_C) == 0)
  27. - ;
  28. + do {
  29. + if ((ltq_ebu_r32(EBU_NAND_WAIT) & NAND_WAIT_WR_C) == 0)
  30. + break;
  31. + cond_resched();
  32. + } while (!time_after_eq(jiffies, timeout));
  33. spin_unlock_irqrestore(&ebu_lock, flags);
  34. }