All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "Mark Rutland" <mark.rutland@arm.com>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Pawel Moll" <Pawel.Moll@arm.com>,
	"Ian Campbell" <ijc+devicetree@hellion.org.uk>,
	"Kumar Gala" <galak@codeaurora.org>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Stephen Warren" <swarren@wwwdotorg.org>,
	"Marek Vasut" <marex@denx.de>, "Rafał Miłecki" <zajec5@gmail.com>,
	linux-spi <linux-spi@vger.kernel.org>
Subject: Re: [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec,spi-nor"
Date: Tue, 21 Jul 2015 09:57:21 -0700	[thread overview]
Message-ID: <20150721165721.GJ24125@google.com> (raw)
In-Reply-To: <20150519013415.GV11598@ld-irv-0074>

On Mon, May 18, 2015 at 06:34:15PM -0700, Brian Norris wrote:
> So how about the following patch? It seems like we'll need to be able to
> ignore useless 'modalias' values in cases like this:
> 
> 	// modalias = "shinynewdevice"
> 	compatible = "myvendor,shinynewdevice", "jedec,spi-nor";
> 
> and also if somebody leaves off the entire shinynewdevice string:
> 
> 	// modalias = "spi-nor"
> 	compatible = "jedec,spi-nor";
> 
> So we rework the spi-nor library to not reject "bad" names, and just
> fall back to autodetection, and we add the .of_match_table to properly
> catch all "jedec,spi-nor".
> 
> Signed-off-by: Brian Norris <computerfsorpeace@gmail.com>

I realized this conversation ended in essentially an ack from Rafal,
with no other comments. So I've pushed this (with some extra commentary)
to l2-mtd.git. Holler if there are objections.

Thanks,
Brian

> ---
>  drivers/mtd/devices/m25p80.c  | 18 +++++++++++-------
>  drivers/mtd/spi-nor/spi-nor.c |  8 ++++----
>  2 files changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
> index 3af137f49ac9..30d608775f5a 100644
> --- a/drivers/mtd/devices/m25p80.c
> +++ b/drivers/mtd/devices/m25p80.c
> @@ -223,8 +223,6 @@ static int m25p_probe(struct spi_device *spi)
>  	 */
>  	if (data && data->type)
>  		flash_name = data->type;
> -	else if (!strcmp(spi->modalias, "spi-nor"))
> -		flash_name = NULL; /* auto-detect */
>  	else
>  		flash_name = spi->modalias;
>  
> @@ -301,19 +299,25 @@ static const struct spi_device_id m25p_ids[] = {
>  	{"w25q128"},	{"w25q256"},	{"cat25c11"},
>  	{"cat25c03"},	{"cat25c09"},	{"cat25c17"},	{"cat25128"},
>  
> -	/*
> -	 * Generic support for SPI NOR that can be identified by the JEDEC READ
> -	 * ID opcode (0x9F). Use this, if possible.
> -	 */
> -	{"spi-nor"},
>  	{ },
>  };
>  MODULE_DEVICE_TABLE(spi, m25p_ids);
>  
> +static const struct of_device_id m25p_of_table[] = {
> +	/*
> +	 * Generic compatibility for SPI NOR that can be identified by the
> +	 * JEDEC READ ID opcode (0x9F). Use this, if possible.
> +	 */
> +	{ .compatible = "jedec,spi-nor" },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, m25p_of_table);
> +
>  static struct spi_driver m25p80_driver = {
>  	.driver = {
>  		.name	= "m25p80",
>  		.owner	= THIS_MODULE,
> +		.of_match_table = m25p_of_table,
>  	},
>  	.id_table	= m25p_ids,
>  	.probe	= m25p_probe,
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index 14a5d2325dac..390d6fa0a53f 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -1003,11 +1003,11 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
>  	if (ret)
>  		return ret;
>  
> -	/* Try to auto-detect if chip name wasn't specified */
> -	if (!name)
> -		id = spi_nor_read_id(nor);
> -	else
> +	if (name)
>  		id = spi_nor_match_id(name);
> +	/* Try to auto-detect if chip name wasn't specified or not found */
> +	if (!id)
> +		id = spi_nor_read_id(nor);
>  	if (IS_ERR_OR_NULL(id))
>  		return -ENOENT;
>  
> -- 
> 1.9.1
> 

WARNING: multiple messages have this Message-ID (diff)
From: Brian Norris <computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Geert Uytterhoeven <geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
Cc: "Mark Rutland" <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	"Rob Herring" <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	"Pawel Moll" <Pawel.Moll-5wv7dgnIgG8@public.gmane.org>,
	"Ian Campbell"
	<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
	"Kumar Gala" <galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	"linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
	<linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"Stephen Warren"
	<swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>,
	"Marek Vasut" <marex-ynQEQJNshbs@public.gmane.org>,
	"Rafał Miłecki" <zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-spi <linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec,spi-nor"
Date: Tue, 21 Jul 2015 09:57:21 -0700	[thread overview]
Message-ID: <20150721165721.GJ24125@google.com> (raw)
In-Reply-To: <20150519013415.GV11598@ld-irv-0074>

On Mon, May 18, 2015 at 06:34:15PM -0700, Brian Norris wrote:
> So how about the following patch? It seems like we'll need to be able to
> ignore useless 'modalias' values in cases like this:
> 
> 	// modalias = "shinynewdevice"
> 	compatible = "myvendor,shinynewdevice", "jedec,spi-nor";
> 
> and also if somebody leaves off the entire shinynewdevice string:
> 
> 	// modalias = "spi-nor"
> 	compatible = "jedec,spi-nor";
> 
> So we rework the spi-nor library to not reject "bad" names, and just
> fall back to autodetection, and we add the .of_match_table to properly
> catch all "jedec,spi-nor".
> 
> Signed-off-by: Brian Norris <computerfsorpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

I realized this conversation ended in essentially an ack from Rafal,
with no other comments. So I've pushed this (with some extra commentary)
to l2-mtd.git. Holler if there are objections.

Thanks,
Brian

> ---
>  drivers/mtd/devices/m25p80.c  | 18 +++++++++++-------
>  drivers/mtd/spi-nor/spi-nor.c |  8 ++++----
>  2 files changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
> index 3af137f49ac9..30d608775f5a 100644
> --- a/drivers/mtd/devices/m25p80.c
> +++ b/drivers/mtd/devices/m25p80.c
> @@ -223,8 +223,6 @@ static int m25p_probe(struct spi_device *spi)
>  	 */
>  	if (data && data->type)
>  		flash_name = data->type;
> -	else if (!strcmp(spi->modalias, "spi-nor"))
> -		flash_name = NULL; /* auto-detect */
>  	else
>  		flash_name = spi->modalias;
>  
> @@ -301,19 +299,25 @@ static const struct spi_device_id m25p_ids[] = {
>  	{"w25q128"},	{"w25q256"},	{"cat25c11"},
>  	{"cat25c03"},	{"cat25c09"},	{"cat25c17"},	{"cat25128"},
>  
> -	/*
> -	 * Generic support for SPI NOR that can be identified by the JEDEC READ
> -	 * ID opcode (0x9F). Use this, if possible.
> -	 */
> -	{"spi-nor"},
>  	{ },
>  };
>  MODULE_DEVICE_TABLE(spi, m25p_ids);
>  
> +static const struct of_device_id m25p_of_table[] = {
> +	/*
> +	 * Generic compatibility for SPI NOR that can be identified by the
> +	 * JEDEC READ ID opcode (0x9F). Use this, if possible.
> +	 */
> +	{ .compatible = "jedec,spi-nor" },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, m25p_of_table);
> +
>  static struct spi_driver m25p80_driver = {
>  	.driver = {
>  		.name	= "m25p80",
>  		.owner	= THIS_MODULE,
> +		.of_match_table = m25p_of_table,
>  	},
>  	.id_table	= m25p_ids,
>  	.probe	= m25p_probe,
> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> index 14a5d2325dac..390d6fa0a53f 100644
> --- a/drivers/mtd/spi-nor/spi-nor.c
> +++ b/drivers/mtd/spi-nor/spi-nor.c
> @@ -1003,11 +1003,11 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
>  	if (ret)
>  		return ret;
>  
> -	/* Try to auto-detect if chip name wasn't specified */
> -	if (!name)
> -		id = spi_nor_read_id(nor);
> -	else
> +	if (name)
>  		id = spi_nor_match_id(name);
> +	/* Try to auto-detect if chip name wasn't specified or not found */
> +	if (!id)
> +		id = spi_nor_read_id(nor);
>  	if (IS_ERR_OR_NULL(id))
>  		return -ENOENT;
>  
> -- 
> 1.9.1
> 
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2015-07-21 16:57 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-14 17:32 [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec, spi-nor" Brian Norris
2015-05-14 17:32 ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec,spi-nor" Brian Norris
2015-05-14 17:46 ` Stephen Warren
2015-05-14 17:46   ` Stephen Warren
2015-05-14 17:46   ` Stephen Warren
2015-05-14 20:26   ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec, spi-nor" Geert Uytterhoeven
2015-05-14 20:26     ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec,spi-nor" Geert Uytterhoeven
2015-05-15 20:02     ` Brian Norris
2015-05-15 20:02       ` Brian Norris
2015-05-15 20:52       ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec, spi-nor" Rafał Miłecki
2015-05-15 20:52         ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec,spi-nor" Rafał Miłecki
2015-05-15 20:52         ` Rafał Miłecki
2015-05-18 14:42       ` Stephen Warren
2015-05-18 14:42         ` Stephen Warren
2015-05-18 14:42         ` Stephen Warren
2015-05-15 10:17 ` Mark Rutland
2015-05-15 10:17   ` Mark Rutland
2015-05-15 10:17   ` Mark Rutland
2015-05-15 19:55 ` Brian Norris
2015-05-15 19:55   ` Brian Norris
2015-05-18 10:45   ` Mark Rutland
2015-05-18 10:45     ` Mark Rutland
2015-05-18 10:45     ` Mark Rutland
2015-05-18 18:34     ` Brian Norris
2015-05-18 18:34       ` Brian Norris
2015-05-18 18:51       ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec, spi-nor" Geert Uytterhoeven
2015-05-18 18:51         ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec,spi-nor" Geert Uytterhoeven
2015-05-18 18:51         ` Geert Uytterhoeven
2015-05-19  1:34         ` Brian Norris
2015-05-19  1:34           ` Brian Norris
2015-05-19  7:27           ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec, spi-nor" Rafał Miłecki
2015-05-19  7:27             ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec,spi-nor" Rafał Miłecki
2015-05-20 21:35             ` Brian Norris
2015-05-20 21:35               ` Brian Norris
2015-05-20 21:35               ` Brian Norris
2015-05-21  7:12               ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec, spi-nor" Rafał Miłecki
2015-05-21  7:12                 ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec,spi-nor" Rafał Miłecki
2015-05-21  7:12                 ` Rafał Miłecki
2015-05-21  7:25                 ` Brian Norris
2015-05-21  7:25                   ` Brian Norris
2015-05-21  8:01                   ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec, spi-nor" Rafał Miłecki
2015-05-21  8:01                     ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec,spi-nor" Rafał Miłecki
2015-05-21  8:01                     ` Rafał Miłecki
2015-05-21  8:15                     ` Brian Norris
2015-05-21  8:15                       ` Brian Norris
2015-05-21  8:15                       ` Brian Norris
2015-05-21  8:25                       ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec, spi-nor" Rafał Miłecki
2015-05-21  8:25                         ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec,spi-nor" Rafał Miłecki
2015-05-21  8:25                         ` Rafał Miłecki
2015-05-21  8:39                         ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec, spi-nor" Geert Uytterhoeven
2015-05-21  8:39                           ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec,spi-nor" Geert Uytterhoeven
2015-05-21  8:39                           ` Geert Uytterhoeven
2015-05-21  8:50                           ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec, spi-nor" Rafał Miłecki
2015-05-21  8:50                             ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec,spi-nor" Rafał Miłecki
2015-05-21  8:50                             ` Rafał Miłecki
2015-05-21  8:58                             ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec, spi-nor" Geert Uytterhoeven
2015-05-21  8:58                               ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec,spi-nor" Geert Uytterhoeven
2015-05-21  8:58                               ` Geert Uytterhoeven
2015-05-21  9:31                               ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec, spi-nor" Rafał Miłecki
2015-05-21  9:31                                 ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec,spi-nor" Rafał Miłecki
2015-05-21  9:31                                 ` Rafał Miłecki
2015-05-21  9:39                                 ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec, spi-nor" Geert Uytterhoeven
2015-05-21  9:39                                   ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec,spi-nor" Geert Uytterhoeven
2015-05-21  9:47                                   ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec, spi-nor" Rafał Miłecki
2015-05-21  9:47                                     ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec,spi-nor" Rafał Miłecki
2015-05-21  9:47                                     ` Rafał Miłecki
2015-05-21  9:57                                   ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec, spi-nor" Rafał Miłecki
2015-05-21  9:57                                     ` [PATCH] Documentation: dt: mtd: replace "nor-jedec" binding with "jedec,spi-nor" Rafał Miłecki
2015-05-21  9:57                                     ` Rafał Miłecki
2015-07-21 16:57           ` Brian Norris [this message]
2015-07-21 16:57             ` 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=20150721165721.GJ24125@google.com \
    --to=computersforpeace@gmail.com \
    --cc=Pawel.Moll@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=geert@linux-m68k.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=marex@denx.de \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=swarren@wwwdotorg.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 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.