aboutsummaryrefslogtreecommitdiff
path: root/src/flash/nor/at91sam4.c
diff options
context:
space:
mode:
authorTomas Vanek <vanekt@fbl.cz>2018-02-15 10:18:37 +0100
committerTomas Vanek <vanekt@fbl.cz>2018-04-10 06:19:01 +0100
commita9fb0d07f07f141f9a1c08c21341b3188b21fbe2 (patch)
treef78e411328fdf310c70c12e633b14f44c2d7fad9 /src/flash/nor/at91sam4.c
parent66d924f787eb60e4f7a7d24c066d96aa68c73a11 (diff)
flash/nor/at91sam: implement flash bank deallocation for SAM series
Microchip (former Atmel) SAM drivers allocate a struct per chip. at91sam3, at91sam34: Deallocate all chip structs from the list at once, on the first bank deallocation. at91samd and at91sam4l drivers do not handle more than one bank. Convert them to simple driver_priv allocation and use default_flash_free_driver_priv(). Change-Id: I49d7200f38a4568c7e12f306c27d1b1b72646736 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4416 Tested-by: jenkins
Diffstat (limited to 'src/flash/nor/at91sam4.c')
-rw-r--r--src/flash/nor/at91sam4.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/flash/nor/at91sam4.c b/src/flash/nor/at91sam4.c
index d101c9b4..04752169 100644
--- a/src/flash/nor/at91sam4.c
+++ b/src/flash/nor/at91sam4.c
@@ -2514,6 +2514,22 @@ FLASH_BANK_COMMAND_HANDLER(sam4_flash_bank_command)
return ERROR_OK;
}
+/**
+ * Remove all chips from the internal list without distingushing which one
+ * is owned by this bank. This simplification works only for one shot
+ * deallocation like current flash_free_all_banks()
+ */
+static void sam4_free_driver_priv(struct flash_bank *bank)
+{
+ struct sam4_chip *chip = all_sam4_chips;
+ while (chip) {
+ struct sam4_chip *next = chip->next;
+ free(chip);
+ chip = next;
+ }
+ all_sam4_chips = NULL;
+}
+
static int sam4_GetDetails(struct sam4_bank_private *pPrivate)
{
const struct sam4_chip_details *pDetails;
@@ -3194,4 +3210,5 @@ struct flash_driver at91sam4_flash = {
.auto_probe = sam4_auto_probe,
.erase_check = default_flash_blank_check,
.protect_check = sam4_protect_check,
+ .free_driver_priv = sam4_free_driver_priv,
};