mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-01 22:21:16 +02:00
tree: Remove forward-declarations of structs for spi masters
Reorder functions to avoid forward-declarations of structs. Similar thing was done earlier for functions declarations, this patch takes care of structs declarations. BUG=b:140394053 TEST=builds objdump -d is identical objdump -s only difference is version number Change-Id: I256bd7c763efc010fc1f29f7c5853f150ac10739 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/51731 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
This commit is contained in:

committed by
Edward O'Callaghan

parent
6d79a6ab80
commit
e704583ad5
@ -51,8 +51,6 @@ const struct dev_entry devs_usbblasterspi[] = {
|
||||
{0}
|
||||
};
|
||||
|
||||
static const struct spi_master spi_master_usbblaster;
|
||||
|
||||
static struct ftdi_context ftdic;
|
||||
|
||||
// command bytes
|
||||
@ -72,51 +70,6 @@ static uint8_t reverse(uint8_t b)
|
||||
return ((b * 0x0802LU & 0x22110LU) | (b * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16;
|
||||
}
|
||||
|
||||
|
||||
/* Returns 0 upon success, a negative number upon errors. */
|
||||
int usbblaster_spi_init(void)
|
||||
{
|
||||
uint8_t buf[BUF_SIZE + 1];
|
||||
|
||||
if (ftdi_init(&ftdic) < 0)
|
||||
return -1;
|
||||
|
||||
if (ftdi_usb_open(&ftdic, ALTERA_VID, ALTERA_USBBLASTER_PID) < 0) {
|
||||
msg_perr("Failed to open USB-Blaster: %s\n", ftdic.error_str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ftdi_usb_reset(&ftdic) < 0) {
|
||||
msg_perr("USB-Blaster reset failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ftdi_set_latency_timer(&ftdic, 2) < 0) {
|
||||
msg_perr("USB-Blaster set latency timer failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ftdi_write_data_set_chunksize(&ftdic, 4096) < 0 ||
|
||||
ftdi_read_data_set_chunksize(&ftdic, BUF_SIZE) < 0) {
|
||||
msg_perr("USB-Blaster set chunk size failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
buf[sizeof(buf)-1] = BIT_LED | BIT_CS;
|
||||
if (ftdi_write_data(&ftdic, buf, sizeof(buf)) < 0) {
|
||||
msg_perr("USB-Blaster reset write failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (ftdi_read_data(&ftdic, buf, sizeof(buf)) < 0) {
|
||||
msg_perr("USB-Blaster reset read failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
register_spi_master(&spi_master_usbblaster);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int send_write(unsigned int writecnt, const unsigned char *writearr)
|
||||
{
|
||||
uint8_t buf[BUF_SIZE];
|
||||
@ -217,4 +170,48 @@ static const struct spi_master spi_master_usbblaster = {
|
||||
.write_aai = default_spi_write_aai,
|
||||
};
|
||||
|
||||
/* Returns 0 upon success, a negative number upon errors. */
|
||||
int usbblaster_spi_init(void)
|
||||
{
|
||||
uint8_t buf[BUF_SIZE + 1];
|
||||
|
||||
if (ftdi_init(&ftdic) < 0)
|
||||
return -1;
|
||||
|
||||
if (ftdi_usb_open(&ftdic, ALTERA_VID, ALTERA_USBBLASTER_PID) < 0) {
|
||||
msg_perr("Failed to open USB-Blaster: %s\n", ftdic.error_str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ftdi_usb_reset(&ftdic) < 0) {
|
||||
msg_perr("USB-Blaster reset failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ftdi_set_latency_timer(&ftdic, 2) < 0) {
|
||||
msg_perr("USB-Blaster set latency timer failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ftdi_write_data_set_chunksize(&ftdic, 4096) < 0 ||
|
||||
ftdi_read_data_set_chunksize(&ftdic, BUF_SIZE) < 0) {
|
||||
msg_perr("USB-Blaster set chunk size failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
buf[sizeof(buf)-1] = BIT_LED | BIT_CS;
|
||||
if (ftdi_write_data(&ftdic, buf, sizeof(buf)) < 0) {
|
||||
msg_perr("USB-Blaster reset write failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (ftdi_read_data(&ftdic, buf, sizeof(buf)) < 0) {
|
||||
msg_perr("USB-Blaster reset read failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
register_spi_master(&spi_master_usbblaster);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user