target/riscv: use struct riscv_info instead of typedef riscv_info_t
[fw/openocd] / src / target / riscv / riscv-011.c
index ae0b6e481b157cceb70fd2fca900a9be11c3d1d9..e2ae5b51a651d7b0069fa5f879c05f9c3addeea7 100644 (file)
@@ -227,10 +227,10 @@ static int get_register(struct target *target, riscv_reg_t *value, int regid);
 
 static riscv011_info_t *get_info(const struct target *target)
 {
-       riscv_info_t *info = (riscv_info_t *) target->arch_info;
+       struct riscv_info *info = target->arch_info;
        assert(info);
        assert(info->version_specific);
-       return (riscv011_info_t *) info->version_specific;
+       return info->version_specific;
 }
 
 static unsigned int slot_offset(const struct target *target, slot_t slot)
@@ -1408,7 +1408,10 @@ static int halt(struct target *target)
 static void deinit_target(struct target *target)
 {
        LOG_DEBUG("riscv_deinit_target()");
-       riscv_info_t *info = (riscv_info_t *) target->arch_info;
+       struct riscv_info *info = target->arch_info;
+       if (!info)
+               return;
+
        free(info->version_specific);
        info->version_specific = NULL;
 }
@@ -1549,7 +1552,7 @@ static int examine(struct target *target)
 
        uint32_t word0 = cache_get32(target, 0);
        uint32_t word1 = cache_get32(target, 1);
-       riscv_info_t *generic_info = (riscv_info_t *) target->arch_info;
+       struct riscv_info *generic_info = riscv_info(target);
        if (word0 == 1 && word1 == 0) {
                generic_info->xlen = 32;
        } else if (word0 == 0xffffffff && word1 == 3) {