- if ((idcode & 1) == 0)
- {
- /* Zero for LSB indicates a device in bypass */
- LOG_INFO("TAP %s does not have IDCODE",
- tap->dotted_name);
- idcode = 0;
- tap->hasidcode = false;
-
- bit_count += 1;
- }
- else
- {
- /* Friendly devices support IDCODE */
- tap->hasidcode = true;
- jtag_examine_chain_display(LOG_LVL_INFO,
- "tap/device found",
- tap->dotted_name, idcode);
-
- bit_count += 32;
- }
- tap->idcode = idcode;
-
- /* ensure the TAP ID matches what was expected */
- if (!jtag_examine_chain_match_tap(tap))
- retval = ERROR_JTAG_INIT_SOFT_FAIL;
- }
-
- /* Fail if too many TAPs were enabled for us to verify them all. */
- if (tap) {
- LOG_ERROR("Too many TAPs enabled; '%s' ignored.",
- tap->dotted_name);
- return ERROR_JTAG_INIT_FAILED;
- }
-
- /* if autoprobing, the tap list is still empty ... populate it! */
- while (autoprobe && bit_count < (JTAG_MAX_CHAIN_SIZE * 32) - 31) {
- uint32_t idcode;
- char buf[12];
-
- /* Is there another TAP? */
- idcode = buf_get_u32(idcode_buffer, bit_count, 32);
- if (jtag_idcode_is_final(idcode))
- break;
-
- /* Default everything in this TAP except IR length.
- *
- * REVISIT create a jtag_alloc(chip, tap) routine, and
- * share it with jim_newtap_cmd().
- */
- tap = calloc(1, sizeof *tap);
- if (!tap)
- return ERROR_FAIL;
+ /* No predefined TAP? Auto-probe. */
+ if (tap == NULL) {
+ /* Is there another TAP? */
+ if (jtag_idcode_is_final(idcode))
+ break;
+
+ /* Default everything in this TAP except IR length.
+ *
+ * REVISIT create a jtag_alloc(chip, tap) routine, and
+ * share it with jim_newtap_cmd().
+ */
+ tap = calloc(1, sizeof *tap);
+ if (!tap) {
+ retval = ERROR_FAIL;
+ goto out;
+ }