1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 23:22:37 +02:00

jedec.c: Provide better lexical scope to itermediates

Change-Id: I8e01d471bb33a933b80760df2c69a4bf3589ba76
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/73285
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
This commit is contained in:
Edward O'Callaghan 2023-02-26 17:06:06 +11:00 committed by Thomas Heijligen
parent 439f096049
commit 648dc4a653

16
jedec.c
View File

@ -38,13 +38,11 @@ uint8_t oddparity(uint8_t val)
static void toggle_ready_jedec_common(const struct flashctx *flash, chipaddr dst, unsigned int delay) static void toggle_ready_jedec_common(const struct flashctx *flash, chipaddr dst, unsigned int delay)
{ {
unsigned int i = 0; unsigned int i = 0;
uint8_t tmp1, tmp2; uint8_t tmp1 = chip_readb(flash, dst) & 0x40;
tmp1 = chip_readb(flash, dst) & 0x40;
while (i++ < 0xFFFFFFF) { while (i++ < 0xFFFFFFF) {
programmer_delay(flash, delay); programmer_delay(flash, delay);
tmp2 = chip_readb(flash, dst) & 0x40; uint8_t tmp2 = chip_readb(flash, dst) & 0x40;
if (tmp1 == tmp2) { if (tmp1 == tmp2) {
break; break;
} }
@ -76,12 +74,11 @@ void data_polling_jedec(const struct flashctx *flash, chipaddr dst,
uint8_t data) uint8_t data)
{ {
unsigned int i = 0; unsigned int i = 0;
uint8_t tmp;
data &= 0x80; data &= 0x80;
while (i++ < 0xFFFFFFF) { while (i++ < 0xFFFFFFF) {
tmp = chip_readb(flash, dst) & 0x80; uint8_t tmp = chip_readb(flash, dst) & 0x80;
if (tmp == data) { if (tmp == data) {
break; break;
} }
@ -377,12 +374,11 @@ static int write_byte_program_jedec_common(const struct flashctx *flash, const u
int write_jedec_1(struct flashctx *flash, const uint8_t *src, unsigned int start, int write_jedec_1(struct flashctx *flash, const uint8_t *src, unsigned int start,
unsigned int len) unsigned int len)
{ {
unsigned int i;
int failed = 0; int failed = 0;
chipaddr dst = flash->virtual_memory + start; chipaddr dst = flash->virtual_memory + start;
const chipaddr olddst = dst; const chipaddr olddst = dst;
for (i = 0; i < len; i++) { for (unsigned int i = 0; i < len; i++) {
if (write_byte_program_jedec_common(flash, src, dst)) if (write_byte_program_jedec_common(flash, src, dst))
failed = 1; failed = 1;
dst++, src++; dst++, src++;
@ -444,7 +440,7 @@ static int jedec_write_page(struct flashctx *flash, const uint8_t *src,
int write_jedec(struct flashctx *flash, const uint8_t *buf, unsigned int start, int write_jedec(struct flashctx *flash, const uint8_t *buf, unsigned int start,
int unsigned len) int unsigned len)
{ {
unsigned int i, starthere, lenhere; unsigned int starthere, lenhere;
/* FIXME: page_size is the wrong variable. We need max_writechunk_size /* FIXME: page_size is the wrong variable. We need max_writechunk_size
* in struct flashctx to do this properly. All chips using * in struct flashctx to do this properly. All chips using
* write_jedec have page_size set to max_writechunk_size, so * write_jedec have page_size set to max_writechunk_size, so
@ -462,7 +458,7 @@ int write_jedec(struct flashctx *flash, const uint8_t *buf, unsigned int start,
* (start + len - 1) / page_size. Since we want to include that last * (start + len - 1) / page_size. Since we want to include that last
* page as well, the loop condition uses <=. * page as well, the loop condition uses <=.
*/ */
for (i = start / page_size; i <= nwrites; i++) { for (unsigned int i = start / page_size; i <= nwrites; i++) {
/* Byte position of the first byte in the range in this page. */ /* Byte position of the first byte in the range in this page. */
/* starthere is an offset to the base address of the chip. */ /* starthere is an offset to the base address of the chip. */
starthere = max(start, i * page_size); starthere = max(start, i * page_size);