+// SPDX-License-Identifier: GPL-2.0-or-later
+
/***************************************************************************
* Copyright (C) 2005, 2007 by Dominic Rath *
* Dominic.Rath@gmx.de *
* michael@schwingen.org *
* Copyright (C) 2010 Øyvind Harboe <oyvind.harboe@zylin.com> *
* Copyright (C) 2010 by Antonio Borneo <borneo.antonio@gmail.com> *
- * *
- * 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 <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
free(cfi_info->pri_ext);
pri_ext = malloc(sizeof(struct cfi_intel_pri_ext));
- if (pri_ext == NULL) {
+ if (!pri_ext) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
free(cfi_info->pri_ext);
pri_ext = malloc(sizeof(struct cfi_spansion_pri_ext));
- if (pri_ext == NULL) {
+ if (!pri_ext) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
free(cfi_info->pri_ext);
pri_ext = malloc(sizeof(struct cfi_spansion_pri_ext));
- if (pri_ext == NULL) {
+ if (!pri_ext) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
}
cfi_info = calloc(1, sizeof(struct cfi_flash_bank));
- if (cfi_info == NULL) {
+ if (!cfi_info) {
LOG_ERROR("No memory for flash bank info");
return ERROR_FAIL;
}
if (retval != ERROR_OK)
return retval;
- if (status == 0x80)
- bank->sectors[i].is_erased = 1;
- else {
+ if (status != 0x80) {
retval = cfi_send_command(bank, 0xff, cfi_flash_address(bank, 0, 0x0));
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
- if (cfi_spansion_wait_status_busy(bank, cfi_info->block_erase_timeout) == ERROR_OK)
- bank->sectors[i].is_erased = 1;
- else {
+ if (cfi_spansion_wait_status_busy(bank, cfi_info->block_erase_timeout) != ERROR_OK) {
retval = cfi_send_command(bank, 0xf0, cfi_flash_address(bank, 0, 0x0));
if (retval != ERROR_OK)
return retval;
/* free up resources */
cleanup:
- if (source)
- target_free_working_area(target, source);
-
+ target_free_working_area(target, source);
target_free_working_area(target, write_algorithm);
destroy_reg_param(®_params[0]);
/* convert bus-width dependent algorithm code to correct endianness */
target_code = malloc(target_code_size);
- if (target_code == NULL) {
+ if (!target_code) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
/* convert bus-width dependent algorithm code to correct endianness */
target_code = malloc(target_code_size);
- if (target_code == NULL) {
+ if (!target_code) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}