kernel: update kernel 3.18 to version 3.18.23
[openwrt/staging/chunkeey.git] / target / linux / sunxi / patches-4.1 / 115-mtd-fetch-randomizer-mode.patch
1 From eb7f9115409710732ebc4dfe1be629252280910e Mon Sep 17 00:00:00 2001
2 From: Boris BREZILLON <boris.brezillon@free-electrons.com>
3 Date: Mon, 28 Jul 2014 14:47:04 +0200
4 Subject: [PATCH] of: mtd: Add NAND randomizer mode retrieval
5
6 Add a of_get_nand_rnd_mode() helper function.
7
8 Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
9 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
10 ---
11 drivers/of/of_mtd.c | 35 +++++++++++++++++++++++++++++++++++
12 include/linux/of_mtd.h | 6 ++++++
13 2 files changed, 41 insertions(+)
14
15 --- a/drivers/of/of_mtd.c
16 +++ b/drivers/of/of_mtd.c
17 @@ -84,6 +84,41 @@ int of_get_nand_ecc_strength(struct devi
18 EXPORT_SYMBOL_GPL(of_get_nand_ecc_strength);
19
20 /**
21 + * It maps 'enum nand_rnd_modes_t' found in include/linux/mtd/nand.h
22 + * into the device tree binding of 'nand-rnd', so that MTD
23 + * device driver can get nand rnd from device tree.
24 + */
25 +static const char *nand_rnd_modes[] = {
26 + [NAND_RND_NONE] = "none",
27 + [NAND_RND_SOFT] = "soft",
28 + [NAND_RND_HW] = "hw",
29 +};
30 +
31 +/**
32 + * of_get_nand_rnd_mode - Get nand randomizer mode for given device_node
33 + * @np: Pointer to the given device_node
34 + *
35 + * The function gets randomizer mode string from property 'nand-rnd-mode',
36 + * and return its index in nand_rnd_modes table, or errno in error case.
37 + */
38 +int of_get_nand_rnd_mode(struct device_node *np)
39 +{
40 + const char *pm;
41 + int err, i;
42 +
43 + err = of_property_read_string(np, "nand-rnd-mode", &pm);
44 + if (err < 0)
45 + return err;
46 +
47 + for (i = 0; i < ARRAY_SIZE(nand_rnd_modes); i++)
48 + if (!strcasecmp(pm, nand_rnd_modes[i]))
49 + return i;
50 +
51 + return -ENODEV;
52 +}
53 +EXPORT_SYMBOL_GPL(of_get_nand_rnd_mode);
54 +
55 +/**
56 * of_get_nand_bus_width - Get nand bus witdh for given device_node
57 * @np: Pointer to the given device_node
58 *
59 --- a/include/linux/of_mtd.h
60 +++ b/include/linux/of_mtd.h
61 @@ -15,6 +15,7 @@
62 int of_get_nand_ecc_mode(struct device_node *np);
63 int of_get_nand_ecc_step_size(struct device_node *np);
64 int of_get_nand_ecc_strength(struct device_node *np);
65 +int of_get_nand_rnd_mode(struct device_node *np);
66 int of_get_nand_bus_width(struct device_node *np);
67 bool of_get_nand_on_flash_bbt(struct device_node *np);
68
69 @@ -34,6 +35,11 @@ static inline int of_get_nand_ecc_streng
70 {
71 return -ENOSYS;
72 }
73 +
74 +static inline int of_get_nand_rnd_mode(struct device_node *np)
75 +{
76 + return -ENOSYS;
77 +}
78
79 static inline int of_get_nand_bus_width(struct device_node *np)
80 {