spi_master: Use new API to register shutdown function

This allows spi masters to register shutdown function in spi_master
struct, which means there is no need to call register_shutdown in init
function, since this call is now a part of register_spi_master.

As a consequence of using new API, two things are happening here:
1) No resource leakage anymore in case register_shutdown() would fail,
2) Fixed propagation of register_spi_master() return values.

Basic testing: when I comment out free(data) in linux_spi_shutdown, test
fails with error
../linux_spi.c:235: note: block 0x55a4db276510 allocated here
ERROR: linux_spi_init_and_shutdown_test_success leaked 1 block(s)
Means, shutdown function is invoked.

Tested:  1) builds and ninja test including CB:56911
2) On ARMv7 device
flashrom -p linux_spi -V
-> using linux_spi, chip found
3) On x86_64 AMD device
flashrom -p internal -V
-> this is actually using sb600spi, chip found

flashrom-stable: Updated `dirtyjtag_spi` which was added earlier.

Change-Id: Ib60300f9ddb295a255d5ef3f8da0e07064207140
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/56103
Original-Reviewed-by: Nico Huber <nico.h@gmx.de>
Original-Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Original-Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72231
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
diff --git a/jlink_spi.c b/jlink_spi.c
index 589447a..fd14908 100644
--- a/jlink_spi.c
+++ b/jlink_spi.c
@@ -156,6 +156,8 @@
 	return 0;
 }
 
+static int jlink_spi_shutdown(void *data);
+
 static const struct spi_master spi_master_jlink_spi = {
 	/* Maximum data read size in one go (excluding opcode+address). */
 	.max_data_read	= JTAG_MAX_TRANSFER_SIZE - 5,
@@ -167,6 +169,7 @@
 	.write_256	= default_spi_write_256,
 	.write_aai	= default_spi_write_aai,
 	.features	= SPI_MASTER_4BA,
+	.shutdown	= jlink_spi_shutdown,
 };
 
 static int jlink_spi_shutdown(void *data)
@@ -515,11 +518,7 @@
 	if (!deassert_cs(jlink_data))
 		goto init_err;
 
-	if (register_shutdown(jlink_spi_shutdown, jlink_data))
-		goto init_err;
-	register_spi_master(&spi_master_jlink_spi, jlink_data);
-
-	return 0;
+	return register_spi_master(&spi_master_jlink_spi, jlink_data);
 
 init_err:
 	if (jaylink_devh)