flash/nor/stm32f1x: unify flash error reporting
[fw/openocd] / src / target / arm_cti.c
index ee9d8aafd40e920682d2a1e5384067ef4533d57f..c776e9c2a5c35e967b87e494e4c8f74321eef8db 100644 (file)
@@ -70,7 +70,7 @@ static int arm_cti_mod_reg_bits(struct arm_cti *self, unsigned int reg, uint32_t
 
        /* Read register */
        int retval = mem_ap_read_atomic_u32(ap, self->spot.base + reg, &tmp);
-       if (ERROR_OK != retval)
+       if (retval != ERROR_OK)
                return retval;
 
        /* clear bitfield */
@@ -143,7 +143,7 @@ int arm_cti_read_reg(struct arm_cti *self, unsigned int reg, uint32_t *p_value)
 {
        struct adiv5_ap *ap = dap_ap(self->spot.dap, self->spot.ap_num);
 
-       if (p_value == NULL)
+       if (!p_value)
                return ERROR_COMMAND_ARGUMENT_INVALID;
 
        return mem_ap_read_atomic_u32(ap, self->spot.base + reg, p_value);
@@ -430,7 +430,7 @@ static const struct command_registration cti_instance_command_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-static int cti_configure(Jim_GetOptInfo *goi, struct arm_cti *cti)
+static int cti_configure(struct jim_getopt_info *goi, struct arm_cti *cti)
 {
        /* parse config or cget options ... */
        while (goi->argc > 0) {
@@ -446,7 +446,7 @@ static int cti_configure(Jim_GetOptInfo *goi, struct arm_cti *cti)
 
        return JIM_OK;
 }
-static int cti_create(Jim_GetOptInfo *goi)
+static int cti_create(struct jim_getopt_info *goi)
 {
        struct command_context *cmd_ctx;
        static struct arm_cti *cti;
@@ -456,16 +456,16 @@ static int cti_create(Jim_GetOptInfo *goi)
        int e;
 
        cmd_ctx = current_command_context(goi->interp);
-       assert(cmd_ctx != NULL);
+       assert(cmd_ctx);
 
        if (goi->argc < 3) {
                Jim_WrongNumArgs(goi->interp, 1, goi->argv, "?name? ..options...");
                return JIM_ERR;
        }
        /* COMMAND */
-       Jim_GetOpt_Obj(goi, &new_cmd);
+       jim_getopt_obj(goi, &new_cmd);
        /* does this command exist? */
-       cmd = Jim_GetCommand(goi->interp, new_cmd, JIM_ERRMSG);
+       cmd = Jim_GetCommand(goi->interp, new_cmd, JIM_NONE);
        if (cmd) {
                cp = Jim_GetString(new_cmd, NULL);
                Jim_SetResultFormatted(goi->interp, "Command: %s Exists", cp);
@@ -474,7 +474,7 @@ static int cti_create(Jim_GetOptInfo *goi)
 
        /* Create it */
        cti = calloc(1, sizeof(*cti));
-       if (cti == NULL)
+       if (!cti)
                return JIM_ERR;
 
        adiv5_mem_ap_spot_init(&cti->spot);
@@ -508,7 +508,7 @@ static int cti_create(Jim_GetOptInfo *goi)
                COMMAND_REGISTRATION_DONE
        };
        e = register_commands_with_data(cmd_ctx, NULL, cti_commands, cti);
-       if (ERROR_OK != e)
+       if (e != ERROR_OK)
                return JIM_ERR;
 
        list_add_tail(&cti->lh, &all_cti);
@@ -518,8 +518,8 @@ static int cti_create(Jim_GetOptInfo *goi)
 
 static int jim_cti_create(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 {
-       Jim_GetOptInfo goi;
-       Jim_GetOpt_Setup(&goi, interp, argc - 1, argv + 1);
+       struct jim_getopt_info goi;
+       jim_getopt_setup(&goi, interp, argc - 1, argv + 1);
        if (goi.argc < 2) {
                Jim_WrongNumArgs(goi.interp, goi.argc, goi.argv,
                        "<name> [<cti_options> ...]");