All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: <Tudor.Ambarus@microchip.com>
Cc: linux-mtd@lists.infradead.org, dan.carpenter@oracle.com
Subject: Re: [PATCH] mtd: spi-nor: Make sure nor->spimem and nor->controller_ops are mutually exclusive
Date: Mon, 11 Nov 2019 16:59:25 +0100	[thread overview]
Message-ID: <20191111165925.3eb56e95@collabora.com> (raw)
In-Reply-To: <20191111094358.8271-1-tudor.ambarus@microchip.com>

On Mon, 11 Nov 2019 09:44:08 +0000
<Tudor.Ambarus@microchip.com> wrote:

> From: Tudor Ambarus <tudor.ambarus@microchip.com>
> 
> Expand the spi_nor_check() to make sure that nor->spimem and
> nor->controller_ops are mutually exclusive.
> 
> Fixes: b35b9a10362d ("mtd: spi-nor: Move m25p80 code in spi-nor.c")
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

> ---
> v3:
> - split checks for better error accuracy
> - s/mutual/mutually
> 
>  drivers/mtd/spi-nor/spi-nor.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index 824649eecd59..f5d24ccf5108 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -2878,6 +2878,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
>  static int spi_nor_check(struct spi_nor *nor)
>  {
>  	if (!nor->dev ||
> +	    (!nor->spimem && !nor->controller_ops) ||
>  	    (!nor->spimem && nor->controller_ops &&
>  	    (!nor->controller_ops->read ||
>  	     !nor->controller_ops->write ||
> @@ -2887,6 +2888,11 @@ static int spi_nor_check(struct spi_nor *nor)
>  		return -EINVAL;
>  	}
>  
> +	if (nor->spimem && nor->controller_ops) {
> +		dev_err(nor->dev, "nor->spimem and nor->controller_ops are mutually exclusive, please set just one of them.\n");
> +		return -EINVAL;
> +	}
> +
>  	return 0;
>  }
>  


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2019-11-11 15:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-25  9:03 [bug report] mtd: spi-nor: Introduce 'struct spi_nor_controller_ops' Dan Carpenter
2019-10-25 11:24 ` Tudor.Ambarus
2019-10-25 12:32   ` [PATCH] mtd: spi-nor: Move condition to avoid a NULL check Tudor.Ambarus
2019-10-25 12:37     ` Dan Carpenter
2019-10-25 14:28     ` [PATCH v2 1/2] mtd: spi-nor: Make sure nor->spimem and nor->controller_ops are mutual exclusive Tudor.Ambarus
2019-10-25 14:28       ` [PATCH v2 2/2] mtd: spi-nor: Move condition to avoid a NULL check Tudor.Ambarus
2019-11-11  9:08         ` Boris Brezillon
2019-11-11 19:28         ` Tudor.Ambarus
2019-11-11  9:02       ` [PATCH v2 1/2] mtd: spi-nor: Make sure nor->spimem and nor->controller_ops are mutual exclusive Boris Brezillon
2019-11-11  9:44         ` [PATCH] mtd: spi-nor: Make sure nor->spimem and nor->controller_ops are mutually exclusive Tudor.Ambarus
2019-11-11 15:59           ` Boris Brezillon [this message]
2019-11-11 19:26           ` Tudor.Ambarus

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=20191111165925.3eb56e95@collabora.com \
    --to=boris.brezillon@collabora.com \
    --cc=Tudor.Ambarus@microchip.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-mtd@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.