X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fflash%2Fnor%2Ffespi.c;h=c61b708b1f1be3a9c4de3ef9a508745815d0d26d;hb=0e1fe03f4ba2b313d80c0a2d3c2ecfb7aee85a77;hp=11da818547ea3289c64097e6e12eaf025cad2adb;hpb=35f284fe7c51d29768156cfec172152d2539d98a;p=fw%2Fopenocd diff --git a/src/flash/nor/fespi.c b/src/flash/nor/fespi.c index 11da81854..c61b708b1 100644 --- a/src/flash/nor/fespi.c +++ b/src/flash/nor/fespi.c @@ -1,19 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + /*************************************************************************** * Copyright (C) 2010 by Antonio Borneo * * Modified by Megan Wachs from the original stmsmi.c * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * ***************************************************************************/ /* The Freedom E SPI controller is a SPI bus controller @@ -523,6 +512,12 @@ static int fespi_write(struct flash_bank *bank, const uint8_t *buffer, } } + struct riscv_info *riscv = riscv_info(target); + if (!is_riscv(riscv)) { + LOG_ERROR("Unexpected target type"); + return ERROR_FAIL; + } + unsigned int xlen = riscv_xlen(target); struct working_area *algorithm_wa = NULL; struct working_area *data_wa = NULL; @@ -661,10 +656,8 @@ static int fespi_write(struct flash_bank *bank, const uint8_t *buffer, return ERROR_OK; err: - if (algorithm_wa) { - target_free_working_area(target, data_wa); - target_free_working_area(target, algorithm_wa); - } + target_free_working_area(target, data_wa); + target_free_working_area(target, algorithm_wa); /* Switch to HW mode before return to prompt */ if (fespi_enable_hw_mode(bank) != ERROR_OK)