From: "Rafał Miłecki" <zajec5@gmail.com>
To: linux-mtd@lists.infradead.org,
David Woodhouse <David.Woodhouse@intel.com>,
Artem Bityutskiy <dedekind1@gmail.com>,
Brian Norris <computersforpeace@gmail.com>
Cc: "Rafał Miłecki" <zajec5@gmail.com>
Subject: [PATCH] mtd: spi-nor: allow NULL as spi_device_id in spi_nor_scan
Date: Thu, 7 Aug 2014 19:13:21 +0200 [thread overview]
Message-ID: <1407431601-22312-1-git-send-email-zajec5@gmail.com> (raw)
Now we allow customized read_id handlers we should allow passing NULL
as a struct spi_device_id pointer. In such case we should simply make
use of the read_id callback and let driver read the flash ID.
At some point we may try to remove this argument completely.
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
This is based on top of
mtd: move support for struct flash_platform_data's "type" into m25p80
---
drivers/mtd/spi-nor/spi-nor.c | 34 ++++++++++++++--------------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index d733b16..45610b2 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -906,29 +906,23 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
if (ret)
return ret;
- info = (void *)id->driver_data;
-
- if (info->jedec_id) {
- const struct spi_device_id *jid;
-
- jid = nor->read_id(nor);
- if (IS_ERR(jid)) {
- return PTR_ERR(jid);
- } else if (jid != id) {
- /*
- * JEDEC knows better, so overwrite platform ID. We
- * can't trust partitions any longer, but we'll let
- * mtd apply them anyway, since some partitions may be
- * 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",
- jid->name, id->name);
- id = jid;
- info = (void *)jid->driver_data;
+ if (id) {
+ info = (void *)id->driver_data;
+ if (info->jedec_id) {
+ dev_warn(dev,
+ "passed SPI device ID (%s) contains JEDEC, ignoring it, driver should be fixed!\n",
+ id->name);
+ id = NULL;
}
}
+ if (!id) {
+ id = nor->read_id(nor);
+ if (IS_ERR(id))
+ return PTR_ERR(id);
+ }
+ info = (void *)id->driver_data;
+
mutex_init(&nor->lock);
/*
--
1.8.4.5
next reply other threads:[~2014-08-07 17:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-07 17:13 Rafał Miłecki [this message]
2014-08-16 2:02 ` [PATCH] mtd: spi-nor: allow NULL as spi_device_id in spi_nor_scan 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=1407431601-22312-1-git-send-email-zajec5@gmail.com \
--to=zajec5@gmail.com \
--cc=David.Woodhouse@intel.com \
--cc=computersforpeace@gmail.com \
--cc=dedekind1@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox