aboutsummaryrefslogtreecommitdiff
path: root/libflash
diff options
context:
space:
mode:
Diffstat (limited to 'libflash')
-rw-r--r--libflash/libflash.c6
-rw-r--r--libflash/libflash.h3
-rw-r--r--libflash/test/test-flash.c2
3 files changed, 8 insertions, 3 deletions
diff --git a/libflash/libflash.c b/libflash/libflash.c
index 90ae653..831bdd4 100644
--- a/libflash/libflash.c
+++ b/libflash/libflash.c
@@ -798,7 +798,8 @@ static int flash_get_info(struct blocklevel_device *bl, const char **name,
return 0;
}
-int flash_init(struct spi_flash_ctrl *ctrl, struct blocklevel_device **bl)
+int flash_init(struct spi_flash_ctrl *ctrl, struct blocklevel_device **bl,
+ struct flash_chip **flash_chip)
{
struct flash_chip *c;
int rc;
@@ -842,6 +843,9 @@ bail:
c->bl.flags = WRITE_NEED_ERASE;
*bl = &(c->bl);
+ if (flash_chip)
+ *flash_chip = c;
+
return 0;
}
diff --git a/libflash/libflash.h b/libflash/libflash.h
index f3973ab..fa5143a 100644
--- a/libflash/libflash.h
+++ b/libflash/libflash.h
@@ -45,7 +45,8 @@ extern bool libflash_debug;
struct flash_chip;
struct spi_flash_ctrl;
-int flash_init(struct spi_flash_ctrl *ctrl, struct blocklevel_device **bl);
+int flash_init(struct spi_flash_ctrl *ctrl, struct blocklevel_device **bl,
+ struct flash_chip **flash_chip);
void flash_exit(struct blocklevel_device *bl);
/* libflash sets the 4b mode automatically based on the flash
diff --git a/libflash/test/test-flash.c b/libflash/test/test-flash.c
index cf2b3a5..c93aef5 100644
--- a/libflash/test/test-flash.c
+++ b/libflash/test/test-flash.c
@@ -378,7 +378,7 @@ int main(void)
memset(sim_image, 0xff, sim_image_sz);
test = malloc(0x10000 * 2);
- rc = flash_init(&sim_ctrl, &bl);
+ rc = flash_init(&sim_ctrl, &bl, NULL);
if (rc) {
ERR("flash_init failed with err %d\n", rc);
exit(1);