Felix Singer has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/67892 )
Change subject: buspirate_spi.c: Move variable `spispeed` into parameters struct ......................................................................
buspirate_spi.c: Move variable `spispeed` into parameters struct
Signed-off-by: Felix Singer felixsinger@posteo.net Change-Id: I816a0017dcb206a8f3284c1c79aed20a96008406 --- M buspirate_spi.c 1 file changed, 17 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/92/67892/1
diff --git a/buspirate_spi.c b/buspirate_spi.c index 2c551c4..5580451 100644 --- a/buspirate_spi.c +++ b/buspirate_spi.c @@ -317,6 +317,7 @@
struct buspirate_spi_parameters { char *dev; + int spispeed; };
static int buspirate_spi_init(const struct programmer_cfg *cfg) @@ -328,7 +329,6 @@ unsigned int fw_version_minor = 0; unsigned int hw_version_major = 0; unsigned int hw_version_minor = 0; - int spispeed = 0x7; int serialspeed_index = -1; int ret = 0; bool pullup = false; @@ -347,11 +347,12 @@ return 1; }
+ parameters.spispeed = 0x7; tmp = extract_programmer_param_str(cfg, "spispeed"); if (tmp) { for (i = 0; spispeeds[i].name; i++) { if (!strncasecmp(spispeeds[i].name, tmp, strlen(spispeeds[i].name))) { - spispeed = spispeeds[i].speed; + parameters.spispeed = spispeeds[i].speed; break; } } @@ -550,15 +551,15 @@
/* Workaround for broken speed settings in firmware 6.1 and older. */ if (BP_FWVERSION(fw_version_major, fw_version_minor) < BP_FWVERSION(6, 2)) - if (spispeed > 0x4) { + if (parameters.spispeed > 0x4) { msg_perr("Bus Pirate firmware 6.1 and older does not support SPI speeds above 2 MHz. " "Limiting speed to 2 MHz.\n"); msg_pinfo("It is recommended to upgrade to firmware 6.2 or newer.\n"); - spispeed = 0x4; + parameters.spispeed = 0x4; }
/* This works because speeds numbering starts at 0 and is contiguous. */ - msg_pdbg("SPI speed is %sHz\n", spispeeds[spispeed].name); + msg_pdbg("SPI speed is %sHz\n", spispeeds[parameters.spispeed].name);
/* Set 2M baud serial speed by default on hardware 3.0 and newer if a custom speed was not set */ if (serialspeed_index == -1 && BP_HWVERSION(hw_version_major, hw_version_minor) >= BP_HWVERSION(3, 0)) { @@ -673,7 +674,7 @@ }
/* Set SPI speed */ - bp_commbuf[0] = 0x60 | spispeed; + bp_commbuf[0] = 0x60 | parameters.spispeed; ret = buspirate_sendrecv(bp_commbuf, 1, 1); if (ret) goto init_err_cleanup_exit;