From: Brian Norris <computersforpeace@gmail.com>
To: <linux-mtd@lists.infradead.org>
Cc: linux-kernel@vger.kernel.org,
"Javier Martinez Canillas" <javier@osg.samsung.com>,
"Rafał Miłecki" <zajec5@gmail.com>,
"Brian Norris" <computersforpeace@gmail.com>,
"Heiner Kallweit" <hkallweit1@gmail.com>
Subject: [PATCH 1/3] mtd: m25p80: fix module autoloading for "jedec, spi-nor" and "spi-nor"
Date: Mon, 16 Nov 2015 14:34:50 -0800 [thread overview]
Message-ID: <1447713292-91525-2-git-send-email-computersforpeace@gmail.com> (raw)
In-Reply-To: <1447713292-91525-1-git-send-email-computersforpeace@gmail.com>
Commit 43163022927b ("mtd: m25p80: allow arbitrary OF matching for
"jedec,spi-nor"") moved the "jedec,spi-nor" handling from the
spi_device_id table to the of_match_table, to better handle matching
complex device tree compatible strings. With that patch, device tree
support works as expected when m25p80.c is built into the kernel.
However, that commit ignored the fact that:
(1) (non-DT) platform devices might want to use the "spi-nor" string
for matching with this driver, rather than picking an arbitrary one
like "m25p80"
(2) the core SPI uevent/modalias code doesn't yet support kernel module
autoloading via of_match_table strings; so for DT-based devices, it
will only report (part of) the first compatible string used
Problem (1) has been reported previously, and I forgot to patch it up
afterward.
Problem (2) was noticed recently here:
http://lists.infradead.org/pipermail/linux-mtd/2015-October/062369.html
https://lkml.org/lkml/2015/11/12/574
Specifically, this patch fixes m25p80.ko module autoloading for cases
like this:
flash@xxx {
compatible = "jedec,spi-nor";
...
};
because modalias of "spi:spi-nor" (the only module loading info provided
by the SPI core for this device) will now be listed as an alias in
m25p80.ko.
Notably, it does *not* help cases like this:
flash@xxx {
compatible = "vendor,shiny-new-device", "jedec,spi-nor";
...
};
unless we also list "shiny-new-device" in m25p_ids[]. There has been
discussion on future work for this issue here:
https://lkml.org/lkml/2015/11/12/574
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
Tested module autoload with each of the following:
compatible = "m25p80";
compatible = "jedec,spi-nor";
drivers/mtd/devices/m25p80.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index f002a8f75374..151b453d0867 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -179,7 +179,7 @@ static int m25p_probe(struct spi_device *spi)
struct m25p *flash;
struct spi_nor *nor;
enum read_mode mode = SPI_NOR_NORMAL;
- char *flash_name = NULL;
+ char *flash_name;
int ret;
data = dev_get_platdata(&spi->dev);
@@ -219,6 +219,8 @@ 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;
@@ -253,6 +255,13 @@ static int m25p_remove(struct spi_device *spi)
*/
static const struct spi_device_id m25p_ids[] = {
/*
+ * Allow non-DT platform devices to bind to the "spi-nor" modalias, and
+ * hack around the fact that the SPI core does not provide uevent
+ * matching for .of_match_table
+ */
+ {"spi-nor"},
+
+ /*
* Entries not used in DTs that should be safe to drop after replacing
* them with "nor-jedec" in platform data.
*/
--
2.6.0.rc2.230.g3dd15c0
next prev parent reply other threads:[~2015-11-16 22:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-16 22:34 [PATCH 0/3] mtd: m25p80: fix some module and documentation issues Brian Norris
2015-11-16 22:34 ` Brian Norris [this message]
2015-11-17 13:55 ` [PATCH 1/3] mtd: m25p80: fix module autoloading for "jedec,spi-nor" and "spi-nor" Javier Martinez Canillas
2015-11-16 22:34 ` [PATCH 2/3] mtd: m25p80: replace leftover "nor-jedec" with "spi-nor" in comments Brian Norris
2015-11-17 13:55 ` Javier Martinez Canillas
2015-11-16 22:34 ` [PATCH 3/3] doc: dt: mtd: stop referring to driver code for spi-nor IDs Brian Norris
2015-11-16 23:16 ` Rob Herring
2015-11-17 14:04 ` Javier Martinez Canillas
2015-11-18 19:43 ` Brian Norris
2015-11-18 20:23 ` Javier Martinez Canillas
2015-11-20 0:48 ` [PATCH 0/3] mtd: m25p80: fix some module and documentation issues 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=1447713292-91525-2-git-send-email-computersforpeace@gmail.com \
--to=computersforpeace@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=javier@osg.samsung.com \
--cc=linux-kernel@vger.kernel.org \
--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).