diff options
author | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2009-08-12 13:32:56 +0000 |
---|---|---|
committer | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2009-08-12 13:32:56 +0000 |
commit | ef58a9ce3f9ae3ce0db34861f0c2d24373712138 (patch) | |
tree | 07d03ad8b91541f09b13ac709ef85e93cbc339ca /serprog.c | |
parent | 415e513d90042b91c1a50a9afe1282e393e574b8 (diff) | |
download | flashrom-ef58a9ce3f9ae3ce0db34861f0c2d24373712138.tar.gz flashrom-ef58a9ce3f9ae3ce0db34861f0c2d24373712138.tar.bz2 flashrom-ef58a9ce3f9ae3ce0db34861f0c2d24373712138.zip |
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.c | 29 |
1 files changed, 14 insertions, 15 deletions
@@ -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)); |