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