34fd1b47eab4569654794430b27eb5165fbf13d8
[openwrt/staging/neocturne.git] /
1 From: Florian Fainelli <f.fainelli@gmail.com>
2 Subject: [PATCH v3 4/9] mtd: rawnand: brcmnand: Move OF operations out of brcmnand_init_cs()
3 Date: Fri, 07 Jan 2022 10:46:09 -0800
4 Content-Type: text/plain; charset="utf-8"
5
6 In order to initialize a given chip select object for use by the
7 brcmnand driver, move all of the Device Tree specific routines outside
8 of brcmnand_init_cs() in order to make it usable in a platform data
9 configuration which will be necessary for supporting BCMA chips.
10
11 No functional changes introduced.
12
13 Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
14 ---
15 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 20 +++++++++++---------
16 1 file changed, 11 insertions(+), 9 deletions(-)
17
18 --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
19 +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
20 @@ -2719,7 +2719,7 @@ static const struct nand_controller_ops
21 .attach_chip = brcmnand_attach_chip,
22 };
23
24 -static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn)
25 +static int brcmnand_init_cs(struct brcmnand_host *host)
26 {
27 struct brcmnand_controller *ctrl = host->ctrl;
28 struct device *dev = ctrl->dev;
29 @@ -2728,16 +2728,9 @@ static int brcmnand_init_cs(struct brcmn
30 int ret;
31 u16 cfg_offs;
32
33 - ret = of_property_read_u32(dn, "reg", &host->cs);
34 - if (ret) {
35 - dev_err(dev, "can't get chip-select\n");
36 - return -ENXIO;
37 - }
38 -
39 mtd = nand_to_mtd(&host->chip);
40 chip = &host->chip;
41
42 - nand_set_flash_node(chip, dn);
43 nand_set_controller_data(chip, host);
44 mtd->name = devm_kasprintf(dev, GFP_KERNEL, "brcmnand.%d",
45 host->cs);
46 @@ -3144,7 +3137,16 @@ int brcmnand_probe(struct platform_devic
47 host->pdev = pdev;
48 host->ctrl = ctrl;
49
50 - ret = brcmnand_init_cs(host, child);
51 + ret = of_property_read_u32(child, "reg", &host->cs);
52 + if (ret) {
53 + dev_err(dev, "can't get chip-select\n");
54 + devm_kfree(dev, host);
55 + continue;
56 + }
57 +
58 + nand_set_flash_node(&host->chip, child);
59 +
60 + ret = brcmnand_init_cs(host);
61 if (ret) {
62 devm_kfree(dev, host);
63 continue; /* Try all chip-selects */