diff --git a/bitbang_spi.c b/bitbang_spi.c index 83c3501be..7c9a04d1b 100644 --- a/bitbang_spi.c +++ b/bitbang_spi.c @@ -147,6 +147,7 @@ static const struct spi_master spi_master_bitbang = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = bitbang_spi_shutdown, }; int register_spi_bitbang_master(const struct bitbang_spi_master *master, void *spi_data) @@ -168,7 +169,6 @@ int register_spi_bitbang_master(const struct bitbang_spi_master *master, void *s data->spi_data = spi_data; register_spi_master(&mst, data); - register_shutdown(bitbang_spi_shutdown, data); /* Only mess with the bus if we're sure nobody else uses it. */ bitbang_spi_request_bus(master, spi_data); diff --git a/buspirate_spi.c b/buspirate_spi.c index 3c0a6ff92..6d7fba7fd 100644 --- a/buspirate_spi.c +++ b/buspirate_spi.c @@ -181,6 +181,7 @@ static struct spi_master spi_master_buspirate = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = buspirate_spi_shutdown, }; static const struct buspirate_speeds spispeeds[] = { @@ -698,13 +699,7 @@ static int buspirate_spi_init(void) goto init_err_cleanup_exit; } - if (register_shutdown(buspirate_spi_shutdown, bp_data) != 0) { - ret = 1; - goto init_err_cleanup_exit; - } - register_spi_master(&spi_master_buspirate, bp_data); - - return 0; + return register_spi_master(&spi_master_buspirate, bp_data); init_err_cleanup_exit: buspirate_spi_shutdown(bp_data); diff --git a/ch341a_spi.c b/ch341a_spi.c index 22c97813c..4a7628637 100644 --- a/ch341a_spi.c +++ b/ch341a_spi.c @@ -417,6 +417,7 @@ static const struct spi_master spi_master_ch341a_spi = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = ch341a_spi_shutdown, }; static int ch341a_spi_init(void) @@ -505,10 +506,7 @@ static int ch341a_spi_init(void) if ((config_stream(CH341A_STM_I2C_100K) < 0) || (enable_pins(true) < 0)) goto dealloc_transfers; - register_shutdown(ch341a_spi_shutdown, NULL); - register_spi_master(&spi_master_ch341a_spi, NULL); - - return 0; + return register_spi_master(&spi_master_ch341a_spi, NULL); dealloc_transfers: for (i = 0; i < USB_IN_TRANSFERS; i++) { diff --git a/dediprog.c b/dediprog.c index d98af4934..323dcd0f1 100644 --- a/dediprog.c +++ b/dediprog.c @@ -1019,6 +1019,7 @@ static struct spi_master spi_master_dediprog = { .read = dediprog_spi_read, .write_256 = dediprog_spi_write_256, .write_aai = dediprog_spi_write_aai, + .shutdown = dediprog_shutdown, }; /* @@ -1271,9 +1272,6 @@ static int dediprog_init(void) if (protocol() >= PROTOCOL_V2) spi_master_dediprog.features |= SPI_MASTER_4BA; - if (register_shutdown(dediprog_shutdown, NULL)) - goto init_err_cleanup_exit; - if (register_spi_master(&spi_master_dediprog, NULL) || dediprog_set_leds(LED_NONE)) return 1; /* shutdown function does cleanup */ diff --git a/digilent_spi.c b/digilent_spi.c index 0ec402e96..e2cfcced3 100644 --- a/digilent_spi.c +++ b/digilent_spi.c @@ -337,6 +337,7 @@ static const struct spi_master spi_master_digilent_spi = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = digilent_spi_shutdown, }; static bool default_reset(struct libusb_device_handle *handle) @@ -454,10 +455,7 @@ static int digilent_spi_init(void) digilent_data->reset_board = reset_board; digilent_data->handle = handle; - register_shutdown(digilent_spi_shutdown, digilent_data); - register_spi_master(&spi_master_digilent_spi, digilent_data); - - return 0; + return register_spi_master(&spi_master_digilent_spi, digilent_data); close_handle: libusb_close(handle); diff --git a/ene_lpc.c b/ene_lpc.c index 23ba12be6..374d1fd5e 100644 --- a/ene_lpc.c +++ b/ene_lpc.c @@ -512,6 +512,7 @@ static const struct spi_master spi_master_ene = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = ene_leave_flash_mode, }; static int check_params(void) @@ -570,16 +571,7 @@ static int ene_lpc_init() internal_buses_supported |= BUS_LPC; - if (register_shutdown(ene_leave_flash_mode, ctx_data)) - goto init_err_cleanup_exit; - register_spi_master(&spi_master_ene, ctx_data); - msg_pdbg("%s: successfully initialized ene\n", __func__); - - return 0; - -init_err_cleanup_exit: - ene_leave_flash_mode(ctx_data); - return 1; + return register_spi_master(&spi_master_ene, ctx_data); init_err_exit: free(ctx_data); diff --git a/ft2232_spi.c b/ft2232_spi.c index e32d7f81e..15837d928 100644 --- a/ft2232_spi.c +++ b/ft2232_spi.c @@ -291,6 +291,7 @@ static const struct spi_master spi_master_ft2232 = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = ft2232_shutdown, }; /* Returns 0 upon success, a negative number upon errors. */ @@ -579,13 +580,7 @@ static int ft2232_spi_init(void) spi_data->pindir = pindir; spi_data->ftdic_context = ftdic; - if (register_shutdown(ft2232_shutdown, spi_data)) { - free(spi_data); - goto ftdi_err; - } - register_spi_master(&spi_master_ft2232, spi_data); - - return 0; + return register_spi_master(&spi_master_ft2232, spi_data); ftdi_err: if ((f = ftdi_usb_close(&ftdic)) < 0) { diff --git a/it85spi.c b/it85spi.c index 9812fc722..dd0cb6c00 100644 --- a/it85spi.c +++ b/it85spi.c @@ -289,6 +289,7 @@ static const struct spi_master spi_master_it85xx = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = it85xx_shutdown, }; int it85xx_spi_init(struct superio s) @@ -353,20 +354,13 @@ int it85xx_spi_init(struct superio s) data->ce_high = ((unsigned char *)base) + 0xE00; /* 0xFFFFFE00 */ data->ce_low = ((unsigned char *)base) + 0xD00; /* 0xFFFFFD00 */ - if (register_shutdown(it85xx_shutdown, data)) { - free(data); - return 1; - } - /* FIXME: Really leave FWH enabled? We can't use this region * anymore since accessing it would mess up IT85 communication. * If we decide to disable FWH for this region, we should print * a debug message about it. */ /* Set this as SPI controller. */ - register_spi_master(&spi_master_it85xx, data); - - return 0; + return register_spi_master(&spi_master_it85xx, data); } #endif diff --git a/it87spi.c b/it87spi.c index e55232858..3e422d7df 100644 --- a/it87spi.c +++ b/it87spi.c @@ -304,6 +304,7 @@ static const struct spi_master spi_master_it87xx = { .read = it8716f_spi_chip_read, .write_256 = it8716f_spi_chip_write_256, .write_aai = spi_chip_write_1, + .shutdown = it8716f_shutdown, }; static uint16_t it87spi_probe(uint16_t port) @@ -419,13 +420,10 @@ static uint16_t it87spi_probe(uint16_t port) data->flashport = flashport; data->fast_spi = 1; - register_shutdown(it8716f_shutdown, data); - if (internal_buses_supported & BUS_SPI) msg_pdbg("Overriding chipset SPI with IT87 SPI.\n"); /* FIXME: Add the SPI bus or replace the other buses with it? */ - register_spi_master(&spi_master_it87xx, data); - return 0; + return register_spi_master(&spi_master_it87xx, data); } int init_superio_ite(void) diff --git a/jlink_spi.c b/jlink_spi.c index daa8eb67e..4b34bfda0 100644 --- a/jlink_spi.c +++ b/jlink_spi.c @@ -179,6 +179,7 @@ static const struct spi_master spi_master_jlink_spi = { .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, .features = SPI_MASTER_4BA, + .shutdown = jlink_spi_shutdown, }; static int jlink_spi_init(void) @@ -468,11 +469,7 @@ static int jlink_spi_init(void) 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) diff --git a/linux_spi.c b/linux_spi.c index 46779a020..bd9ffb360 100644 --- a/linux_spi.c +++ b/linux_spi.c @@ -122,6 +122,7 @@ static const struct spi_master spi_master_linux = { .read = linux_spi_read, .write_256 = linux_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = linux_spi_shutdown, }; /* Read max buffer size from sysfs, or use page size as fallback. */ @@ -239,12 +240,7 @@ static int linux_spi_init(void) spi_data->fd = fd; spi_data->max_kernel_buf_size = max_kernel_buf_size; - if (register_shutdown(linux_spi_shutdown, spi_data)) { - free(spi_data); - goto init_err; - } - register_spi_master(&spi_master_linux, spi_data); - return 0; + return register_spi_master(&spi_master_linux, spi_data); init_err: close(fd); diff --git a/lspcon_i2c_spi.c b/lspcon_i2c_spi.c index e9ff2ddc7..bed7efc89 100644 --- a/lspcon_i2c_spi.c +++ b/lspcon_i2c_spi.c @@ -434,6 +434,7 @@ static const struct spi_master spi_master_i2c_lspcon = { .read = lspcon_i2c_spi_read, .write_256 = lspcon_i2c_spi_write_256, .write_aai = lspcon_i2c_spi_write_aai, + .shutdown = lspcon_i2c_spi_shutdown, }; static int lspcon_i2c_spi_init(void) @@ -458,10 +459,7 @@ static int lspcon_i2c_spi_init(void) data->fd = fd; - ret |= register_shutdown(lspcon_i2c_spi_shutdown, data); - ret |= register_spi_master(&spi_master_i2c_lspcon, data); - - return ret; + return register_spi_master(&spi_master_i2c_lspcon, data); } const struct programmer_entry programmer_lspcon_i2c_spi = { diff --git a/mec1308.c b/mec1308.c index c085ff2a3..e9c621494 100644 --- a/mec1308.c +++ b/mec1308.c @@ -405,6 +405,7 @@ static const struct spi_master spi_master_mec1308 = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = mec1308_shutdown, }; static int check_params(void) @@ -507,12 +508,7 @@ static int mec1308_init(void) internal_buses_supported |= BUS_LPC; /* for LPC <--> SPI bridging */ - if (register_shutdown(mec1308_shutdown, ctx_data)) - goto init_err_cleanup_exit; - register_spi_master(&spi_master_mec1308, ctx_data); - msg_pdbg("%s(): successfully initialized mec1308\n", __func__); - - return 0; + return register_spi_master(&spi_master_mec1308, ctx_data); init_err_cleanup_exit: mec1308_shutdown(ctx_data); diff --git a/mstarddc_spi.c b/mstarddc_spi.c index a7816a4b6..8e2d5a86c 100644 --- a/mstarddc_spi.c +++ b/mstarddc_spi.c @@ -147,6 +147,7 @@ static const struct spi_master spi_master_mstarddc = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = mstarddc_spi_shutdown, }; /* Returns 0 upon success, a negative number upon errors. */ @@ -240,9 +241,6 @@ static int mstarddc_spi_init(void) mstarddc_data->addr = mstarddc_addr; mstarddc_data->doreset = mstarddc_doreset; - // Register shutdown function - register_shutdown(mstarddc_spi_shutdown, mstarddc_data); - // Register programmer register_spi_master(&spi_master_mstarddc, mstarddc_data); out: diff --git a/ni845x_spi.c b/ni845x_spi.c index 215351067..87a1dd8d9 100644 --- a/ni845x_spi.c +++ b/ni845x_spi.c @@ -536,6 +536,7 @@ static const struct spi_master spi_programmer_ni845x = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = ni845x_spi_shutdown, }; static int ni845x_spi_init(void) @@ -625,14 +626,7 @@ static int ni845x_spi_init(void) return 1; } - if (register_shutdown(ni845x_spi_shutdown, NULL)) { - ni845x_spi_shutdown(NULL); - return 1; - } - - register_spi_master(&spi_programmer_ni845x, NULL); - - return 0; + return register_spi_master(&spi_programmer_ni845x, NULL); } const struct programmer_entry programmer_ni845x_spi = { diff --git a/pickit2_spi.c b/pickit2_spi.c index 73ace4be9..17da1d991 100644 --- a/pickit2_spi.c +++ b/pickit2_spi.c @@ -386,6 +386,7 @@ static const struct spi_master spi_master_pickit2 = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = pickit2_shutdown, }; static int pickit2_spi_init(void) @@ -498,11 +499,7 @@ static int pickit2_spi_init(void) goto init_err_cleanup_exit; } - if (register_shutdown(pickit2_shutdown, pickit2_data)) - goto init_err_cleanup_exit; - register_spi_master(&spi_master_pickit2, pickit2_data); - - return 0; + return register_spi_master(&spi_master_pickit2, pickit2_data); init_err_cleanup_exit: pickit2_shutdown(pickit2_data); diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c index 41458645e..954150df5 100644 --- a/realtek_mst_i2c_spi.c +++ b/realtek_mst_i2c_spi.c @@ -440,6 +440,7 @@ static const struct spi_master spi_master_i2c_realtek_mst = { .read = realtek_mst_i2c_spi_read, .write_256 = realtek_mst_i2c_spi_write_256, .write_aai = realtek_mst_i2c_spi_write_aai, + .shutdown = realtek_mst_i2c_spi_shutdown, }; static int get_params(int *reset, int *enter_isp) @@ -512,10 +513,7 @@ static int realtek_mst_i2c_spi_init(void) data->fd = fd; data->reset = reset; - ret |= register_shutdown(realtek_mst_i2c_spi_shutdown, data); - ret |= register_spi_master(&spi_master_i2c_realtek_mst, data); - - return ret; + return register_spi_master(&spi_master_i2c_realtek_mst, data); } const struct programmer_entry programmer_realtek_mst_i2c_spi = { diff --git a/sb600spi.c b/sb600spi.c index 5c6547548..fe7920fb4 100644 --- a/sb600spi.c +++ b/sb600spi.c @@ -589,6 +589,7 @@ static const struct spi_master spi_master_sb600 = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = sb600spi_shutdown, }; static const struct spi_master spi_master_yangtze = { @@ -599,6 +600,7 @@ static const struct spi_master spi_master_yangtze = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = sb600spi_shutdown, }; static const struct spi_master spi_master_promontory = { @@ -609,6 +611,7 @@ static const struct spi_master spi_master_promontory = { .read = promontory_read_memmapped, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = sb600spi_shutdown, }; int sb600_probe_spi(struct pci_dev *dev) @@ -786,8 +789,6 @@ int sb600_probe_spi(struct pci_dev *dev) data->flash = NULL; data->spibar = sb600_spibar; - register_shutdown(sb600spi_shutdown, data); - /* Starting with Yangtze the SPI controller got a different interface with a much bigger buffer. */ if (amd_gen < CHIPSET_YANGTZE) register_spi_master(&spi_master_sb600, data); diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c index 3a5aeb325..58e7a4191 100644 --- a/stlinkv3_spi.c +++ b/stlinkv3_spi.c @@ -467,6 +467,7 @@ static const struct spi_master spi_programmer_stlinkv3 = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = stlinkv3_spi_shutdown, }; static int stlinkv3_spi_init(void) @@ -531,17 +532,7 @@ static int stlinkv3_spi_init(void) stlinkv3_data->usb_ctx = usb_ctx; stlinkv3_data->handle = stlinkv3_handle; - if (register_shutdown(stlinkv3_spi_shutdown, stlinkv3_data)) - goto init_err_cleanup_exit; - - if (register_spi_master(&spi_programmer_stlinkv3, stlinkv3_data)) - return 1; /* shutdown function does cleanup */ - - return 0; - -init_err_cleanup_exit: - stlinkv3_spi_shutdown(stlinkv3_data); - return 1; + return register_spi_master(&spi_programmer_stlinkv3, stlinkv3_data); init_err_exit: if (stlinkv3_handle) diff --git a/usbblaster_spi.c b/usbblaster_spi.c index dfd98ec41..bd4b1c920 100644 --- a/usbblaster_spi.c +++ b/usbblaster_spi.c @@ -174,6 +174,7 @@ static const struct spi_master spi_master_usbblaster = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = usbblaster_shutdown, }; /* Returns 0 upon success, a negative number upon errors. */ @@ -224,12 +225,7 @@ static int usbblaster_spi_init(void) } usbblaster_data->ftdic = ftdic; - if (register_shutdown(usbblaster_shutdown, usbblaster_data)) { - free(usbblaster_data); - return -1; - } - register_spi_master(&spi_master_usbblaster, usbblaster_data); - return 0; + return register_spi_master(&spi_master_usbblaster, usbblaster_data); } const struct programmer_entry programmer_usbblaster_spi = { diff --git a/wbsio_spi.c b/wbsio_spi.c index 233684560..a175b2166 100644 --- a/wbsio_spi.c +++ b/wbsio_spi.c @@ -191,6 +191,7 @@ static const struct spi_master spi_master_wbsio = { .read = wbsio_spi_read, .write_256 = spi_chip_write_1, .write_aai = spi_chip_write_1, + .shutdown = wbsio_spi_shutdown, }; int wbsio_check_for_spi(void) @@ -214,10 +215,7 @@ int wbsio_check_for_spi(void) } data->spibase = wbsio_spibase; - register_shutdown(wbsio_spi_shutdown, data); - register_spi_master(&spi_master_wbsio, data); - - return 0; + return register_spi_master(&spi_master_wbsio, data); } #endif /* defined(__i386__) || defined(__x86_64__) */