linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: Hauke Mehrtens <hauke@hauke-m.de>,
	linux-mtd@lists.infradead.org,
	David Woodhouse <David.Woodhouse@intel.com>,
	Artem Bityutskiy <dedekind1@gmail.com>
Subject: Re: [PATCH] mtd: spi-nor: allow NULL as chip name and try to auto detect it
Date: Mon, 1 Dec 2014 00:40:23 -0800	[thread overview]
Message-ID: <20141201084023.GH29070@brian-ubuntu> (raw)
In-Reply-To: <1413993900-23155-1-git-send-email-zajec5@gmail.com>

On Wed, Oct 22, 2014 at 06:05:00PM +0200, Rafał Miłecki wrote:
> This will allow spi-nor users to plainly use JEDEC to detect flash chip.
> 
> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
> ---
>  drivers/mtd/spi-nor/spi-nor.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index ee777a4..1facaac 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -937,13 +937,21 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
>  	if (ret)
>  		return ret;
>  
> -	id = spi_nor_match_id(name);
> +	/* Try to auto-detect if chip name wasn't specified */
> +	if (!name)
> +		id = spi_nor_read_id(nor);
> +	else
> +		id = spi_nor_match_id(name);
>  	if (!id)
>  		return -ENOENT;
>  
>  	info = (void *)id->driver_data;
>  
> -	if (info->jedec_id) {
> +	/*
> +	 * If caller has specified name of flash model that can normally be
> +	 * detected using JEDEC, let's verify it.
> +	 */
> +	if (name && info->jedec_id) {

This part doesn't apply cleanly any more.

>  		const struct spi_device_id *jid;
>  
>  		jid = spi_nor_read_id(nor);

I think this is a good time to consider this question: how do we
*really* want a SPI NOR driver to interact with spi-nor.c, regarding
device detection? I like how this patch removes the string-matching
requirement, so we can just auto-detect by JEDEC RDID alone. But I don't
like how it leaves around the function parameter 'name', which really
we should really be moving to deprecate if possible.

Anyway, I can take a rebased version of this patch. But I'd like to
encourage more thought here for the future. I don't yet have a specific
proposal, so any thoughts are welcome.

Brian

  parent reply	other threads:[~2014-12-01  8:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-22 16:05 [PATCH] mtd: spi-nor: allow NULL as chip name and try to auto detect it Rafał Miłecki
2014-11-28  8:24 ` Rafał Miłecki
2014-12-01  8:40 ` Brian Norris [this message]
2014-12-01  9:49   ` Rafał Miłecki
2014-12-17  1:15     ` Brian Norris
2014-12-17  6:19       ` Rafał Miłecki
2014-12-17  6:50         ` Brian Norris
2014-12-01  8:42 ` [PATCH V2] " Rafał Miłecki
2014-12-01  8:53   ` Brian Norris

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=20141201084023.GH29070@brian-ubuntu \
    --to=computersforpeace@gmail.com \
    --cc=David.Woodhouse@intel.com \
    --cc=dedekind1@gmail.com \
    --cc=hauke@hauke-m.de \
    --cc=linux-mtd@lists.infradead.org \
    --cc=zajec5@gmail.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).