public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Boris Brezillon <bbrezillon@kernel.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Marek Vasut <marek.vasut@gmail.com>,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	linux-mtd@lists.infradead.org,
	Richard Weinberger <richard@nod.at>
Subject: Re: [PATCH 2/2] mtd: rawnand: fsmc: Disable NAND on remove()
Date: Mon, 21 Jan 2019 09:22:22 +0100	[thread overview]
Message-ID: <20190121092222.2794d873@bbrezillon> (raw)
In-Reply-To: <20190118210615.8286-1-linus.walleij@linaro.org>

On Fri, 18 Jan 2019 22:06:15 +0100
Linus Walleij <linus.walleij@linaro.org> 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@linaro.org>
> ---
>  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/

      reply	other threads:[~2019-01-21  8:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-18 21:06 [PATCH 2/2] mtd: rawnand: fsmc: Disable NAND on remove() Linus Walleij
2019-01-21  8:22 ` Boris Brezillon [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190121092222.2794d873@bbrezillon \
    --to=bbrezillon@kernel.org \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=richard@nod.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox