dummyflasher.c: Drop useless macros
The `EMULATE_CHIP` and `EMULATE_SPI_CHIP` macros are unconditionally
defined as `1`, with no way to change their values. Since this means
that the code never gets build-tested using other values, drop these
noisy macros.
Tested: Build with `make distclean && make VERSION=none -j` with and
without this patch, the flashrom executable does not change.
Change-Id: If46e1c37c3b04b28b4ba1f82c9b3def1e549368f
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/55265
Original-Reviewed-by: Nico Huber <nico.h@gmx.de>
Original-Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Original-Reviewed-by: Namyoon Woo <namyoon@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/71370
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
diff --git a/dummyflasher.c b/dummyflasher.c
index a8bf8f0..e947f00 100644
--- a/dummyflasher.c
+++ b/dummyflasher.c
@@ -22,20 +22,11 @@
#include "chipdrivers.h"
#include "programmer.h"
-/* Remove the #define below if you don't want SPI flash chip emulation. */
-#define EMULATE_SPI_CHIP 1
-
-#if EMULATE_SPI_CHIP
-#define EMULATE_CHIP 1
#include "spi.h"
-#endif
-#if EMULATE_CHIP
#include <sys/types.h>
#include <sys/stat.h>
-#endif
-#if EMULATE_CHIP
enum emu_chip {
EMULATE_NONE,
EMULATE_ST_M25P10_RES,
@@ -66,7 +57,6 @@
uint8_t *flashchip_contents;
};
-#if EMULATE_SPI_CHIP
/* A legit complete SFDP table based on the MX25L6436E (rev. 1.8) datasheet. */
static const uint8_t sfdp_table[] = {
0x53, 0x46, 0x44, 0x50, // @0x00: SFDP signature
@@ -93,8 +83,6 @@
0xFF, 0xFF, 0xFF, 0xFF, // @0x54: Macronix parameter table end
};
-#endif
-#endif
static unsigned int spi_write_256_chunksize = 256;
@@ -136,7 +124,6 @@
static int dummy_shutdown(void *data)
{
msg_pspew("%s\n", __func__);
-#if EMULATE_CHIP
struct emu_data *emu_data = (struct emu_data *)data;
if (emu_data->emu_chip != EMULATE_NONE) {
if (emu_data->emu_persistent_image && emu_data->emu_modified) {
@@ -148,7 +135,6 @@
free(emu_data->emu_persistent_image);
free(emu_data->flashchip_contents);
}
-#endif
free(data);
return 0;
}
@@ -159,9 +145,7 @@
char *tmp = NULL;
unsigned int i;
char *endptr;
-#if EMULATE_SPI_CHIP
char *status = NULL;
-#endif
bustext = extract_programmer_param("bus");
msg_pdbg("Requested buses are: %s\n", bustext ? bustext : "default");
@@ -274,7 +258,6 @@
}
free(tmp);
-#if EMULATE_CHIP
tmp = extract_programmer_param("emulate");
if (!tmp) {
msg_pdbg("Not emulating any flash chip.\n");
@@ -282,7 +265,6 @@
return 0;
}
-#if EMULATE_SPI_CHIP
if (!strcmp(tmp, "M25P10.RES")) {
data->emu_chip = EMULATE_ST_M25P10_RES;
data->emu_chip_size = 128 * 1024;
@@ -347,7 +329,6 @@
data->emu_jedec_ce_c7_size = data->emu_chip_size;
msg_pdbg("Emulating Winbond W25Q128FV SPI flash chip (RDID)\n");
}
-#endif /* EMULATE_SPI_CHIP */
if (data->emu_chip == EMULATE_NONE) {
msg_perr("Invalid chip specified for emulation: %s\n", tmp);
free(tmp);
@@ -355,7 +336,6 @@
}
free(tmp);
-#ifdef EMULATE_SPI_CHIP
status = extract_programmer_param("spi_status");
if (status) {
errno = 0;
@@ -370,7 +350,6 @@
msg_pdbg("Initial status register is set to 0x%02x.\n",
data->emu_status);
}
-#endif /* EMULATE_SPI_CHIP */
data->flashchip_contents = malloc(data->emu_chip_size);
if (!data->flashchip_contents) {
@@ -378,16 +357,13 @@
return 1;
}
-#endif /* EMULATE_CHIP */
return 0;
}
int dummy_init(void)
{
-#if EMULATE_CHIP
struct stat image_stat;
-#endif
struct emu_data *data = calloc(1, sizeof(struct emu_data));
if (!data) {
@@ -406,7 +382,6 @@
return 1;
}
-#if EMULATE_CHIP
if (data->emu_chip == EMULATE_NONE) {
msg_pdbg("Not emulating any flash chip.\n");
/* Nothing else to do. */
@@ -442,7 +417,6 @@
msg_pdbg("doesn't match.\n");
}
}
-#endif /* EMULATE_CHIP */
dummy_init_out:
if (register_shutdown(dummy_shutdown, data)) {
@@ -523,7 +497,6 @@
return;
}
-#if EMULATE_SPI_CHIP
static int emulate_spi_chip_response(unsigned int writecnt,
unsigned int readcnt,
const unsigned char *writearr,
@@ -868,7 +841,6 @@
data->emu_status &= ~SPI_SR_WEL;
return 0;
}
-#endif
static int dummy_spi_send_command(const struct flashctx *flash, unsigned int writecnt,
unsigned int readcnt,
@@ -890,7 +862,6 @@
/* Response for unknown commands and missing chip is 0xff. */
memset(readarr, 0xff, readcnt);
-#if EMULATE_SPI_CHIP
switch (emu_data->emu_chip) {
case EMULATE_ST_M25P10_RES:
case EMULATE_SST_SST25VF040_REMS:
@@ -906,7 +877,6 @@
default:
break;
}
-#endif
msg_pspew(" reading %u bytes:", readcnt);
for (i = 0; i < readcnt; i++)
msg_pspew(" 0x%02x", readarr[i]);