Skip to content

Commit 74ae7b1

Browse files
committed
target: drop useless calls target_set_examined()
target_set_examined() or target_reset_examined() is called in both handle_target_examine() and target_examine_one() depending on the result returned from target->type->examine method. Drop target_set_examined() from target specific examine methods unless the following part of examine code is suspected to require the examined state. Update the comment describing target_set_examined() usage. Change-Id: I68c76176f4a34bf21c8f3a2a417bc7cdcaf72e6f Signed-off-by: Tomas Vanek <[email protected]> Reviewed-on: https://review.openocd.org/c/openocd/+/9181 Tested-by: jenkins
1 parent 57c0667 commit 74ae7b1

10 files changed

Lines changed: 4 additions & 17 deletions

File tree

src/target/arc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,6 @@ static int arc_examine(struct target *target)
748748

749749
/* Read BCRs and configure optional registers. */
750750
CHECK_RETVAL(arc_configure(target));
751-
752-
target_set_examined(target);
753751
}
754752

755753
return ERROR_OK;

src/target/arm11.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,8 +1220,6 @@ static int arm11_examine(struct target *target)
12201220
CHECK_RETVAL(etm_setup(target));
12211221
}
12221222

1223-
target_set_examined(target);
1224-
12251223
return ERROR_OK;
12261224
}
12271225

src/target/avr32_ap7k.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,6 @@ static int avr32_ap7k_examine(struct target *target)
527527
struct avr32_ap7k_common *ap7k = target_to_ap7k(target);
528528

529529
if (!target_was_examined(target)) {
530-
target_set_examined(target);
531530
avr32_jtag_nexus_read(&ap7k->jtag, AVR32_OCDREG_DID, &devid);
532531
LOG_INFO("device id: %08" PRIx32, devid);
533532
avr32_ocd_setbits(&ap7k->jtag, AVR32_OCDREG_DC, OCDREG_DC_DBE);

src/target/esirisc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,8 +1679,6 @@ static int esirisc_examine(struct target *target)
16791679
}
16801680
}
16811681

1682-
target_set_examined(target);
1683-
16841682
LOG_TARGET_INFO(target, "%d bit, %d registers, %s%s%s",
16851683
esirisc->num_bits, esirisc->num_regs,
16861684
target_endianness(target),

src/target/mem_ap.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ static int mem_ap_examine(struct target *target)
143143
return ERROR_FAIL;
144144
}
145145
}
146-
target_set_examined(target);
147146
target->state = TARGET_UNKNOWN;
148147
target->debug_reason = DBG_REASON_UNDEFINED;
149148
return mem_ap_init(mem_ap->ap);

src/target/mips32.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,6 @@ int mips32_examine(struct target *target)
734734
struct mips32_common *mips32 = target_to_mips32(target);
735735

736736
if (!target_was_examined(target)) {
737-
target_set_examined(target);
738-
739737
/* we will configure later */
740738
mips32->bp_scanned = 0;
741739
mips32->num_inst_bpoints = 0;

src/target/mips64.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,6 @@ int mips64_examine(struct target *target)
479479
mips64->num_inst_bpoints = 0;
480480
mips64->num_inst_bpoints_avail = 0;
481481

482-
target_set_examined(target);
483-
484482
return ERROR_OK;
485483
}
486484

src/target/stm8.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,8 +1747,6 @@ static int stm8_examine(struct target *target)
17471747
}
17481748
}
17491749

1750-
target_set_examined(target);
1751-
17521750
return ERROR_OK;
17531751
}
17541752

src/target/target.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,6 @@ static inline void target_reset_active_polled(struct target *target)
671671

672672
static int default_examine(struct target *target)
673673
{
674-
target_set_examined(target);
675674
return ERROR_OK;
676675
}
677676

src/target/target.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,10 @@ static inline bool target_active_polled(const struct target *target)
450450
return target->active_polled;
451451
}
452452

453-
/** Sets the @c examined and @c active_polled flags for the given target. */
454-
/** Use in target->type->examine() after one-time setup is done. */
453+
/** Sets the @c examined and @c active_polled flags for the given target.
454+
* Not necessary to call it in target->type->examine() methods,
455+
* the target infrastructure calls it after successful return
456+
* from this method. */
455457
static inline void target_set_examined(struct target *target)
456458
{
457459
target->active_polled = true;

0 commit comments

Comments
 (0)