[<prev] [next>] [day] [month] [year] [list]
Message-ID: <YqdLNyIX8MCQ7Sfs@spacedout.fries.net>
Date: Mon, 13 Jun 2022 09:35:35 -0500
From: David Fries <David@...es.net>
To: Mark Brown <broonie@...nel.org>
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH] spi: spidev_test: Warn when the mode is not the requested
mode
Print a warning if the device mode doesn't match the requested mode.
The user doesn't enter the mode in hex so it isn't obvious when
setting the mode succeeds that the mode isn't the requested mode. The
kernel logs a message, it will be more visible if the test also prints
a warning. I was testing --quad, which is unsupported, but doesn't
cause the mode request to fail.
Signed-off-by: David Fries <David@...es.net>
---
Sorry forgot to run checkpatch.pl though it was silent about the
comments, which I reworded.
tools/spi/spidev_test.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/tools/spi/spidev_test.c b/tools/spi/spidev_test.c
index 83844f8b862a..941d713d6f23 100644
--- a/tools/spi/spidev_test.c
+++ b/tools/spi/spidev_test.c
@@ -417,6 +417,7 @@ int main(int argc, char *argv[])
{
int ret = 0;
int fd;
+ uint32_t request;
parse_opts(argc, argv);
@@ -429,7 +430,10 @@ int main(int argc, char *argv[])
/*
* spi mode
+ * WR is write 'mode' to request the transfer mode
+ * RD is read what mode the device actually is
*/
+ request = mode;
ret = ioctl(fd, SPI_IOC_WR_MODE32, &mode);
if (ret == -1)
pabort("can't set spi mode");
@@ -437,6 +441,14 @@ int main(int argc, char *argv[])
ret = ioctl(fd, SPI_IOC_RD_MODE32, &mode);
if (ret == -1)
pabort("can't get spi mode");
+ /*
+ * Drivers can reject some mode options without returning an error.
+ * Warn in this case to avoid the user thinking the requested mode is
+ * supported since it didn't give an error.
+ */
+ if (request != mode)
+ printf("WARNING device does not support requested mode 0x%x\n",
+ request);
/*
* bits per word
--
2.30.2
Powered by blists - more mailing lists