openocd: fix Yoda conditions with checkpatch
[fw/openocd] / src / target / nds32_v3_common.c
index 6dc20982d19bc607c38479df285c86072514a722..b0c3de622fb80a6ba7b30ed9dcc317aca71aacd8 100644 (file)
@@ -13,9 +13,7 @@
  *   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, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -95,7 +93,7 @@ static int nds32_v3_debug_entry(struct nds32 *nds32, bool enable_watchpoint)
                }
        }
 
-       if (ERROR_OK != nds32_examine_debug_reason(nds32)) {
+       if (nds32_examine_debug_reason(nds32) != ERROR_OK) {
                nds32->target->state = backup_state;
 
                /* re-activate all hardware breakpoints & watchpoints */
@@ -270,8 +268,8 @@ static int nds32_v3_get_exception_address(struct nds32 *nds32,
 
                nds32_get_mapped_reg(nds32, PC, &val_pc);
 
-               if ((NDS32_DEBUG_DATA_ADDR_WATCHPOINT_NEXT_PRECISE == reason) ||
-                               (NDS32_DEBUG_DATA_VALUE_WATCHPOINT_NEXT_PRECISE == reason)) {
+               if ((reason == NDS32_DEBUG_DATA_ADDR_WATCHPOINT_NEXT_PRECISE) ||
+                               (reason == NDS32_DEBUG_DATA_VALUE_WATCHPOINT_NEXT_PRECISE)) {
                        if (edmsw & 0x4) /* check EDMSW.IS_16BIT */
                                val_pc -= 2;
                        else
@@ -322,7 +320,7 @@ static int nds32_v3_get_exception_address(struct nds32 *nds32,
                        return ERROR_FAIL;
        } else if (match_count == 0) {
                /* global stop is precise exception */
-               if ((NDS32_DEBUG_LOAD_STORE_GLOBAL_STOP == reason) && nds32->global_stop) {
+               if ((reason == NDS32_DEBUG_LOAD_STORE_GLOBAL_STOP) && nds32->global_stop) {
                        /* parse instruction to get correct access address */
                        uint32_t val_pc;
                        uint32_t opcode;
@@ -370,7 +368,7 @@ int nds32_v3_target_request_data(struct target *target,
 }
 
 int nds32_v3_checksum_memory(struct target *target,
-               uint32_t address, uint32_t count, uint32_t *checksum)
+               target_addr_t address, uint32_t count, uint32_t *checksum)
 {
        LOG_WARNING("Not implemented: %s", __func__);
 
@@ -436,8 +434,8 @@ int nds32_v3_run_algorithm(struct target *target,
                struct mem_param *mem_params,
                int num_reg_params,
                struct reg_param *reg_params,
-               uint32_t entry_point,
-               uint32_t exit_point,
+               target_addr_t entry_point,
+               target_addr_t exit_point,
                int timeout_ms,
                void *arch_info)
 {
@@ -446,19 +444,19 @@ int nds32_v3_run_algorithm(struct target *target,
        return ERROR_FAIL;
 }
 
-int nds32_v3_read_buffer(struct target *target, uint32_t address,
+int nds32_v3_read_buffer(struct target *target, target_addr_t address,
                uint32_t size, uint8_t *buffer)
 {
        struct nds32 *nds32 = target_to_nds32(target);
        struct nds32_memory *memory = &(nds32->memory);
 
-       if ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
+       if ((memory->access_channel == NDS_MEMORY_ACC_CPU) &&
                        (target->state != TARGET_HALTED)) {
                LOG_WARNING("target was not halted");
                return ERROR_TARGET_NOT_HALTED;
        }
 
-       uint32_t physical_address;
+       target_addr_t physical_address;
        /* BUG: If access range crosses multiple pages, the translation will not correct
         * for second page or so. */
 
@@ -476,7 +474,7 @@ int nds32_v3_read_buffer(struct target *target, uint32_t address,
         * Because hardware will turn off IT/DT by default, it MUST translate virtual address
         * to physical address.
         */
-       if (ERROR_OK == target->type->virt2phys(target, address, &physical_address))
+       if (target->type->virt2phys(target, address, &physical_address) == ERROR_OK)
                address = physical_address;
        else
                return ERROR_FAIL;
@@ -504,19 +502,19 @@ int nds32_v3_read_buffer(struct target *target, uint32_t address,
        return result;
 }
 
-int nds32_v3_write_buffer(struct target *target, uint32_t address,
+int nds32_v3_write_buffer(struct target *target, target_addr_t address,
                uint32_t size, const uint8_t *buffer)
 {
        struct nds32 *nds32 = target_to_nds32(target);
        struct nds32_memory *memory = &(nds32->memory);
 
-       if ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
+       if ((memory->access_channel == NDS_MEMORY_ACC_CPU) &&
                        (target->state != TARGET_HALTED)) {
                LOG_WARNING("target was not halted");
                return ERROR_TARGET_NOT_HALTED;
        }
 
-       uint32_t physical_address;
+       target_addr_t physical_address;
        /* BUG: If access range crosses multiple pages, the translation will not correct
         * for second page or so. */
 
@@ -534,7 +532,7 @@ int nds32_v3_write_buffer(struct target *target, uint32_t address,
         * Because hardware will turn off IT/DT by default, it MUST translate virtual address
         * to physical address.
         */
-       if (ERROR_OK == target->type->virt2phys(target, address, &physical_address))
+       if (target->type->virt2phys(target, address, &physical_address) == ERROR_OK)
                address = physical_address;
        else
                return ERROR_FAIL;
@@ -555,7 +553,7 @@ int nds32_v3_write_buffer(struct target *target, uint32_t address,
                int result;
                result = nds32_gdb_fileio_write_memory(nds32, address, size, buffer);
 
-               if (NDS_MEMORY_ACC_CPU == origin_access_channel) {
+               if (origin_access_channel == NDS_MEMORY_ACC_CPU) {
                        memory->access_channel = NDS_MEMORY_ACC_CPU;
                        aice_memory_access(aice, NDS_MEMORY_ACC_CPU);
                }
@@ -566,19 +564,19 @@ int nds32_v3_write_buffer(struct target *target, uint32_t address,
        return nds32_write_buffer(target, address, size, buffer);
 }
 
-int nds32_v3_read_memory(struct target *target, uint32_t address,
+int nds32_v3_read_memory(struct target *target, target_addr_t address,
                uint32_t size, uint32_t count, uint8_t *buffer)
 {
        struct nds32 *nds32 = target_to_nds32(target);
        struct nds32_memory *memory = &(nds32->memory);
 
-       if ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
+       if ((memory->access_channel == NDS_MEMORY_ACC_CPU) &&
                        (target->state != TARGET_HALTED)) {
                LOG_WARNING("target was not halted");
                return ERROR_TARGET_NOT_HALTED;
        }
 
-       uint32_t physical_address;
+       target_addr_t physical_address;
        /* BUG: If access range crosses multiple pages, the translation will not correct
         * for second page or so. */
 
@@ -596,7 +594,7 @@ int nds32_v3_read_memory(struct target *target, uint32_t address,
         * Because hardware will turn off IT/DT by default, it MUST translate virtual address
         * to physical address.
         */
-       if (ERROR_OK == target->type->virt2phys(target, address, &physical_address))
+       if (target->type->virt2phys(target, address, &physical_address) == ERROR_OK)
                address = physical_address;
        else
                return ERROR_FAIL;
@@ -624,19 +622,19 @@ int nds32_v3_read_memory(struct target *target, uint32_t address,
        return result;
 }
 
-int nds32_v3_write_memory(struct target *target, uint32_t address,
+int nds32_v3_write_memory(struct target *target, target_addr_t address,
                uint32_t size, uint32_t count, const uint8_t *buffer)
 {
        struct nds32 *nds32 = target_to_nds32(target);
        struct nds32_memory *memory = &(nds32->memory);
 
-       if ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
+       if ((memory->access_channel == NDS_MEMORY_ACC_CPU) &&
                        (target->state != TARGET_HALTED)) {
                LOG_WARNING("target was not halted");
                return ERROR_TARGET_NOT_HALTED;
        }
 
-       uint32_t physical_address;
+       target_addr_t physical_address;
        /* BUG: If access range crosses multiple pages, the translation will not correct
         * for second page or so. */
 
@@ -654,7 +652,7 @@ int nds32_v3_write_memory(struct target *target, uint32_t address,
         * Because hardware will turn off IT/DT by default, it MUST translate virtual address
         * to physical address.
         */
-       if (ERROR_OK == target->type->virt2phys(target, address, &physical_address))
+       if (target->type->virt2phys(target, address, &physical_address) == ERROR_OK)
                address = physical_address;
        else
                return ERROR_FAIL;