On Mon, Jun 01, 2009 at 01:14:55AM +0200, Carl-Daniel Hailfinger wrote:
Add bus type support to the dummy external programmer.
The syntax is explained in the man page. Example: flashrom -p dummy=lpc,fwh
Tested, works perfectly. ;-)
As a nice benefit, it allows easy testing of the "probe only compatible flashes" patch.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Acked-by: Uwe Hermann uwe@hermann-uwe.de
with the small changes below.
Index: flashrom-dummy_bustype/dummyflasher.c
--- flashrom-dummy_bustype/dummyflasher.c (Revision 557) +++ flashrom-dummy_bustype/dummyflasher.c (Arbeitskopie) @@ -20,16 +20,51 @@
#include <string.h> #include <stdlib.h> +#include <ctype.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <errno.h> #include "flash.h"
+char *dummytype = NULL;
int dummy_init(void) {
- int i; printf_debug("%s\n", __func__);
- spi_controller = SPI_CONTROLLER_DUMMY;
- /* "all" is equivalent to specifying no type. */
- if (!strcmp(dummytype, "all")) {
Use strncmp() whereever possible please.
free(dummytype);
dummytype = NULL;
- }
- if (!dummytype)
dummytype = strdup("parallel,lpc,fwh,spi");
- for (i = 0; dummytype[i] != '\0'; i++)
dummytype[i] = (char)tolower(dummytype[i]);
- buses_supported = CHIP_BUSTYPE_NONE;
- if (strstr(dummytype, "parallel")) {
buses_supported |= CHIP_BUSTYPE_PARALLEL;
printf_debug("Enabling support for parallel flash.\n");
- }
- if (strstr(dummytype, "lpc")) {
buses_supported |= CHIP_BUSTYPE_LPC;
printf_debug("Enabling support for LPC flash.\n");
- }
- if (strstr(dummytype, "fwh")) {
buses_supported |= CHIP_BUSTYPE_FWH;
printf_debug("Enabling support for FWH flash.\n");
- }
- if (strstr(dummytype, "spi")) {
buses_supported |= CHIP_BUSTYPE_SPI;
spi_controller = SPI_CONTROLLER_DUMMY;
printf_debug("Enabling support for SPI flash.\n");
- }
You can use this nice little trick Stefan mentioned last year or so, which will save a few bytes in binary size (not that it's too important in the case of flashrom, but still).
printf_debug("Enabling support for %s flash.\n", "parallel"); printf_debug("Enabling support for %s flash.\n", "LPC"); printf_debug("Enabling support for %s flash.\n", "FWH"); printf_debug("Enabling support for %s flash.\n", "SPI");
Uwe.