summaryrefslogtreecommitdiffstats
path: root/it87spi.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2010-07-06 09:55:48 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2010-07-06 09:55:48 +0000
commit744132af4b9f629716394f9c22f6add71cc73ef9 (patch)
tree46de6c5dc108fc2868603fdc606e7328a83f1703 /it87spi.c
parentd1be52d545329debd2128c1aa8685b31dfaa0a0e (diff)
downloadast2050-flashrom-744132af4b9f629716394f9c22f6add71cc73ef9.zip
ast2050-flashrom-744132af4b9f629716394f9c22f6add71cc73ef9.tar.gz
Various places in the flashrom source feature custom parameter extraction from programmer_param
This led to wildly differing syntax for programmer parameters, and it also voids pretty much every assumption you could make about programmer_param. The latter is a problem for libflashrom. Use extract_param everywhere, clean up related code and make it more foolproof. Add two instances of exit(1) where we have no option to return an error. Remove six instances of exit(1) where returning an error was possible. WARNING: This changes programmer parameter syntax for a few programmers! Corresponding to flashrom svn r1070. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Diffstat (limited to 'it87spi.c')
-rw-r--r--it87spi.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/it87spi.c b/it87spi.c
index d374fcd..d314856 100644
--- a/it87spi.c
+++ b/it87spi.c
@@ -142,22 +142,24 @@ static uint16_t find_ite_spi_flash_port(uint16_t port, uint16_t id)
flashport = sio_read(port, 0x64) << 8;
flashport |= sio_read(port, 0x65);
msg_pdbg("Serial flash port 0x%04x\n", flashport);
- if (programmer_param && !strlen(programmer_param)) {
- free(programmer_param);
- programmer_param = NULL;
- }
- if (programmer_param) {
- portpos = extract_param(&programmer_param,
- "it87spiport=", ",:");
- if (portpos) {
- flashport = strtol(portpos, (char **)NULL, 0);
- msg_pinfo("Forcing serial flash port 0x%04x\n",
- flashport);
- sio_write(port, 0x64, (flashport >> 8));
- sio_write(port, 0x65, (flashport & 0xff));
- free(portpos);
- }
+ /* Non-default port requested? */
+ portpos = extract_param(&programmer_param, "it87spiport", ",:");
+ if (portpos && strlen(portpos)) {
+ flashport = strtol(portpos, (char **)NULL, 0);
+ msg_pinfo("Forcing serial flash port 0x%04x\n",
+ flashport);
+ sio_write(port, 0x64, (flashport >> 8));
+ sio_write(port, 0x65, (flashport & 0xff));
+ } else if (portpos) {
+ msg_perr("Error: it87spiport specified, but no port "
+ "given.\n");
+ free(portpos);
+ /* FIXME: Return failure here once it87spi_common_init()
+ * can handle the return value sanely.
+ */
+ exit(1);
}
+ free(portpos);
exit_conf_mode_ite(port);
break;
/* TODO: Handle more IT87xx if they support flash translation */
OpenPOWER on IntegriCloud