summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/drivers/spi/boot_device_rw_nommap.c40
1 files changed, 12 insertions, 28 deletions
diff --git a/src/drivers/spi/boot_device_rw_nommap.c b/src/drivers/spi/boot_device_rw_nommap.c
index 47683144a8..5de9a71ceb 100644
--- a/src/drivers/spi/boot_device_rw_nommap.c
+++ b/src/drivers/spi/boot_device_rw_nommap.c
@@ -11,24 +11,18 @@
* GNU General Public License for more details.
*/
-#include <arch/early_variables.h>
#include <boot_device.h>
#include <spi_flash.h>
#include <spi-generic.h>
#include <stdint.h>
-static struct spi_flash sfg CAR_GLOBAL;
-static bool sfg_init_done CAR_GLOBAL;
+static struct spi_flash sfg;
+static bool sfg_init_done;
static ssize_t spi_readat(const struct region_device *rd, void *b,
size_t offset, size_t size)
{
- struct spi_flash *sf = car_get_var_ptr(&sfg);
-
- if (sf == NULL)
- return -1;
-
- if (spi_flash_read(sf, offset, size, b))
+ if (spi_flash_read(&sfg, offset, size, b))
return -1;
return size;
@@ -37,12 +31,7 @@ static ssize_t spi_readat(const struct region_device *rd, void *b,
static ssize_t spi_writeat(const struct region_device *rd, const void *b,
size_t offset, size_t size)
{
- struct spi_flash *sf = car_get_var_ptr(&sfg);
-
- if (sf == NULL)
- return -1;
-
- if (spi_flash_write(sf, offset, size, b))
+ if (spi_flash_write(&sfg, offset, size, b))
return -1;
return size;
@@ -51,12 +40,7 @@ static ssize_t spi_writeat(const struct region_device *rd, const void *b,
static ssize_t spi_eraseat(const struct region_device *rd,
size_t offset, size_t size)
{
- struct spi_flash *sf = car_get_var_ptr(&sfg);
-
- if (sf == NULL)
- return -1;
-
- if (spi_flash_erase(sf, offset, size))
+ if (spi_flash_erase(&sfg, offset, size))
return -1;
return size;
@@ -76,14 +60,14 @@ static void boot_device_rw_init(void)
const int bus = CONFIG_BOOT_DEVICE_SPI_FLASH_BUS;
const int cs = 0;
- if (car_get_var(sfg_init_done) == true)
+ if (sfg_init_done == true)
return;
/* Ensure any necessary setup is performed by the drivers. */
spi_init();
- if (!spi_flash_probe(bus, cs, car_get_var_ptr(&sfg)))
- car_set_var(sfg_init_done, true);
+ if (!spi_flash_probe(bus, cs, &sfg))
+ sfg_init_done = true;
}
const struct region_device *boot_device_rw(void)
@@ -91,7 +75,7 @@ const struct region_device *boot_device_rw(void)
/* Probe for the SPI flash device if not already done. */
boot_device_rw_init();
- if (car_get_var(sfg_init_done) != true)
+ if (sfg_init_done != true)
return NULL;
return &spi_rw;
@@ -101,10 +85,10 @@ const struct spi_flash *boot_device_spi_flash(void)
{
boot_device_rw_init();
- if (car_get_var(sfg_init_done) != true)
+ if (sfg_init_done != true)
return NULL;
- return car_get_var_ptr(&sfg);
+ return &sfg;
}
int boot_device_wp_region(const struct region_device *rd,
@@ -122,7 +106,7 @@ int boot_device_wp_region(const struct region_device *rd,
if (type == MEDIA_WP) {
if (spi_flash_is_write_protected(boot_dev,
- region_device_region(rd)) != 1) {
+ region_device_region(rd)) != 1) {
return spi_flash_set_write_protected(boot_dev,
region_device_region(rd), true,
SPI_WRITE_PROTECTION_REBOOT);