adiv5: Fix the invalid AP handling loop so that we don't stop early and bail out before time.

This improves target detection reliability.
This commit is contained in:
dragonmux 2022-07-26 05:26:31 +01:00 committed by Piotr Esden-Tempski
parent 1ea9641ada
commit 733d8ddc19
1 changed files with 4 additions and 6 deletions

View File

@ -772,9 +772,9 @@ void adiv5_dp_init(ADIv5_DP_t *dp)
/* Probe for APs on this DP */ /* Probe for APs on this DP */
uint32_t last_base = 0; uint32_t last_base = 0;
int void_aps = 0; size_t void_aps = 0;
dp->refcnt++; dp->refcnt++;
for (int i = 0; (i < 256) && (void_aps < 8); i++) { for (size_t i = 0; i < 256 && void_aps < 8; ++i) {
ADIv5_AP_t *ap = NULL; ADIv5_AP_t *ap = NULL;
#if PC_HOSTED == 1 #if PC_HOSTED == 1
if ((!dp->ap_setup) || dp->ap_setup(i)) if ((!dp->ap_setup) || dp->ap_setup(i))
@ -783,17 +783,15 @@ void adiv5_dp_init(ADIv5_DP_t *dp)
ap = adiv5_new_ap(dp, i); ap = adiv5_new_ap(dp, i);
#endif #endif
if (ap == NULL) { if (ap == NULL) {
void_aps++;
#if PC_HOSTED == 1 #if PC_HOSTED == 1
if (dp->ap_cleanup) if (dp->ap_cleanup)
dp->ap_cleanup(i); dp->ap_cleanup(i);
#endif #endif
if (i == 0) { if (++void_aps == 8) {
adiv5_dp_unref(dp); adiv5_dp_unref(dp);
return; return;
} else {
continue;
} }
continue;
} }
if (ap->base == last_base) { if (ap->base == last_base) {
DEBUG_WARN("AP %d: Duplicate base\n", i); DEBUG_WARN("AP %d: Duplicate base\n", i);