Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1432224 > unrolled thread

[PATCH v2 1/3] spi: spidev: fix the check for spidev in dt

Started byMichal Suchanek <hramrach@gmail.com>
First post2016-06-27 21:10 +0200
Last post2016-06-27 22:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 1/3] spi: spidev: fix the check for spidev in dt Michal Suchanek <hramrach@gmail.com> - 2016-06-27 21:10 +0200
    Re: [PATCH v2 1/3] spi: spidev: fix the check for spidev in dt Mark Brown <broonie@kernel.org> - 2016-06-27 22:40 +0200

#1432224 — [PATCH v2 1/3] spi: spidev: fix the check for spidev in dt

FromMichal Suchanek <hramrach@gmail.com>
Date2016-06-27 21:10 +0200
Subject[PATCH v2 1/3] spi: spidev: fix the check for spidev in dt
Message-ID<rOK4V-4o3-11@gated-at.bofh.it>
The error message is "buggy DT: spidev listed directly in DT\n"

That's not what the check does. It checks that one if the IDs listed in
the driver match table matches what is set on the DT node.

This does not work if you manage to convince the kernel to bind spidev
on a node that has some other random compatible which is not "spidev".

Also the spidev id match table is not compiled when !CONFIG_OF

So add a match table that has just "spidev" entry in it so it can
reliably detect what this message is supposed to warn about.

Signed-off-by: Michal Suchanek <hramrach@gmail.com>
---
 - fix indent
 - update commit mesage
---
 drivers/spi/spidev.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index e3c19f3..3c6ebe7 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -700,6 +700,11 @@ static const struct of_device_id spidev_dt_ids[] = {
 MODULE_DEVICE_TABLE(of, spidev_dt_ids);
 #endif
 
+static const struct of_device_id spidev_check[] = {
+	{ .compatible = "spidev" },
+	{}
+};
+
 /*-------------------------------------------------------------------------*/
 
 static int spidev_probe(struct spi_device *spi)
@@ -713,10 +718,10 @@ static int spidev_probe(struct spi_device *spi)
 	 * compatible string, it is a Linux implementation thing
 	 * rather than a description of the hardware.
 	 */
-	if (spi->dev.of_node && !of_match_device(spidev_dt_ids, &spi->dev)) {
+	if (spi->dev.of_node && of_match_device(spidev_check, &spi->dev)) {
 		dev_err(&spi->dev, "buggy DT: spidev listed directly in DT\n");
 		WARN_ON(spi->dev.of_node &&
-			!of_match_device(spidev_dt_ids, &spi->dev));
+			of_match_device(spidev_check, &spi->dev));
 	}
 
 	/* Allocate driver data */
-- 
2.8.1

[toc] | [next] | [standalone]


#1432300

FromMark Brown <broonie@kernel.org>
Date2016-06-27 22:40 +0200
Message-ID<rOLu1-5cR-3@gated-at.bofh.it>
In reply to#1432224

[Multipart message — attachments visible in raw view] — view raw

On Mon, Jun 27, 2016 at 09:02:30PM +0200, Michal Suchanek wrote:

> Also the spidev id match table is not compiled when !CONFIG_OF

To repeat what I said last time we have stub defines for this stuff for
a reason.

> This does not work if you manage to convince the kernel to bind spidev
> on a node that has some other random compatible which is not "spidev".

...which is only possible if the other problematic changes in this
series are merged so as I was suggesting last time this needs to be
pushed to the end of the series.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web