linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: <Tudor.Ambarus@microchip.com>
Cc: vigneshr@ti.com, richard@nod.at, linux-kernel@vger.kernel.org,
	marek.vasut@gmail.com, linux-mtd@lists.infradead.org,
	miquel.raynal@bootlin.com, computersforpeace@gmail.com,
	dwmw2@infradead.org
Subject: Re: [PATCH 3/3] mtd: spi-nor: Introduce spi_nor_get_flash_info()
Date: Thu, 1 Aug 2019 08:49:02 +0200	[thread overview]
Message-ID: <20190801084902.0cddd236@collabora.com> (raw)
In-Reply-To: <20190731091835.27766-4-tudor.ambarus@microchip.com>

On Wed, 31 Jul 2019 09:18:49 +0000
<Tudor.Ambarus@microchip.com> wrote:

> From: Tudor Ambarus <tudor.ambarus@microchip.com>
> 
> Dedicate a function for getting the pointer to the flash_info
> const struct. Trim a bit the spi_nor_scan() huge function.
> 
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>

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

> ---
>  drivers/mtd/spi-nor/spi-nor.c | 52 ++++++++++++++++++++++++++-----------------
>  1 file changed, 32 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index c322d7cd8216..636f065cc869 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -4800,25 +4800,10 @@ static int spi_nor_set_addr_width(struct spi_nor *nor)
>  	return 0;
>  }
>  
> -int spi_nor_scan(struct spi_nor *nor, const char *name,
> -		 const struct spi_nor_hwcaps *hwcaps)
> +static const struct flash_info *spi_nor_get_flash_info(struct spi_nor *nor,
> +						       const char *name)
>  {
> -	struct spi_nor_flash_parameter params;
>  	const struct flash_info *info = NULL;
> -	struct device *dev = nor->dev;
> -	struct mtd_info *mtd = &nor->mtd;
> -	struct device_node *np = spi_nor_get_flash_node(nor);
> -	int ret;
> -	int i;
> -
> -	ret = spi_nor_check(nor);
> -	if (ret)
> -		return ret;
> -
> -	/* Reset SPI protocol for all commands. */
> -	nor->reg_proto = SNOR_PROTO_1_1_1;
> -	nor->read_proto = SNOR_PROTO_1_1_1;
> -	nor->write_proto = SNOR_PROTO_1_1_1;
>  
>  	if (name)
>  		info = spi_nor_match_id(name);
> @@ -4826,7 +4811,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
>  	if (!info)
>  		info = spi_nor_read_id(nor);
>  	if (IS_ERR_OR_NULL(info))
> -		return -ENOENT;
> +		return ERR_PTR(-ENOENT);
>  
>  	/*
>  	 * If caller has specified name of flash model that can normally be
> @@ -4837,7 +4822,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
>  
>  		jinfo = spi_nor_read_id(nor);
>  		if (IS_ERR(jinfo)) {
> -			return PTR_ERR(jinfo);
> +			return jinfo;
>  		} else if (jinfo != info) {
>  			/*
>  			 * JEDEC knows better, so overwrite platform ID. We
> @@ -4846,12 +4831,39 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
>  			 * marked read-only, and we don't want to lose that
>  			 * information, even if it's not 100% accurate.
>  			 */
> -			dev_warn(dev, "found %s, expected %s\n",
> +			dev_warn(nor->dev, "found %s, expected %s\n",
>  				 jinfo->name, info->name);
>  			info = jinfo;
>  		}
>  	}
>  
> +	return info;
> +}
> +
> +int spi_nor_scan(struct spi_nor *nor, const char *name,
> +		 const struct spi_nor_hwcaps *hwcaps)
> +{
> +	struct spi_nor_flash_parameter params;
> +	const struct flash_info *info;
> +	struct device *dev = nor->dev;
> +	struct mtd_info *mtd = &nor->mtd;
> +	struct device_node *np = spi_nor_get_flash_node(nor);
> +	int ret;
> +	int i;
> +
> +	ret = spi_nor_check(nor);
> +	if (ret)
> +		return ret;
> +
> +	/* Reset SPI protocol for all commands. */
> +	nor->reg_proto = SNOR_PROTO_1_1_1;
> +	nor->read_proto = SNOR_PROTO_1_1_1;
> +	nor->write_proto = SNOR_PROTO_1_1_1;
> +
> +	info = spi_nor_get_flash_info(nor, name);
> +	if (IS_ERR(info))
> +		return PTR_ERR(info);
> +
>  	nor->info = info;
>  
>  	mutex_init(&nor->lock);


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

      reply	other threads:[~2019-08-01  6:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-31  9:18 [PATCH 0/3] mtd: spi-nor: move manuf out of the core - batch 3 Tudor.Ambarus
2019-07-31  9:18 ` [PATCH 1/3] mtd: spi-nor: Bring flash params init together Tudor.Ambarus
2019-08-01  6:46   ` Boris Brezillon
2019-07-31  9:18 ` [PATCH 2/3] mtd: spi_nor: Introduce spi_nor_set_addr_width() Tudor.Ambarus
2019-08-01  6:47   ` Boris Brezillon
2019-07-31  9:18 ` [PATCH 3/3] mtd: spi-nor: Introduce spi_nor_get_flash_info() Tudor.Ambarus
2019-08-01  6:49   ` 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=20190801084902.0cddd236@collabora.com \
    --to=boris.brezillon@collabora.com \
    --cc=Tudor.Ambarus@microchip.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.com \
    /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;
as well as URLs for NNTP newsgroup(s).