Felix Singer has uploaded this change for review.

View Change

buspirate_spi.c: Move variable `dev` into parameter struct

Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: I5a791f1d9204982d7972eed85ccf8eb10ce02b78
---
M buspirate_spi.c
1 file changed, 23 insertions(+), 9 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/91/67891/1
diff --git a/buspirate_spi.c b/buspirate_spi.c
index cf84c9c..2c551c4 100644
--- a/buspirate_spi.c
+++ b/buspirate_spi.c
@@ -315,10 +315,13 @@
*/
#define BP_DIVISOR(baud) ((4000000/(baud)) - 1)

+struct buspirate_spi_parameters {
+ char *dev;
+};
+
static int buspirate_spi_init(const struct programmer_cfg *cfg)
{
char *tmp;
- char *dev;
int i;
int cnt;
unsigned int fw_version_major = 0;
@@ -332,13 +335,14 @@
bool psu = false;
unsigned char *bp_commbuf;
int bp_commbufsize;
+ struct buspirate_spi_parameters parameters = { 0 };

- dev = extract_programmer_param_str(cfg, "dev");
- if (dev && !strlen(dev)) {
- free(dev);
- dev = NULL;
+ parameters.dev = extract_programmer_param_str(cfg, "dev");
+ if (parameters.dev && !strlen(parameters.dev)) {
+ free(parameters.dev);
+ parameters.dev = NULL;
}
- if (!dev) {
+ if (!parameters.dev) {
msg_perr("No serial device given. Use flashrom -p buspirate_spi:dev=/dev/ttyUSB0\n");
return 1;
}
@@ -401,13 +405,13 @@
bp_commbuf = malloc(DEFAULT_BUFSIZE);
if (!bp_commbuf) {
msg_perr("Out of memory!\n");
- free(dev);
+ free(parameters.dev);
return ERROR_OOM;
}
bp_commbufsize = DEFAULT_BUFSIZE;

- ret = buspirate_serialport_setup(dev);
- free(dev);
+ ret = buspirate_serialport_setup(parameters.dev);
+ free(parameters.dev);
if (ret) {
free(bp_commbuf);
return ret;

To view, visit change 67891. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I5a791f1d9204982d7972eed85ccf8eb10ce02b78
Gerrit-Change-Number: 67891
Gerrit-PatchSet: 1
Gerrit-Owner: Felix Singer <felixsinger@posteo.net>
Gerrit-MessageType: newchange