From 89ec9eb94a0bf4605e73bc3dd1d8588005b7ec4d Mon Sep 17 00:00:00 2001 From: Cyril Bur Date: Thu, 4 Jun 2015 10:36:03 +1000 Subject: libflash: Add checking at blocklevel for erase block aligned erase lengths Currently blocklevel_erase() will let any erase of any size get passed down to the backend. Not strictly a problem since libflash does do this check as well, however, not all future backends will. This is very much a sanity check to save from a likely mistake. Signed-off-by: Cyril Bur Signed-off-by: Stewart Smith --- libflash/blocklevel.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libflash/blocklevel.h') diff --git a/libflash/blocklevel.h b/libflash/blocklevel.h index 2e8480d4..a22ecb4a 100644 --- a/libflash/blocklevel.h +++ b/libflash/blocklevel.h @@ -29,6 +29,11 @@ struct blocklevel_device { int (*erase)(struct blocklevel_device *bl, uint32_t pos, uint32_t len); int (*get_info)(struct blocklevel_device *bl, const char **name, uint32_t *total_size, uint32_t *erase_granule); + + /* + * Keep the erase mask so that blocklevel_erase() can do sanity checking + */ + uint32_t erase_mask; }; int blocklevel_read(struct blocklevel_device *bl, uint32_t pos, void *buf, uint32_t len); -- cgit v1.2.1