On Fri, 18 Jan 2019 22:06:15 +0100 Linus Walleij <linus.walleij@xxxxxxxxxx> wrote: > This disables the NAND on remove() and the errorpath, > making sure the chipselect gets deasserted when the > NAND is not in use. > > Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx> > --- > drivers/mtd/nand/raw/fsmc_nand.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c > index 4050843dd35e..118b1b1cd8da 100644 > --- a/drivers/mtd/nand/raw/fsmc_nand.c > +++ b/drivers/mtd/nand/raw/fsmc_nand.c > @@ -979,6 +979,7 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) > dma_cap_mask_t mask; > int ret = 0; > u32 pid; > + u32 val; > int i; > > /* Allocate memory for the device structure (and zero it) */ > @@ -1120,6 +1121,9 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) > if (host->mode == USE_DMA_ACCESS) > dma_release_channel(host->read_dma_chan); > disable_clk: > + val = readl(host->regs_va + FSMC_PC); > + val &= ~FSMC_ENABLE; > + writel(val, host->regs_va + FSMC_PC); Can you move this code in a separate function so that you don't have to duplicate the logic in fsmc_nand_remove()? > clk_disable_unprepare(host->clk); > > return ret; > @@ -1131,10 +1135,15 @@ static int __init fsmc_nand_probe(struct platform_device *pdev) > static int fsmc_nand_remove(struct platform_device *pdev) > { > struct fsmc_nand_data *host = platform_get_drvdata(pdev); > + u32 val; > > if (host) { > nand_release(&host->nand); > > + val = readl(host->regs_va + FSMC_PC); > + val &= ~FSMC_ENABLE; > + writel(val, host->regs_va + FSMC_PC); > + > if (host->mode == USE_DMA_ACCESS) { > dma_release_channel(host->write_dma_chan); > dma_release_channel(host->read_dma_chan); ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/