summaryrefslogtreecommitdiffstats
path: root/serprog.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-08-12 13:32:56 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-08-12 13:32:56 +0000
commitef58a9ce3f9ae3ce0db34861f0c2d24373712138 (patch)
tree07d03ad8b91541f09b13ac709ef85e93cbc339ca /serprog.c
parent415e513d90042b91c1a50a9afe1282e393e574b8 (diff)
downloadast2050-flashrom-ef58a9ce3f9ae3ce0db34861f0c2d24373712138.zip
ast2050-flashrom-ef58a9ce3f9ae3ce0db34861f0c2d24373712138.tar.gz
Use a common parameter variable for all programmers
This allows us to reduce #ifdef clauses a lot if we compile out some programmers completely. Corresponding to flashrom svn r679. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Stefan Reinauer <stepan@coresystems.de>
Diffstat (limited to 'serprog.c')
-rw-r--r--serprog.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/serprog.c b/serprog.c
index 04e15a8..d76cbe5 100644
--- a/serprog.c
+++ b/serprog.c
@@ -19,8 +19,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <string.h>
+#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
+#include "flash.h"
+
+#if SERPROG_SUPPORT == 1
+
+#include <string.h>
#include <ctype.h>
#include <fcntl.h>
#include <sys/types.h>
@@ -31,15 +37,8 @@
#include <netdb.h>
#include <sys/stat.h>
#include <errno.h>
-#include <stdio.h>
-#include <unistd.h>
#include <inttypes.h>
#include <termios.h>
-#include "flash.h"
-
-char *serprog_param = NULL;
-
-#if SERPROG_SUPPORT == 1
#define MSGHEADER "serprog:"
@@ -431,15 +430,15 @@ int serprog_init(void)
char *dev;
printf_debug("%s\n", __func__);
/* the parameter is either of format "/dev/device:baud" or "ip:port" */
- if ((!serprog_param) || (!strlen(serprog_param))) {
+ if ((!programmer_param) || (!strlen(programmer_param))) {
nodevice:
fprintf(stderr,
"Error: No device/host given for the serial programmer driver.\n"
"Use flashrom -p serprog=/dev/device:baud or flashrom -p serprog=ip:port\n");
exit(1);
}
- num = strstr(serprog_param, ":");
- len = num - serprog_param;
+ num = strstr(programmer_param, ":");
+ len = num - programmer_param;
if (!len) goto nodevice;
if (!num) {
fprintf(stderr,
@@ -447,15 +446,15 @@ int serprog_init(void)
"Use flashrom -p serprog=/dev/device:baud or flashrom -p serprog=ip:port\n");
exit(1);
}
- len = num - serprog_param;
+ len = num - programmer_param;
dev = malloc(len + 1);
if (!dev) sp_die("Error: memory allocation failure");
- memcpy(dev, serprog_param, len);
+ memcpy(dev, programmer_param, len);
dev[len] = 0;
num = strdup(num + 1);
if (!num) sp_die("Error: memory allocation failure");
- free(serprog_param);
- serprog_param = NULL;
+ free(programmer_param);
+ programmer_param = NULL;
if (dev[0] == '/') sp_fd = sp_openserport(dev, atoi(num));
else sp_fd = sp_opensocket(dev, atoi(num));
OpenPOWER on IntegriCloud