summaryrefslogtreecommitdiffstats
path: root/libflash/blocklevel.c
diff options
context:
space:
mode:
Diffstat (limited to 'libflash/blocklevel.c')
-rw-r--r--libflash/blocklevel.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libflash/blocklevel.c b/libflash/blocklevel.c
index 35b8c8a3..320ffacc 100644
--- a/libflash/blocklevel.c
+++ b/libflash/blocklevel.c
@@ -15,6 +15,9 @@
*/
#include <unistd.h>
+#include <stdio.h>
+
+#include <libflash/libflash.h>
#include "blocklevel.h"
int blocklevel_read(struct blocklevel_device *bl, uint32_t pos, void *buf, uint32_t len)
@@ -38,6 +41,13 @@ int blocklevel_erase(struct blocklevel_device *bl, uint32_t pos, uint32_t len)
if (!bl || !bl->erase)
return -1;
+ /* Programmer may be making a horrible mistake without knowing it */
+ if (len & bl->erase_mask) {
+ fprintf(stderr, "blocklevel_erase: len (0x%08x) is not erase block (0x%08x) aligned\n",
+ len, bl->erase_mask + 1);
+ return FLASH_ERR_ERASE_BOUNDARY;
+ }
+
return bl->erase(bl, pos, len);
}
OpenPOWER on IntegriCloud