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