summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohanna Schander <coreboot@mimoja.de>2020-01-04 04:05:02 +0100
committerKyösti Mälkki <kyosti.malkki@gmail.com>2020-01-07 20:50:03 +0000
commit1c9746ceaf683f97b584a78bde1ea13778ec7cdd (patch)
treea532672dfccf414fe4e1a26ff9fd9576e0025398 /src
parent23063305dcee93317d1dd6b424de8a74f1c60d7e (diff)
downloadcoreboot-1c9746ceaf683f97b584a78bde1ea13778ec7cdd.tar.xz
drivers/spi/flashconsole: Fix shadowing local variable
Commit c9b13594eb8d425e54a126b5c10e3f6fbc41528b removed the g_ prefix from global variables, leaving the local "offset" variable shadowing the global one. This commit partially reverts this by renaming one of the occations and converting the flushing logic to work on the global object. Change-Id: I246ebdcfd3b973e6a4aa3c15fc5f32497dcf8398 Signed-off-by: Johanna Schander <coreboot@mimoja.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/38171 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: HAOUAS Elyes <ehaouas@noos.fr> Reviewed-by: Patrick Rudolph <siro@das-labor.org> Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/drivers/spi/flashconsole.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/drivers/spi/flashconsole.c b/src/drivers/spi/flashconsole.c
index 80c63e07ea..2216e7df90 100644
--- a/src/drivers/spi/flashconsole.c
+++ b/src/drivers/spi/flashconsole.c
@@ -32,7 +32,7 @@ void flashconsole_init(void)
{
uint8_t buffer[READ_BUFFER_SIZE];
size_t size;
- size_t offset = 0;
+ size_t initial_offset = 0;
size_t len = READ_BUFFER_SIZE;
size_t i;
@@ -52,30 +52,30 @@ void flashconsole_init(void)
* the sector is already erased, so we would need to read
* anyways to check if it's all 0xff).
*/
- for (i = 0; i < len && offset < size;) {
+ for (i = 0; i < len && initial_offset < size;) {
// Fill the buffer on first iteration
if (i == 0) {
len = MIN(READ_BUFFER_SIZE, size - offset);
- if (rdev_readat(&rdev, buffer, offset, len) != len)
+ if (rdev_readat(&rdev, buffer, initial_offset, len) != len)
return;
}
if (buffer[i] == 0xff) {
- offset += i;
+ initial_offset += i;
break;
}
// If we're done, repeat the process for the next sector
if (++i == READ_BUFFER_SIZE) {
- offset += len;
+ initial_offset += len;
i = 0;
}
}
// Make sure there is still space left on the console
- if (offset >= size) {
+ if (initial_offset >= size) {
printk(BIOS_INFO, "No space left on 'console' region in SPI flash\n");
return;
}
- offset = offset;
+ offset = initial_offset;
rdev_ptr = &rdev;
}
@@ -96,7 +96,6 @@ void flashconsole_tx_byte(unsigned char c)
void flashconsole_tx_flush(void)
{
- size_t offset = offset;
size_t len = line_offset;
size_t region_size;
static int busy;
@@ -122,7 +121,7 @@ void flashconsole_tx_flush(void)
if (offset + len >= region_size)
return;
- offset = offset + len;
+ offset += len;
line_offset = 0;
busy = 0;