[Skiboot] [PATCH v3 3/7] libflash: Reintroduce typesafety in lowlevel libflash calls
Cyril Bur
cyril.bur at au1.ibm.com
Wed Aug 26 16:02:34 AEST 2015
Previous work did away with some typesafety when adding the
blocklevel_device abstraction, this has resulted in the ability to
accidently call libflash low level code with a blocklevel_device which has
not been initialised by the libflash backend.
The end result will not be good. Best to reintroduce that low level calls
be called with libflashes own structures.
Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
---
external/common/arch_flash_arm.c | 4 ++--
libflash/libflash.c | 6 ++----
libflash/libflash.h | 4 ++--
3 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/external/common/arch_flash_arm.c b/external/common/arch_flash_arm.c
index 576c5e8..b3c9454 100644
--- a/external/common/arch_flash_arm.c
+++ b/external/common/arch_flash_arm.c
@@ -235,7 +235,7 @@ int arch_flash_erase_chip(struct blocklevel_device *bl)
if (!arch_data.flash_chip)
return -1;
- return flash_erase_chip(bl);
+ return flash_erase_chip(arch_data.flash_chip);
}
int arch_flash_4b_mode(struct blocklevel_device *bl, int set_4b)
@@ -247,7 +247,7 @@ int arch_flash_4b_mode(struct blocklevel_device *bl, int set_4b)
if (!arch_data.flash_chip)
return -1;
- return flash_force_4b_mode(bl, set_4b);
+ return flash_force_4b_mode(arch_data.flash_chip, set_4b);
}
int arch_flash_set_wrprotect(struct blocklevel_device *bl, int set)
diff --git a/libflash/libflash.c b/libflash/libflash.c
index 4b9948b..c43f212 100644
--- a/libflash/libflash.c
+++ b/libflash/libflash.c
@@ -267,9 +267,8 @@ static int flash_erase(struct blocklevel_device *bl, uint32_t dst, uint32_t size
return 0;
}
-int flash_erase_chip(struct blocklevel_device *bl)
+int flash_erase_chip(struct flash_chip *c)
{
- struct flash_chip *c = container_of(bl, struct flash_chip, bl);
struct spi_flash_ctrl *ct = c->ctrl;
int rc;
@@ -692,9 +691,8 @@ static int flash_set_4b(struct flash_chip *c, bool enable)
return ct->cmd_wr(ct, enable ? CMD_EN4B : CMD_EX4B, false, 0, NULL, 0);
}
-int flash_force_4b_mode(struct blocklevel_device *bl, bool enable_4b)
+int flash_force_4b_mode(struct flash_chip *c, bool enable_4b)
{
- struct flash_chip *c = container_of(bl, struct flash_chip, bl);
struct spi_flash_ctrl *ct = c->ctrl;
int rc;
diff --git a/libflash/libflash.h b/libflash/libflash.h
index 3fdd00b..4fecfe7 100644
--- a/libflash/libflash.h
+++ b/libflash/libflash.h
@@ -57,7 +57,7 @@ void flash_exit_close(struct blocklevel_device *bl, void (*close)(struct spi_fla
/* libflash sets the 4b mode automatically based on the flash
* size and controller capabilities but it can be overriden
*/
-int flash_force_4b_mode(struct blocklevel_device *bl, bool enable_4b);
+int flash_force_4b_mode(struct flash_chip *c, bool enable_4b);
/*
* This provides a wapper around flash_read() on ECCed data. All params are
@@ -95,6 +95,6 @@ int flash_smart_write_corrected(struct blocklevel_device *bl, uint32_t dst, cons
/* chip erase may not be supported by all chips/controllers, get ready
* for FLASH_ERR_CHIP_ER_NOT_SUPPORTED
*/
-int flash_erase_chip(struct blocklevel_device *bl);
+int flash_erase_chip(struct flash_chip *c);
#endif /* __LIBFLASH_H */
--
2.5.0
More information about the Skiboot
mailing list