When a driver does not support transfer() call, such as most QSPI drivers, calling spi_sync() (e.g. with the "spi" command) will cause the system to hang. Fix this by adding a function check. barebox@Mega-Milas Informer SAMA5D2:/ spi -b 1 -c 0 0xaa prefetch abort pc : [<00000004>] lr : [<27e266a4>] sp : 27ff7c78 ip : 27ff7ce8 fp : 27e87410 r10: 27ff7d20 r9 : 00000000 r8 : 23f58128 r7 : 23f33c30 r6 : 27ff7c90 r5 : 27ff7d20 r4 : 27ff7c7c r3 : 00000000 r2 : 27ff7cc4 r1 : 27ff7c90 r0 : 27ff7d20 Flags: nzCv IRQs off FIQs off Mode SVC_32 [<27e266a4>] (spi_sync+0xc8/0xdc) from [<27e2675c>] (spi_write_then_read+0xa4/0xac) [<27e2675c>] (spi_write_then_read+0xa4/0xac) from [<27e438e4>] (do_spi+0x288/0x3e8) [<27e438e4>] (do_spi+0x288/0x3e8) from [<27e05c38>] (execute_command+0x3c/0x80) [<27e05c38>] (execute_command+0x3c/0x80) from [<27e0ee48>] (run_list_real+0x9a8/0xad8) [<27e0ee48>] (run_list_real+0x9a8/0xad8) from [<27e0e2b4>] (parse_stream_outer+0x138/0x200) [<27e0e2b4>] (parse_stream_outer+0x138/0x200) from [<27e0f180>] (run_shell+0x5c/0x90) [<27e0f180>] (run_shell+0x5c/0x90) from [<27e018b4>] (run_init+0x108/0x288) [<27e018b4>] (run_init+0x108/0x288) from [<27e01a8c>] (start_barebox+0x58/0xb4) [<27e01a8c>] (start_barebox+0x58/0xb4) from [<27e5ee18>] (barebox_non_pbl_start+0xc8/0xe0) [<27e5ee18>] (barebox_non_pbl_start+0xc8/0xe0) from [<27e00004>] (__bare_init_start+0x0/0x10) Signed-off-by: Alexander Shiyan <eagle.alexander923@xxxxxxxxx> --- drivers/spi/spi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index c627d88954..c354c00e72 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -357,6 +357,9 @@ int spi_sync(struct spi_device *spi, struct spi_message *message) int status; int ret; + if (!spi->controller->transfer) + return -ENOTSUPP; + status = __spi_validate(spi, message); if (status != 0) return status; -- 2.39.1