0017-MTD-xway-fix-nand-locking.patch 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. From aa705c1b0860da91f2ed1a4c0b57337e6de689e1 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <blogic@openwrt.org>
  3. Date: Thu, 7 Aug 2014 18:55:31 +0200
  4. Subject: [PATCH 17/36] MTD: xway: fix nand locking
  5. Signed-off-by: John Crispin <blogic@openwrt.org>
  6. ---
  7. drivers/mtd/nand/xway_nand.c | 15 +++------------
  8. 1 file changed, 3 insertions(+), 12 deletions(-)
  9. --- a/drivers/mtd/nand/xway_nand.c
  10. +++ b/drivers/mtd/nand/xway_nand.c
  11. @@ -80,13 +80,16 @@ static void xway_reset_chip(struct nand_
  12. static void xway_select_chip(struct mtd_info *mtd, int chip)
  13. {
  14. + static unsigned long csflags;
  15. switch (chip) {
  16. case -1:
  17. ltq_ebu_w32_mask(NAND_CON_CE, 0, EBU_NAND_CON);
  18. ltq_ebu_w32_mask(NAND_CON_NANDM, 0, EBU_NAND_CON);
  19. + spin_unlock_irqrestore(&ebu_lock, csflags);
  20. break;
  21. case 0:
  22. + spin_lock_irqsave(&ebu_lock, csflags);
  23. ltq_ebu_w32_mask(0, NAND_CON_NANDM, EBU_NAND_CON);
  24. ltq_ebu_w32_mask(0, NAND_CON_CE, EBU_NAND_CON);
  25. break;
  26. @@ -99,7 +102,6 @@ static void xway_cmd_ctrl(struct mtd_inf
  27. {
  28. struct nand_chip *this = mtd->priv;
  29. unsigned long nandaddr = (unsigned long) this->IO_ADDR_W;
  30. - unsigned long flags;
  31. if (ctrl & NAND_CTRL_CHANGE) {
  32. if (ctrl & NAND_CLE)
  33. @@ -109,11 +111,9 @@ static void xway_cmd_ctrl(struct mtd_inf
  34. }
  35. if (cmd != NAND_CMD_NONE) {
  36. - spin_lock_irqsave(&ebu_lock, flags);
  37. writeb(cmd, (void __iomem *) (nandaddr | xway_latchcmd));
  38. while ((ltq_ebu_r32(EBU_NAND_WAIT) & NAND_WAIT_WR_C) == 0)
  39. ;
  40. - spin_unlock_irqrestore(&ebu_lock, flags);
  41. }
  42. }
  43. @@ -126,12 +126,9 @@ static unsigned char xway_read_byte(stru
  44. {
  45. struct nand_chip *this = mtd->priv;
  46. unsigned long nandaddr = (unsigned long) this->IO_ADDR_R;
  47. - unsigned long flags;
  48. int ret;
  49. - spin_lock_irqsave(&ebu_lock, flags);
  50. ret = ltq_r8((void __iomem *)(nandaddr | NAND_READ_DATA));
  51. - spin_unlock_irqrestore(&ebu_lock, flags);
  52. return ret;
  53. }
  54. @@ -140,26 +137,20 @@ static void xway_read_buf(struct mtd_inf
  55. {
  56. struct nand_chip *this = mtd->priv;
  57. unsigned long nandaddr = (unsigned long) this->IO_ADDR_R;
  58. - unsigned long flags;
  59. int i;
  60. - spin_lock_irqsave(&ebu_lock, flags);
  61. for (i = 0; i < len; i++)
  62. buf[i] = ltq_r8((void __iomem *)(nandaddr | NAND_READ_DATA));
  63. - spin_unlock_irqrestore(&ebu_lock, flags);
  64. }
  65. static void xway_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
  66. {
  67. struct nand_chip *this = mtd->priv;
  68. unsigned long nandaddr = (unsigned long) this->IO_ADDR_W;
  69. - unsigned long flags;
  70. int i;
  71. - spin_lock_irqsave(&ebu_lock, flags);
  72. for (i = 0; i < len; i++)
  73. ltq_w8(buf[i], (void __iomem *)(nandaddr | NAND_WRITE_DATA));
  74. - spin_unlock_irqrestore(&ebu_lock, flags);
  75. }
  76. static int xway_nand_probe(struct platform_device *pdev)