Skip to content

Commit

Permalink
mtd: rawnand: brcmnand: Move OF operations out of brcmnand_init_cs()
Browse files Browse the repository at this point in the history
In order to initialize a given chip select object for use by the
brcmnand driver, move all of the Device Tree specific routines outside
of brcmnand_init_cs() in order to make it usable in a platform data
configuration which will be necessary for supporting BCMA chips.

No functional changes introduced.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220107184614.2670254-5-f.fainelli@gmail.com
  • Loading branch information
Florian Fainelli authored and Miquel Raynal committed Jan 23, 2022
1 parent c0d08a1 commit 75ac944
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions drivers/mtd/nand/raw/brcmnand/brcmnand.c
Original file line number Diff line number Diff line change
Expand Up @@ -2768,7 +2768,7 @@ static const struct nand_controller_ops brcmnand_controller_ops = {
.attach_chip = brcmnand_attach_chip,
};

static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn)
static int brcmnand_init_cs(struct brcmnand_host *host)
{
struct brcmnand_controller *ctrl = host->ctrl;
struct device *dev = ctrl->dev;
Expand All @@ -2777,16 +2777,9 @@ static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn)
int ret;
u16 cfg_offs;

ret = of_property_read_u32(dn, "reg", &host->cs);
if (ret) {
dev_err(dev, "can't get chip-select\n");
return -ENXIO;
}

mtd = nand_to_mtd(&host->chip);
chip = &host->chip;

nand_set_flash_node(chip, dn);
nand_set_controller_data(chip, host);
mtd->name = devm_kasprintf(dev, GFP_KERNEL, "brcmnand.%d",
host->cs);
Expand Down Expand Up @@ -3193,7 +3186,16 @@ int brcmnand_probe(struct platform_device *pdev, struct brcmnand_soc *soc)
host->pdev = pdev;
host->ctrl = ctrl;

ret = brcmnand_init_cs(host, child);
ret = of_property_read_u32(child, "reg", &host->cs);
if (ret) {
dev_err(dev, "can't get chip-select\n");
devm_kfree(dev, host);
continue;
}

nand_set_flash_node(&host->chip, child);

ret = brcmnand_init_cs(host);
if (ret) {
devm_kfree(dev, host);
continue; /* Try all chip-selects */
Expand Down

0 comments on commit 75ac944

Please sign in to comment.