Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/37044 )
Change subject: drivers/spi/boot_device_rw_nommap.c: Drop CAR_GLOBAL_MIGRATION support ......................................................................
drivers/spi/boot_device_rw_nommap.c: Drop CAR_GLOBAL_MIGRATION support
Change-Id: I613c28a2d06f5f0216deb75960ab660941ef8057 Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M src/drivers/spi/boot_device_rw_nommap.c 1 file changed, 12 insertions(+), 28 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/44/37044/1
diff --git a/src/drivers/spi/boot_device_rw_nommap.c b/src/drivers/spi/boot_device_rw_nommap.c index 4768314..5de9a71 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_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_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 @@ 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 @@ /* 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 @@ { 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 @@
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);
HAOUAS Elyes has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37044 )
Change subject: drivers/spi/boot_device_rw_nommap.c: Drop CAR_GLOBAL_MIGRATION support ......................................................................
Patch Set 7: Code-Review+1
Kyösti Mälkki has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37044 )
Change subject: drivers/spi/boot_device_rw_nommap.c: Drop CAR_GLOBAL_MIGRATION support ......................................................................
Patch Set 7: Code-Review+2
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37044 )
Change subject: drivers/spi/boot_device_rw_nommap.c: Drop CAR_GLOBAL_MIGRATION support ......................................................................
Patch Set 7:
(1 comment)
https://review.coreboot.org/c/coreboot/+/37044/7/src/drivers/spi/boot_device... File src/drivers/spi/boot_device_rw_nommap.c:
https://review.coreboot.org/c/coreboot/+/37044/7/src/drivers/spi/boot_device... PS7, Line 28: if (sf == NULL) again, should this null check be kept? (same for the others)
Kyösti Mälkki has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37044 )
Change subject: drivers/spi/boot_device_rw_nommap.c: Drop CAR_GLOBAL_MIGRATION support ......................................................................
Patch Set 7:
(1 comment)
https://review.coreboot.org/c/coreboot/+/37044/7/src/drivers/spi/boot_device... File src/drivers/spi/boot_device_rw_nommap.c:
https://review.coreboot.org/c/coreboot/+/37044/7/src/drivers/spi/boot_device... PS7, Line 28: if (sf == NULL)
again, should this null check be kept? (same for the others)
To me it appeared sfg_init_done acts as the guard.
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37044 )
Change subject: drivers/spi/boot_device_rw_nommap.c: Drop CAR_GLOBAL_MIGRATION support ......................................................................
Patch Set 7:
(1 comment)
https://review.coreboot.org/c/coreboot/+/37044/7/src/drivers/spi/boot_device... File src/drivers/spi/boot_device_rw_nommap.c:
https://review.coreboot.org/c/coreboot/+/37044/7/src/drivers/spi/boot_device... PS7, Line 28: if (sf == NULL)
To me it appeared sfg_init_done acts as the guard.
Ack
Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/37044 )
Change subject: drivers/spi/boot_device_rw_nommap.c: Drop CAR_GLOBAL_MIGRATION support ......................................................................
drivers/spi/boot_device_rw_nommap.c: Drop CAR_GLOBAL_MIGRATION support
Change-Id: I613c28a2d06f5f0216deb75960ab660941ef8057 Signed-off-by: Arthur Heymans arthur@aheymans.xyz Reviewed-on: https://review.coreboot.org/c/coreboot/+/37044 Reviewed-by: HAOUAS Elyes ehaouas@noos.fr Reviewed-by: Kyösti Mälkki kyosti.malkki@gmail.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/drivers/spi/boot_device_rw_nommap.c 1 file changed, 12 insertions(+), 28 deletions(-)
Approvals: build bot (Jenkins): Verified Kyösti Mälkki: Looks good to me, approved HAOUAS Elyes: Looks good to me, but someone else must approve
diff --git a/src/drivers/spi/boot_device_rw_nommap.c b/src/drivers/spi/boot_device_rw_nommap.c index 4768314..5de9a71 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_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_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 @@ 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 @@ /* 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 @@ { 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 @@
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);