diff mbox series

[v2,3/3] spi: spidev: Fix OF tree warning logic

Message ID 20180920191759.17781-4-tpiepho@impinj.com (mailing list archive)
State Accepted
Commit 605b3bec73cbd74b4ac937b580cd0b47d1300484
Headers show
Series device tree spidev solution - driver_override for SPI | expand

Commit Message

Trent Piepho Sept. 20, 2018, 7:18 p.m. UTC
spidev will make a big fuss if a device tree node binds a device by
using "spidev" as the node's compatible property.

However, the logic for this isn't looking for "spidev" in the
compatible, but rather checking that the device is NOT compatible with
spidev's list of devices.

This causes a false positive if a device not named "rohm,dh2228fv", etc.
binds to spidev, even if a means other than putting "spidev" in the
device tree was used.  E.g., the sysfs driver_override attribute.

Signed-off-by: Trent Piepho <tpiepho@impinj.com>
---
 drivers/spi/spidev.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Jan Kundrát Sept. 20, 2018, 9:39 p.m. UTC | #1
On čtvrtek 20. září 2018 21:18:34 CEST, Trent Piepho wrote:
> spidev will make a big fuss if a device tree node binds a device by
> using "spidev" as the node's compatible property.
>
> However, the logic for this isn't looking for "spidev" in the
> compatible, but rather checking that the device is NOT compatible with
> spidev's list of devices.
>
> This causes a false positive if a device not named "rohm,dh2228fv", etc.
> binds to spidev, even if a means other than putting "spidev" in the
> device tree was used.  E.g., the sysfs driver_override attribute.
>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Reviewed-by: Jan Kundrát <jan.kundrat@cesnet.cz>
Tested-by: Jan Kundrát <jan.kundrat@cesnet.cz>
Geert Uytterhoeven Sept. 24, 2018, 7:57 a.m. UTC | #2
On Thu, Sep 20, 2018 at 9:18 PM Trent Piepho <tpiepho@impinj.com> wrote:
> spidev will make a big fuss if a device tree node binds a device by
> using "spidev" as the node's compatible property.
>
> However, the logic for this isn't looking for "spidev" in the
> compatible, but rather checking that the device is NOT compatible with
> spidev's list of devices.
>
> This causes a false positive if a device not named "rohm,dh2228fv", etc.
> binds to spidev, even if a means other than putting "spidev" in the
> device tree was used.  E.g., the sysfs driver_override attribute.
>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert
diff mbox series

Patch

diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index cda10719d1d1..c5fe08bc34a0 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -724,11 +724,9 @@  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)) {
-		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));
-	}
+	WARN(spi->dev.of_node &&
+	     of_device_is_compatible(spi->dev.of_node, "spidev"),
+	     "%pOF: buggy DT: spidev listed directly in DT\n", spi->dev.of_node);
 
 	spidev_probe_acpi(spi);