未验证 提交 41ecad2c 编写于 作者: D David Fries 提交者: Mark Brown

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: NDavid Fries <David@Fries.net>
Link: https://lore.kernel.org/r/YqbNnSGtWHe/GG7w@spacedout.fries.netSigned-off-by: NMark Brown <broonie@kernel.org>
上级 845d3fd8
...@@ -417,6 +417,7 @@ int main(int argc, char *argv[]) ...@@ -417,6 +417,7 @@ int main(int argc, char *argv[])
{ {
int ret = 0; int ret = 0;
int fd; int fd;
uint32_t request;
parse_opts(argc, argv); parse_opts(argc, argv);
...@@ -430,13 +431,23 @@ int main(int argc, char *argv[]) ...@@ -430,13 +431,23 @@ int main(int argc, char *argv[])
/* /*
* spi mode * spi mode
*/ */
/* WR is make a request to assign 'mode' */
request = mode;
ret = ioctl(fd, SPI_IOC_WR_MODE32, &mode); ret = ioctl(fd, SPI_IOC_WR_MODE32, &mode);
if (ret == -1) if (ret == -1)
pabort("can't set spi mode"); pabort("can't set spi mode");
/* RD is read what mode the device actually is in */
ret = ioctl(fd, SPI_IOC_RD_MODE32, &mode); ret = ioctl(fd, SPI_IOC_RD_MODE32, &mode);
if (ret == -1) if (ret == -1)
pabort("can't get spi mode"); pabort("can't get spi mode");
/* Drivers can reject some mode bits without returning an error.
* Read the current value to identify what mode it is in, and if it
* differs from the requested mode, warn the user.
*/
if (request != mode)
printf("WARNING device does not support requested mode 0x%x\n",
request);
/* /*
* bits per word * bits per word
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册