Valgrind reported
== Syscall param ioctl(generic) points to uninitialised byte(s)
== at 0x4ABF990: ioctl (ioctl.S:26)
== by 0x19D00B: spidev_speed (linuxspidev.c:181)
== by 0x19D00B: spidev_init (linuxspidev.c:307)
Indeed, spidev_init() uses adapter_get_speed(), it calls
adapter_khz_to_speed() and it returns early without setting
the output parameter if adapter is not initialized.
Of course the adapter initialized flag is not set until
spidev_init() returns.
Simply drop this code as the adapter infrastructure initializes
adapter speed just after spidev_init() return.
Change-Id: I26f011ae59fc942a34d9bb517f467c22f735091d
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Fixes: 83e0293f7ba3 ("Add Linux SPI device SWD adapter support")
Reviewed-on: https://review.openocd.org/c/openocd/+/8733
Tested-by: jenkins
Reviewed-by: Richard Pasek <rpasek@google.com>
LOG_INFO("Opened SPI device at %s in mode 0x%" PRIx32 " with %" PRIu8 " bits ",
spi_path, spi_mode, spi_bits);
- // Set SPI read and write max speed.
- int speed;
- ret = adapter_get_speed(&speed);
- if (ret != ERROR_OK) {
- LOG_ERROR("Failed to get adapter speed");
- return ERROR_JTAG_INIT_FAILED;
- }
-
- ret = spidev_speed(speed);
- if (ret != ERROR_OK)
- return ERROR_JTAG_INIT_FAILED;
-
if (max_queue_entries == 0) {
ret = spidev_alloc_queue(MAX_QUEUE_ENTRIES);
if (ret != ERROR_OK)