summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2023-04-01 12:32:52 +1100
committerEdward O'Callaghan <quasisec@chromium.org>2023-04-06 05:15:03 +0000
commit21901c11e7e83a0cd1c28c727430a0fe3689353e (patch)
tree811d90ce655336bb30ce4141aaedad6055cde55e
parent67b5526d5c46bfc4d70fb288b9227097fc113e30 (diff)
downloadflashrom-git-21901c11e7e83a0cd1c28c727430a0fe3689353e.tar.gz
tree/: Case write_granularity enum values
Change-Id: Ic8c655225abe477c1b618dc685b743e691c16ebd Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/74165 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r--at45db.c12
-rw-r--r--flashchips.c6
-rw-r--r--flashrom.c40
-rw-r--r--include/flash.h20
-rw-r--r--nicintel_eeprom.c4
5 files changed, 41 insertions, 41 deletions
diff --git a/at45db.c b/at45db.c
index 78773309..6d66a6e9 100644
--- a/at45db.c
+++ b/at45db.c
@@ -200,12 +200,12 @@ int probe_spi_at45db(struct flashctx *flash)
}
switch (chip->page_size) {
- case 256: chip->gran = write_gran_256bytes; break;
- case 264: chip->gran = write_gran_264bytes; break;
- case 512: chip->gran = write_gran_512bytes; break;
- case 528: chip->gran = write_gran_528bytes; break;
- case 1024: chip->gran = write_gran_1024bytes; break;
- case 1056: chip->gran = write_gran_1056bytes; break;
+ case 256: chip->gran = WRITE_GRAN_256BYTES; break;
+ case 264: chip->gran = WRITE_GRAN_264BYTES; break;
+ case 512: chip->gran = WRITE_GRAN_512BYTES; break;
+ case 528: chip->gran = WRITE_GRAN_528BYTES; break;
+ case 1024: chip->gran = WRITE_GRAN_1024BYTES; break;
+ case 1056: chip->gran = WRITE_GRAN_1056BYTES; break;
default:
msg_cerr("%s: unknown page size %d.\n", __func__, chip->page_size);
return 0;
diff --git a/flashchips.c b/flashchips.c
index dc6e882f..6a5cf495 100644
--- a/flashchips.c
+++ b/flashchips.c
@@ -2762,7 +2762,7 @@ const struct flashchip flashchips[] = {
.write = SPI_WRITE_AT45DB,
.read = SPI_READ_AT45DB,
.voltage = {2700, 3600},
- .gran = write_gran_1056bytes,
+ .gran = WRITE_GRAN_1056BYTES,
},
{
@@ -3015,7 +3015,7 @@ const struct flashchip flashchips[] = {
.write = SPI_WRITE_AT45DB,
.read = SPI_READ_AT45DB_E8, /* 3 address and 4 dummy bytes */
.voltage = {2700, 3600},
- .gran = write_gran_528bytes,
+ .gran = WRITE_GRAN_528BYTES,
},
{
@@ -3638,7 +3638,7 @@ const struct flashchip flashchips[] = {
.write = EDI_CHIP_WRITE,
.read = EDI_CHIP_READ,
.voltage = {2700, 3600},
- .gran = write_gran_128bytes,
+ .gran = WRITE_GRAN_128BYTES,
},
{
diff --git a/flashrom.c b/flashrom.c
index 01c78fd5..3e6e0fb5 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -719,42 +719,42 @@ int need_erase(const uint8_t *have, const uint8_t *want, unsigned int len,
unsigned int i;
switch (gran) {
- case write_gran_1bit:
+ case WRITE_GRAN_1BIT:
for (i = 0; i < len; i++)
if ((have[i] & want[i]) != want[i]) {
result = 1;
break;
}
break;
- case write_gran_1byte:
+ case WRITE_GRAN_1BYTE:
for (i = 0; i < len; i++)
if ((have[i] != want[i]) && (have[i] != erased_value)) {
result = 1;
break;
}
break;
- case write_gran_128bytes:
+ case WRITE_GRAN_128BYTES:
result = need_erase_gran_bytes(have, want, len, 128, erased_value);
break;
- case write_gran_256bytes:
+ case WRITE_GRAN_256BYTES:
result = need_erase_gran_bytes(have, want, len, 256, erased_value);
break;
- case write_gran_264bytes:
+ case WRITE_GRAN_264BYTES:
result = need_erase_gran_bytes(have, want, len, 264, erased_value);
break;
- case write_gran_512bytes:
+ case WRITE_GRAN_512BYTES:
result = need_erase_gran_bytes(have, want, len, 512, erased_value);
break;
- case write_gran_528bytes:
+ case WRITE_GRAN_528BYTES:
result = need_erase_gran_bytes(have, want, len, 528, erased_value);
break;
- case write_gran_1024bytes:
+ case WRITE_GRAN_1024BYTES:
result = need_erase_gran_bytes(have, want, len, 1024, erased_value);
break;
- case write_gran_1056bytes:
+ case WRITE_GRAN_1056BYTES:
result = need_erase_gran_bytes(have, want, len, 1056, erased_value);
break;
- case write_gran_1byte_implicit_erase:
+ case WRITE_GRAN_1BYTE_IMPLICIT_ERASE:
/* Do not erase, handle content changes from anything->0xff by writing 0xff. */
result = 0;
break;
@@ -797,30 +797,30 @@ unsigned int get_next_write(const uint8_t *have, const uint8_t *want, unsigned i
unsigned int i, limit, stride;
switch (gran) {
- case write_gran_1bit:
- case write_gran_1byte:
- case write_gran_1byte_implicit_erase:
+ case WRITE_GRAN_1BIT:
+ case WRITE_GRAN_1BYTE:
+ case WRITE_GRAN_1BYTE_IMPLICIT_ERASE:
stride = 1;
break;
- case write_gran_128bytes:
+ case WRITE_GRAN_128BYTES:
stride = 128;
break;
- case write_gran_256bytes:
+ case WRITE_GRAN_256BYTES:
stride = 256;
break;
- case write_gran_264bytes:
+ case WRITE_GRAN_264BYTES:
stride = 264;
break;
- case write_gran_512bytes:
+ case WRITE_GRAN_512BYTES:
stride = 512;
break;
- case write_gran_528bytes:
+ case WRITE_GRAN_528BYTES:
stride = 528;
break;
- case write_gran_1024bytes:
+ case WRITE_GRAN_1024BYTES:
stride = 1024;
break;
- case write_gran_1056bytes:
+ case WRITE_GRAN_1056BYTES:
stride = 1056;
break;
default:
diff --git a/include/flash.h b/include/flash.h
index f0357cba..3e9c885f 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -83,17 +83,17 @@ enum chipbustype {
*/
enum write_granularity {
/* We assume 256 byte granularity by default. */
- write_gran_256bytes = 0,/* If less than 256 bytes are written, the unwritten bytes are undefined. */
- write_gran_1bit, /* Each bit can be cleared individually. */
- write_gran_1byte, /* A byte can be written once. Further writes to an already written byte cause
+ WRITE_GRAN_256BYTES = 0,/* If less than 256 bytes are written, the unwritten bytes are undefined. */
+ WRITE_GRAN_1BIT, /* Each bit can be cleared individually. */
+ WRITE_GRAN_1BYTE, /* A byte can be written once. Further writes to an already written byte cause
* its contents to be either undefined or to stay unchanged. */
- write_gran_128bytes, /* If less than 128 bytes are written, the unwritten bytes are undefined. */
- write_gran_264bytes, /* If less than 264 bytes are written, the unwritten bytes are undefined. */
- write_gran_512bytes, /* If less than 512 bytes are written, the unwritten bytes are undefined. */
- write_gran_528bytes, /* If less than 528 bytes are written, the unwritten bytes are undefined. */
- write_gran_1024bytes, /* If less than 1024 bytes are written, the unwritten bytes are undefined. */
- write_gran_1056bytes, /* If less than 1056 bytes are written, the unwritten bytes are undefined. */
- write_gran_1byte_implicit_erase, /* EEPROMs and other chips with implicit erase and 1-byte writes. */
+ WRITE_GRAN_128BYTES, /* If less than 128 bytes are written, the unwritten bytes are undefined. */
+ WRITE_GRAN_264BYTES, /* If less than 264 bytes are written, the unwritten bytes are undefined. */
+ WRITE_GRAN_512BYTES, /* If less than 512 bytes are written, the unwritten bytes are undefined. */
+ WRITE_GRAN_528BYTES, /* If less than 528 bytes are written, the unwritten bytes are undefined. */
+ WRITE_GRAN_1024BYTES, /* If less than 1024 bytes are written, the unwritten bytes are undefined. */
+ WRITE_GRAN_1056BYTES, /* If less than 1056 bytes are written, the unwritten bytes are undefined. */
+ WRITE_GRAN_1BYTE_IMPLICIT_ERASE, /* EEPROMs and other chips with implicit erase and 1-byte writes. */
};
/*
diff --git a/nicintel_eeprom.c b/nicintel_eeprom.c
index 80ccd887..2c351da3 100644
--- a/nicintel_eeprom.c
+++ b/nicintel_eeprom.c
@@ -116,7 +116,7 @@ static int nicintel_ee_probe_i210(struct flashctx *flash)
flash->chip->total_size = 4;
flash->chip->page_size = flash->chip->total_size * 1024;
flash->chip->tested = TEST_OK_PREWB;
- flash->chip->gran = write_gran_1byte_implicit_erase;
+ flash->chip->gran = WRITE_GRAN_1BYTE_IMPLICIT_ERASE;
flash->chip->block_erasers->eraseblocks[0].size = flash->chip->page_size;
flash->chip->block_erasers->eraseblocks[0].count = 1;
@@ -147,7 +147,7 @@ static int nicintel_ee_probe_82580(struct flashctx *flash)
flash->chip->page_size = EE_PAGE_MASK + 1;
flash->chip->tested = TEST_OK_PREWB;
- flash->chip->gran = write_gran_1byte_implicit_erase;
+ flash->chip->gran = WRITE_GRAN_1BYTE_IMPLICIT_ERASE;
flash->chip->block_erasers->eraseblocks[0].size = (EE_PAGE_MASK + 1);
flash->chip->block_erasers->eraseblocks[0].count = (flash->chip->total_size * 1024) / (EE_PAGE_MASK + 1);