ar71xx: make rb750_nand driver compatible with 3.7
[openwrt.git] / target / linux / ar71xx / patches-3.6 / a06-rb750_nand-add-buffer-verification.patch
1 --- a/drivers/mtd/nand/rb750_nand.c
2 +++ b/drivers/mtd/nand/rb750_nand.c
3 @@ -110,7 +110,8 @@ static void rb750_nand_write(const u8 *b
4         __raw_readl(base + AR71XX_GPIO_REG_OE);
5  }
6  
7 -static void rb750_nand_read(u8 *read_buf, unsigned len)
8 +static int rb750_nand_read_verify(u8 *read_buf, unsigned len,
9 +                                 const u8 *verify_buf)
10  {
11         void __iomem *base = ath79_gpio_base;
12         unsigned i;
13 @@ -130,8 +131,13 @@ static void rb750_nand_read(u8 *read_buf
14                 /* deactivate RE line */
15                 __raw_writel(RB750_NAND_NRE, base + AR71XX_GPIO_REG_SET);
16  
17 -               read_buf[i] = data;
18 +               if (read_buf)
19 +                       read_buf[i] = data;
20 +               else if (verify_buf && verify_buf[i] != data)
21 +                       return -EFAULT;
22         }
23 +
24 +       return 0;
25  }
26  
27  static void rb750_nand_select_chip(struct mtd_info *mtd, int chip)
28 @@ -206,13 +212,13 @@ static void rb750_nand_cmd_ctrl(struct m
29  static u8 rb750_nand_read_byte(struct mtd_info *mtd)
30  {
31         u8 data = 0;
32 -       rb750_nand_read(&data, 1);
33 +       rb750_nand_read_verify(&data, 1, NULL);
34         return data;
35  }
36  
37  static void rb750_nand_read_buf(struct mtd_info *mtd, u8 *buf, int len)
38  {
39 -       rb750_nand_read(buf, len);
40 +       rb750_nand_read_verify(buf, len, NULL);
41  }
42  
43  static void rb750_nand_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
44 @@ -220,6 +226,11 @@ static void rb750_nand_write_buf(struct
45         rb750_nand_write(buf, len);
46  }
47  
48 +static int rb750_nand_verify_buf(struct mtd_info *mtd, const u8 *buf, int len)
49 +{
50 +       return rb750_nand_read_verify(NULL, len, buf);
51 +}
52 +
53  static void __init rb750_nand_gpio_init(struct rb750_nand_info *info)
54  {
55         void __iomem *base = ath79_gpio_base;
56 @@ -274,6 +285,7 @@ static int __devinit rb750_nand_probe(st
57         info->chip.read_byte    = rb750_nand_read_byte;
58         info->chip.write_buf    = rb750_nand_write_buf;
59         info->chip.read_buf     = rb750_nand_read_buf;
60 +       info->chip.verify_buf   = rb750_nand_verify_buf;
61  
62         info->chip.chip_delay   = 25;
63         info->chip.ecc.mode     = NAND_ECC_SOFT;