From: openocd-gerrit <ope...@us...> - 2025-02-22 18:34:10
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via f63b41bbe4ce33449ec18106620f57ba69ce7549 (commit) from 0d7d178ed4fe2e99de804412fde9bb11c872f10a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f63b41bbe4ce33449ec18106620f57ba69ce7549 Author: Tomas Vanek <va...@fb...> Date: Sat Feb 15 08:11:02 2025 +0100 drivers/linuxspidev: fix compilation on Linux older than 3.15 Although the commit [1] which introduced SPI_IOC_WR_MODE32 is 10 years old, some hardware may enforce old Linux because the vendor didn't bother with system updates. Change-Id: I76d0b38c8646b1be329418860916b9f01b90990d Link: [1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/include/uapi/linux/spi/spidev.h?h=linux-3.15.y&id=dc64d39b54c1e9db97a6fb1ca52598c981728157 Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: https://review.openocd.org/c/openocd/+/8759 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/src/jtag/drivers/linuxspidev.c b/src/jtag/drivers/linuxspidev.c index 6a149a977..18abdc7db 100644 --- a/src/jtag/drivers/linuxspidev.c +++ b/src/jtag/drivers/linuxspidev.c @@ -302,8 +302,20 @@ static int spidev_init(void) return ERROR_JTAG_INIT_FAILED; } + int ret; // Set SPI mode. - int ret = ioctl(spi_fd, SPI_IOC_WR_MODE32, &spi_mode); +#ifdef SPI_IOC_WR_MODE32 + ret = ioctl(spi_fd, SPI_IOC_WR_MODE32, &spi_mode); +#else + // Linux pre 3.15 does not support MODE32, use 8-bit ioctl + if (spi_mode & ~0xff) { + LOG_ERROR("SPI mode 0x%" PRIx32 ", system permits 8 bits only", spi_mode); + return ERROR_JTAG_INIT_FAILED; + } + + uint8_t mode = (uint8_t)spi_mode; + ret = ioctl(spi_fd, SPI_IOC_WR_MODE, &mode); +#endif if (ret == -1) { LOG_ERROR("Failed to set SPI mode 0x%" PRIx32, spi_mode); return ERROR_JTAG_INIT_FAILED; ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/linuxspidev.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |