Patchwork Common parameter variable for all programmers

login
register
about
Submitter Carl-Daniel Hailfinger
Date 2009-08-12 12:32:15
Message ID <4A82B64F.6020404@gmx.net>
Download mbox | patch
Permalink /patch/109/
State Accepted
Commit r679
Headers show

Comments

Carl-Daniel Hailfinger - 2009-08-12 12:32:15
Use a common parameter variable for all programmers. This allows us to
reduce #ifdef clauses a lot if we compile out some programmers completely.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Stefan Reinauer - 2009-08-12 13:23:28
Acked-by: Stefan Reinauer <stepan@coresystems.de>

On 12.08.2009, at 14:32, Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net 
 > wrote:

> Use a common parameter variable for all programmers. This allows us to
> reduce #ifdef clauses a lot if we compile out some programmers  
> completely.
>
> Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net 
> >
>
> Index: flashrom-programmer_common_param/flash.h
> ===================================================================
> --- flashrom-programmer_common_param/flash.h    (Revision 678)
> +++ flashrom-programmer_common_param/flash.h    (Arbeitskopie)
> @@ -277,7 +277,7 @@
>    const char *device_name;
> };
> uint32_t pcidev_validate(struct pci_dev *dev, struct pcidev_status  
> *devs);
> -uint32_t pcidev_init(uint16_t vendor_id, struct pcidev_status *devs);
> +uint32_t pcidev_init(uint16_t vendor_id, struct pcidev_status  
> *devs, char *pcidev_bdf);
>
> /* print.c */
> char *flashbuses_to_text(enum chipbustype bustype);
> @@ -350,7 +350,6 @@
> #endif
>
> /* dummyflasher.c */
> -extern char *dummytype;
> int dummy_init(void);
> int dummy_shutdown(void);
> void *dummy_map(const char *descr, unsigned long phys_addr, size_t  
> len);
> @@ -383,13 +382,13 @@
> /* ft2232_spi.c */
> #define FTDI_FT2232H 0x6010
> #define FTDI_FT4232H 0x6011
> -extern char *ft2232spi_param;
> int ft2232_spi_init(void);
> int ft2232_spi_send_command(unsigned int writecnt, unsigned int  
> readcnt, const unsigned char *writearr, unsigned char *readarr);
> int ft2232_spi_read(struct flashchip *flash, uint8_t *buf, int  
> start, int len);
> int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf);
>
> /* flashrom.c */
> +extern char *programmer_param;
> extern int verbose;
> extern const char *flashrom_version;
> #define printf_debug(x...) { if (verbose) printf(x); }
> @@ -399,7 +398,6 @@
> int max(int a, int b);
> int check_erased_range(struct flashchip *flash, int start, int len);
> int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int  
> start, int len, char *message);
> -extern char *pcidev_bdf;
> char *strcat_realloc(char *dest, const char *src);
>
> #define OK 0
> @@ -507,7 +505,6 @@
> int ich_spi_send_multicommand(struct spi_command *spicommands);
>
> /* it87spi.c */
> -extern char *it87opts;
> extern uint16_t it8716f_flashport;
> void enter_conf_mode_ite(uint16_t port);
> void exit_conf_mode_ite(uint16_t port);
> @@ -628,7 +625,6 @@
> int write_stm50flw0x0x(struct flashchip *flash, uint8_t *buf);
>
> /* serprog.c */
> -extern char *serprog_param;
> int serprog_init(void);
> int serprog_shutdown(void);
> void serprog_chip_writeb(uint8_t val, chipaddr addr);
> Index: flashrom-programmer_common_param/it87spi.c
> ===================================================================
> --- flashrom-programmer_common_param/it87spi.c    (Revision 678)
> +++ flashrom-programmer_common_param/it87spi.c    (Arbeitskopie)
> @@ -31,7 +31,6 @@
> #define ITE_SUPERIO_PORT1    0x2e
> #define ITE_SUPERIO_PORT2    0x4e
>
> -char *it87opts = NULL;
> uint16_t it8716f_flashport = 0;
> /* use fast 33MHz SPI (<>0) or slow 16MHz (0) */
> int fast_spi = 1;
> @@ -95,11 +94,11 @@
>        flashport = sio_read(port, 0x64) << 8;
>        flashport |= sio_read(port, 0x65);
>        printf("Serial flash port 0x%04x\n", flashport);
> -        if (it87opts && !strlen(it87opts)) {
> -            free(it87opts);
> -            it87opts = NULL;
> +        if (programmer_param && !strlen(programmer_param)) {
> +            free(programmer_param);
> +            programmer_param = NULL;
>        }
> -        if (it87opts && (portpos = strstr(it87opts, "port="))) {
> +        if (programmer_param && (portpos = strstr(programmer_param,  
> "port="))) {
>            portpos += 5;
>            flashport = strtol(portpos, (char **)NULL, 0);
>            printf("Forcing serial flash port 0x%04x\n", flashport);
> Index: flashrom-programmer_common_param/pcidev.c
> ===================================================================
> --- flashrom-programmer_common_param/pcidev.c    (Revision 678)
> +++ flashrom-programmer_common_param/pcidev.c    (Arbeitskopie)
> @@ -26,7 +26,6 @@
> uint32_t io_base_addr;
> struct pci_access *pacc;
> struct pci_filter filter;
> -char *pcidev_bdf = NULL;
> struct pci_dev *pcidev_dev = NULL;
>
> uint32_t pcidev_validate(struct pci_dev *dev, struct pcidev_status  
> *devs)
> @@ -58,7 +57,7 @@
>    return 0;
> }
>
> -uint32_t pcidev_init(uint16_t vendor_id, struct pcidev_status *devs)
> +uint32_t pcidev_init(uint16_t vendor_id, struct pcidev_status  
> *devs, char *pcidev_bdf)
> {
>    struct pci_dev *dev;
>    char *msg = NULL;
> Index: flashrom-programmer_common_param/serprog.c
> ===================================================================
> --- flashrom-programmer_common_param/serprog.c    (Revision 678)
> +++ flashrom-programmer_common_param/serprog.c    (Arbeitskopie)
> @@ -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,16 +37,9 @@
> #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:"
>
> #define S_ACK 0x06
> @@ -431,15 +430,15 @@
>    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 @@
>            "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));
> Index: flashrom-programmer_common_param/nic3com.c
> ===================================================================
> --- flashrom-programmer_common_param/nic3com.c    (Revision 678)
> +++ flashrom-programmer_common_param/nic3com.c    (Arbeitskopie)
> @@ -58,7 +58,7 @@
> {
>    get_io_perms();
>
> -    io_base_addr = pcidev_init(PCI_VENDOR_ID_3COM, nics_3com);
> +    io_base_addr = pcidev_init(PCI_VENDOR_ID_3COM, nics_3com,  
> programmer_param);
>    id = pcidev_dev->device_id;
>
>    /* 3COM 3C90xB cards need a special fixup. */
> @@ -94,7 +94,7 @@
>        OUTL(internal_conf, io_base_addr + INTERNAL_CONFIG);
>    }
>
> -    free(pcidev_bdf);
> +    free(programmer_param);
>    pci_cleanup(pacc);
>    release_io_perms();
>    return 0;
> Index: flashrom-programmer_common_param/ft2232_spi.c
> ===================================================================
> --- flashrom-programmer_common_param/ft2232_spi.c    (Revision 678)
> +++ flashrom-programmer_common_param/ft2232_spi.c    (Arbeitskopie)
> @@ -26,8 +26,6 @@
> #include "flash.h"
> #include "spi.h"
>
> -char *ft2232spi_param = NULL;
> -
> #if FT2232_SPI_SUPPORT == 1
>
> #include <ftdi.h>
> @@ -83,16 +81,16 @@
>        return EXIT_FAILURE;
>    }
>
> -    if (ft2232spi_param && !strlen(ft2232spi_param)) {
> -        free(ft2232spi_param);
> -        ft2232spi_param = NULL;
> +    if (programmer_param && !strlen(programmer_param)) {
> +        free(programmer_param);
> +        programmer_param = NULL;
>    }
> -    if (ft2232spi_param) {
> -        if (strstr(ft2232spi_param, "2232"))
> +    if (programmer_param) {
> +        if (strstr(programmer_param, "2232"))
>            ft2232_type = FTDI_FT2232H;
> -        if (strstr(ft2232spi_param, "4232"))
> +        if (strstr(programmer_param, "4232"))
>            ft2232_type = FTDI_FT4232H;
> -        portpos = strstr(ft2232spi_param, "port=");
> +        portpos = strstr(programmer_param, "port=");
>        if (portpos) {
>            portpos += 5;
>            switch (toupper(*portpos)) {
> @@ -107,7 +105,7 @@
>                    "using default.\n");
>            }
>        }
> -        free(ft2232spi_param);
> +        free(programmer_param);
>    }
>    printf_debug("Using device type %s ",
>             (ft2232_type == FTDI_FT2232H) ? "2232H" : "4232H");
> Index: flashrom-programmer_common_param/satasii.c
> ===================================================================
> --- flashrom-programmer_common_param/satasii.c    (Revision 678)
> +++ flashrom-programmer_common_param/satasii.c    (Arbeitskopie)
> @@ -47,7 +47,7 @@
>
>    get_io_perms();
>
> -    pcidev_init(PCI_VENDOR_ID_SII, satas_sii);
> +    pcidev_init(PCI_VENDOR_ID_SII, satas_sii, programmer_param);
>    id = pcidev_dev->device_id;
>
>    if ((id == 0x3132) || (id == 0x3124)) {
> @@ -71,7 +71,7 @@
>
> int satasii_shutdown(void)
> {
> -    free(pcidev_bdf);
> +    free(programmer_param);
>    pci_cleanup(pacc);
>    release_io_perms();
>    return 0;
> Index: flashrom-programmer_common_param/dummyflasher.c
> ===================================================================
> --- flashrom-programmer_common_param/dummyflasher.c    (Revision 678)
> +++ flashrom-programmer_common_param/dummyflasher.c    (Arbeitskopie)
> @@ -24,45 +24,43 @@
> #include <sys/types.h>
> #include "flash.h"
>
> -char *dummytype = NULL;
> -
> int dummy_init(void)
> {
>    int i;
>    printf_debug("%s\n", __func__);
>
>    /* "all" is equivalent to specifying no type. */
> -    if (dummytype && (!strcmp(dummytype, "all"))) {
> -        free(dummytype);
> -        dummytype = NULL;
> +    if (programmer_param && (!strcmp(programmer_param, "all"))) {
> +        free(programmer_param);
> +        programmer_param = NULL;
>    }
> -    if (!dummytype)
> -        dummytype = strdup("parallel,lpc,fwh,spi");
> +    if (!programmer_param)
> +        programmer_param = strdup("parallel,lpc,fwh,spi");
>    /* Convert the parameters to lowercase. */
> -    for (i = 0; dummytype[i] != '\0'; i++)
> -        dummytype[i] = (char)tolower(dummytype[i]);
> +    for (i = 0; programmer_param[i] != '\0'; i++)
> +        programmer_param[i] = (char)tolower(programmer_param[i]);
>
>    buses_supported = CHIP_BUSTYPE_NONE;
> -    if (strstr(dummytype, "parallel")) {
> +    if (strstr(programmer_param, "parallel")) {
>        buses_supported |= CHIP_BUSTYPE_PARALLEL;
>        printf_debug("Enabling support for %s flash.\n", "parallel");
>    }
> -    if (strstr(dummytype, "lpc")) {
> +    if (strstr(programmer_param, "lpc")) {
>        buses_supported |= CHIP_BUSTYPE_LPC;
>        printf_debug("Enabling support for %s flash.\n", "LPC");
>    }
> -    if (strstr(dummytype, "fwh")) {
> +    if (strstr(programmer_param, "fwh")) {
>        buses_supported |= CHIP_BUSTYPE_FWH;
>        printf_debug("Enabling support for %s flash.\n", "FWH");
>    }
> -    if (strstr(dummytype, "spi")) {
> +    if (strstr(programmer_param, "spi")) {
>        buses_supported |= CHIP_BUSTYPE_SPI;
>        spi_controller = SPI_CONTROLLER_DUMMY;
>        printf_debug("Enabling support for %s flash.\n", "SPI");
>    }
>    if (buses_supported == CHIP_BUSTYPE_NONE)
>        printf_debug("Support for all flash bus types disabled.\n");
> -    free(dummytype);
> +    free(programmer_param);
>    return 0;
> }
>
> Index: flashrom-programmer_common_param/flashrom.c
> ===================================================================
> --- flashrom-programmer_common_param/flashrom.c    (Revision 678)
> +++ flashrom-programmer_common_param/flashrom.c    (Arbeitskopie)
> @@ -34,6 +34,7 @@
> char *chip_to_probe = NULL;
> int verbose = 0;
> enum programmer programmer = PROGRAMMER_INTERNAL;
> +char *programmer_param = NULL;
>
> const struct programmer_entry programmer_table[] = {
>    {
> @@ -642,30 +643,32 @@
>        case 'p':
>            if (strncmp(optarg, "internal", 8) == 0) {
>                programmer = PROGRAMMER_INTERNAL;
> +                if (optarg[8] == '=')
> +                    programmer_param = strdup(optarg + 9);
>            } else if (strncmp(optarg, "dummy", 5) == 0) {
>                programmer = PROGRAMMER_DUMMY;
>                if (optarg[5] == '=')
> -                    dummytype = strdup(optarg + 6);
> +                    programmer_param = strdup(optarg + 6);
>            } else if (strncmp(optarg, "nic3com", 7) == 0) {
>                programmer = PROGRAMMER_NIC3COM;
>                if (optarg[7] == '=')
> -                    pcidev_bdf = strdup(optarg + 8);
> +                    programmer_param = strdup(optarg + 8);
>            } else if (strncmp(optarg, "satasii", 7) == 0) {
>                programmer = PROGRAMMER_SATASII;
>                if (optarg[7] == '=')
> -                    pcidev_bdf = strdup(optarg + 8);
> +                    programmer_param = strdup(optarg + 8);
>            } else if (strncmp(optarg, "it87spi", 7) == 0) {
>                programmer = PROGRAMMER_IT87SPI;
>                if (optarg[7] == '=')
> -                    it87opts = strdup(optarg + 8);
> +                    programmer_param = strdup(optarg + 8);
>            } else if (strncmp(optarg, "ft2232spi", 9) == 0) {
>                programmer = PROGRAMMER_FT2232SPI;
>                if (optarg[9] == '=')
> -                    ft2232spi_param = strdup(optarg + 10);
> +                    programmer_param = strdup(optarg + 10);
>            } else if (strncmp(optarg, "serprog", 7) == 0) {
>                programmer = PROGRAMMER_SERPROG;
>                if (optarg[7] == '=')
> -                    serprog_param = strdup(optarg + 8);
> +                    programmer_param = strdup(optarg + 8);
>            } else {
>                printf("Error: Unknown programmer.\n");
>                exit(1);
>
>
> -- 
> http://www.hailfinger.org/
>
>
> _______________________________________________
> flashrom mailing list
> flashrom@flashrom.org
> http://www.flashrom.org/mailman/listinfo/flashrom
>
Carl-Daniel Hailfinger - 2009-08-12 13:33:49
On 12.08.2009 15:23, Stefan Reinauer wrote:
> Acked-by: Stefan Reinauer <stepan@coresystems.de>
>
> On 12.08.2009, at 14:32, Carl-Daniel Hailfinger
> <c-d.hailfinger.devel.2006@gmx.net> wrote:
>
>> Use a common parameter variable for all programmers. This allows us to
>> reduce #ifdef clauses a lot if we compile out some programmers
>> completely.
>>
>> Signed-off-by: Carl-Daniel Hailfinger
>> <c-d.hailfinger.devel.2006@gmx.net>

Thanks, r679.

Regards,
Carl-Daniel

Patch

Index: flashrom-programmer_common_param/flash.h
===================================================================
--- flashrom-programmer_common_param/flash.h	(Revision 678)
+++ flashrom-programmer_common_param/flash.h	(Arbeitskopie)
@@ -277,7 +277,7 @@ 
 	const char *device_name;
 };
 uint32_t pcidev_validate(struct pci_dev *dev, struct pcidev_status *devs);
-uint32_t pcidev_init(uint16_t vendor_id, struct pcidev_status *devs);
+uint32_t pcidev_init(uint16_t vendor_id, struct pcidev_status *devs, char *pcidev_bdf);
 
 /* print.c */
 char *flashbuses_to_text(enum chipbustype bustype);
@@ -350,7 +350,6 @@ 
 #endif
 
 /* dummyflasher.c */
-extern char *dummytype;
 int dummy_init(void);
 int dummy_shutdown(void);
 void *dummy_map(const char *descr, unsigned long phys_addr, size_t len);
@@ -383,13 +382,13 @@ 
 /* ft2232_spi.c */
 #define FTDI_FT2232H 0x6010
 #define FTDI_FT4232H 0x6011
-extern char *ft2232spi_param;
 int ft2232_spi_init(void);
 int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
 int ft2232_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
 int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf);
 
 /* flashrom.c */
+extern char *programmer_param;
 extern int verbose;
 extern const char *flashrom_version;
 #define printf_debug(x...) { if (verbose) printf(x); }
@@ -399,7 +398,6 @@ 
 int max(int a, int b);
 int check_erased_range(struct flashchip *flash, int start, int len);
 int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, char *message);
-extern char *pcidev_bdf;
 char *strcat_realloc(char *dest, const char *src);
 
 #define OK 0
@@ -507,7 +505,6 @@ 
 int ich_spi_send_multicommand(struct spi_command *spicommands);
 
 /* it87spi.c */
-extern char *it87opts;
 extern uint16_t it8716f_flashport;
 void enter_conf_mode_ite(uint16_t port);
 void exit_conf_mode_ite(uint16_t port);
@@ -628,7 +625,6 @@ 
 int write_stm50flw0x0x(struct flashchip *flash, uint8_t *buf);
 
 /* serprog.c */
-extern char *serprog_param;
 int serprog_init(void);
 int serprog_shutdown(void);
 void serprog_chip_writeb(uint8_t val, chipaddr addr);
Index: flashrom-programmer_common_param/it87spi.c
===================================================================
--- flashrom-programmer_common_param/it87spi.c	(Revision 678)
+++ flashrom-programmer_common_param/it87spi.c	(Arbeitskopie)
@@ -31,7 +31,6 @@ 
 #define ITE_SUPERIO_PORT1	0x2e
 #define ITE_SUPERIO_PORT2	0x4e
 
-char *it87opts = NULL;
 uint16_t it8716f_flashport = 0;
 /* use fast 33MHz SPI (<>0) or slow 16MHz (0) */
 int fast_spi = 1;
@@ -95,11 +94,11 @@ 
 		flashport = sio_read(port, 0x64) << 8;
 		flashport |= sio_read(port, 0x65);
 		printf("Serial flash port 0x%04x\n", flashport);
-		if (it87opts && !strlen(it87opts)) {
-			free(it87opts);
-			it87opts = NULL;
+		if (programmer_param && !strlen(programmer_param)) {
+			free(programmer_param);
+			programmer_param = NULL;
 		}
-		if (it87opts && (portpos = strstr(it87opts, "port="))) {
+		if (programmer_param && (portpos = strstr(programmer_param, "port="))) {
 			portpos += 5;
 			flashport = strtol(portpos, (char **)NULL, 0);
 			printf("Forcing serial flash port 0x%04x\n", flashport);
Index: flashrom-programmer_common_param/pcidev.c
===================================================================
--- flashrom-programmer_common_param/pcidev.c	(Revision 678)
+++ flashrom-programmer_common_param/pcidev.c	(Arbeitskopie)
@@ -26,7 +26,6 @@ 
 uint32_t io_base_addr;
 struct pci_access *pacc;
 struct pci_filter filter;
-char *pcidev_bdf = NULL;
 struct pci_dev *pcidev_dev = NULL;
 
 uint32_t pcidev_validate(struct pci_dev *dev, struct pcidev_status *devs)
@@ -58,7 +57,7 @@ 
 	return 0;
 }
 
-uint32_t pcidev_init(uint16_t vendor_id, struct pcidev_status *devs)
+uint32_t pcidev_init(uint16_t vendor_id, struct pcidev_status *devs, char *pcidev_bdf)
 {
 	struct pci_dev *dev;
 	char *msg = NULL;
Index: flashrom-programmer_common_param/serprog.c
===================================================================
--- flashrom-programmer_common_param/serprog.c	(Revision 678)
+++ flashrom-programmer_common_param/serprog.c	(Arbeitskopie)
@@ -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,16 +37,9 @@ 
 #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:"
 
 #define S_ACK 0x06
@@ -431,15 +430,15 @@ 
 	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 @@ 
 			"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));
Index: flashrom-programmer_common_param/nic3com.c
===================================================================
--- flashrom-programmer_common_param/nic3com.c	(Revision 678)
+++ flashrom-programmer_common_param/nic3com.c	(Arbeitskopie)
@@ -58,7 +58,7 @@ 
 {
 	get_io_perms();
 
-	io_base_addr = pcidev_init(PCI_VENDOR_ID_3COM, nics_3com);
+	io_base_addr = pcidev_init(PCI_VENDOR_ID_3COM, nics_3com, programmer_param);
 	id = pcidev_dev->device_id;
 
 	/* 3COM 3C90xB cards need a special fixup. */
@@ -94,7 +94,7 @@ 
 		OUTL(internal_conf, io_base_addr + INTERNAL_CONFIG);
 	}
 
-	free(pcidev_bdf);
+	free(programmer_param);
 	pci_cleanup(pacc);
 	release_io_perms();
 	return 0;
Index: flashrom-programmer_common_param/ft2232_spi.c
===================================================================
--- flashrom-programmer_common_param/ft2232_spi.c	(Revision 678)
+++ flashrom-programmer_common_param/ft2232_spi.c	(Arbeitskopie)
@@ -26,8 +26,6 @@ 
 #include "flash.h"
 #include "spi.h"
 
-char *ft2232spi_param = NULL;
-
 #if FT2232_SPI_SUPPORT == 1
 
 #include <ftdi.h>
@@ -83,16 +81,16 @@ 
 		return EXIT_FAILURE;
 	}
 
-	if (ft2232spi_param && !strlen(ft2232spi_param)) {
-		free(ft2232spi_param);
-		ft2232spi_param = NULL;
+	if (programmer_param && !strlen(programmer_param)) {
+		free(programmer_param);
+		programmer_param = NULL;
 	}
-	if (ft2232spi_param) {
-		if (strstr(ft2232spi_param, "2232"))
+	if (programmer_param) {
+		if (strstr(programmer_param, "2232"))
 			ft2232_type = FTDI_FT2232H;
-		if (strstr(ft2232spi_param, "4232"))
+		if (strstr(programmer_param, "4232"))
 			ft2232_type = FTDI_FT4232H;
-		portpos = strstr(ft2232spi_param, "port=");
+		portpos = strstr(programmer_param, "port=");
 		if (portpos) {
 			portpos += 5;
 			switch (toupper(*portpos)) {
@@ -107,7 +105,7 @@ 
 					"using default.\n");
 			}
 		}
-		free(ft2232spi_param);
+		free(programmer_param);
 	}
 	printf_debug("Using device type %s ",
 		     (ft2232_type == FTDI_FT2232H) ? "2232H" : "4232H");
Index: flashrom-programmer_common_param/satasii.c
===================================================================
--- flashrom-programmer_common_param/satasii.c	(Revision 678)
+++ flashrom-programmer_common_param/satasii.c	(Arbeitskopie)
@@ -47,7 +47,7 @@ 
 
 	get_io_perms();
 
-	pcidev_init(PCI_VENDOR_ID_SII, satas_sii);
+	pcidev_init(PCI_VENDOR_ID_SII, satas_sii, programmer_param);
 	id = pcidev_dev->device_id;
 
 	if ((id == 0x3132) || (id == 0x3124)) {
@@ -71,7 +71,7 @@ 
 
 int satasii_shutdown(void)
 {
-	free(pcidev_bdf);
+	free(programmer_param);
 	pci_cleanup(pacc);
 	release_io_perms();
 	return 0;
Index: flashrom-programmer_common_param/dummyflasher.c
===================================================================
--- flashrom-programmer_common_param/dummyflasher.c	(Revision 678)
+++ flashrom-programmer_common_param/dummyflasher.c	(Arbeitskopie)
@@ -24,45 +24,43 @@ 
 #include <sys/types.h>
 #include "flash.h"
 
-char *dummytype = NULL;
-
 int dummy_init(void)
 {
 	int i;
 	printf_debug("%s\n", __func__);
 
 	/* "all" is equivalent to specifying no type. */
-	if (dummytype && (!strcmp(dummytype, "all"))) {
-		free(dummytype);
-		dummytype = NULL;
+	if (programmer_param && (!strcmp(programmer_param, "all"))) {
+		free(programmer_param);
+		programmer_param = NULL;
 	}
-	if (!dummytype)
-		dummytype = strdup("parallel,lpc,fwh,spi");
+	if (!programmer_param)
+		programmer_param = strdup("parallel,lpc,fwh,spi");
 	/* Convert the parameters to lowercase. */
-	for (i = 0; dummytype[i] != '\0'; i++)
-		dummytype[i] = (char)tolower(dummytype[i]);
+	for (i = 0; programmer_param[i] != '\0'; i++)
+		programmer_param[i] = (char)tolower(programmer_param[i]);
 
 	buses_supported = CHIP_BUSTYPE_NONE;
-	if (strstr(dummytype, "parallel")) {
+	if (strstr(programmer_param, "parallel")) {
 		buses_supported |= CHIP_BUSTYPE_PARALLEL;
 		printf_debug("Enabling support for %s flash.\n", "parallel");
 	}
-	if (strstr(dummytype, "lpc")) {
+	if (strstr(programmer_param, "lpc")) {
 		buses_supported |= CHIP_BUSTYPE_LPC;
 		printf_debug("Enabling support for %s flash.\n", "LPC");
 	}
-	if (strstr(dummytype, "fwh")) {
+	if (strstr(programmer_param, "fwh")) {
 		buses_supported |= CHIP_BUSTYPE_FWH;
 		printf_debug("Enabling support for %s flash.\n", "FWH");
 	}
-	if (strstr(dummytype, "spi")) {
+	if (strstr(programmer_param, "spi")) {
 		buses_supported |= CHIP_BUSTYPE_SPI;
 		spi_controller = SPI_CONTROLLER_DUMMY;
 		printf_debug("Enabling support for %s flash.\n", "SPI");
 	}
 	if (buses_supported == CHIP_BUSTYPE_NONE)
 		printf_debug("Support for all flash bus types disabled.\n");
-	free(dummytype);
+	free(programmer_param);
 	return 0;
 }
 
Index: flashrom-programmer_common_param/flashrom.c
===================================================================
--- flashrom-programmer_common_param/flashrom.c	(Revision 678)
+++ flashrom-programmer_common_param/flashrom.c	(Arbeitskopie)
@@ -34,6 +34,7 @@ 
 char *chip_to_probe = NULL;
 int verbose = 0;
 enum programmer programmer = PROGRAMMER_INTERNAL;
+char *programmer_param = NULL;
 
 const struct programmer_entry programmer_table[] = {
 	{
@@ -642,30 +643,32 @@ 
 		case 'p':
 			if (strncmp(optarg, "internal", 8) == 0) {
 				programmer = PROGRAMMER_INTERNAL;
+				if (optarg[8] == '=')
+					programmer_param = strdup(optarg + 9);
 			} else if (strncmp(optarg, "dummy", 5) == 0) {
 				programmer = PROGRAMMER_DUMMY;
 				if (optarg[5] == '=')
-					dummytype = strdup(optarg + 6);
+					programmer_param = strdup(optarg + 6);
 			} else if (strncmp(optarg, "nic3com", 7) == 0) {
 				programmer = PROGRAMMER_NIC3COM;
 				if (optarg[7] == '=')
-					pcidev_bdf = strdup(optarg + 8);
+					programmer_param = strdup(optarg + 8);
 			} else if (strncmp(optarg, "satasii", 7) == 0) {
 				programmer = PROGRAMMER_SATASII;
 				if (optarg[7] == '=')
-					pcidev_bdf = strdup(optarg + 8);
+					programmer_param = strdup(optarg + 8);
 			} else if (strncmp(optarg, "it87spi", 7) == 0) {
 				programmer = PROGRAMMER_IT87SPI;
 				if (optarg[7] == '=')
-					it87opts = strdup(optarg + 8);
+					programmer_param = strdup(optarg + 8);
 			} else if (strncmp(optarg, "ft2232spi", 9) == 0) {
 				programmer = PROGRAMMER_FT2232SPI;
 				if (optarg[9] == '=')
-					ft2232spi_param = strdup(optarg + 10);
+					programmer_param = strdup(optarg + 10);
 			} else if (strncmp(optarg, "serprog", 7) == 0) {
 				programmer = PROGRAMMER_SERPROG;
 				if (optarg[7] == '=')
-					serprog_param = strdup(optarg + 8);
+					programmer_param = strdup(optarg + 8);
 			} else {
 				printf("Error: Unknown programmer.\n");
 				exit(1);