cl_utils: target selection '-n' argument needs optarg.
foreach now returns the number of targets.
This commit is contained in:
parent
4eb336277c
commit
165560edd8
|
@ -41,7 +41,7 @@ int platform_jtag_scan(const uint8_t *lrlens);
|
|||
int adiv5_swdp_scan(void);
|
||||
int jtag_scan(const uint8_t *lrlens);
|
||||
|
||||
bool target_foreach(void (*cb)(int i, target *t, void *context), void *context);
|
||||
int target_foreach(void (*cb)(int i, target *t, void *context), void *context);
|
||||
void target_list_free(void);
|
||||
|
||||
/* Attach/detach functions */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of the Black Magic Debug project.
|
||||
*
|
||||
* Copyright (C) 2019 - 2020 Uwe Bonnes
|
||||
* Copyright (C) 2019 - 2021 Uwe Bonnes
|
||||
* (bon@elektron.ikp.physik.tu-darmstadt.de)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
@ -168,7 +168,7 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv)
|
|||
opt->opt_flash_size = 16 * 1024 *1024;
|
||||
opt->opt_flash_start = 0xffffffff;
|
||||
opt->opt_max_swj_frequency = 4000000;
|
||||
while((c = getopt(argc, argv, "eEhHv:d:f:s:I:c:CnltVtTa:S:jpP:rR")) != -1) {
|
||||
while((c = getopt(argc, argv, "eEhHv:d:f:s:I:c:Cln:tVtTa:S:jpP:rR")) != -1) {
|
||||
switch(c) {
|
||||
case 'c':
|
||||
if (optarg)
|
||||
|
@ -333,11 +333,11 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
|
|||
DEBUG_WARN("No target found\n");
|
||||
return res;
|
||||
} else {
|
||||
target_foreach(display_target, NULL);
|
||||
num_targets = target_foreach(display_target, &num_targets);
|
||||
}
|
||||
if (opt->opt_target_dev > num_targets) {
|
||||
DEBUG_WARN("Given target nummer %d not available\n",
|
||||
opt->opt_target_dev);
|
||||
DEBUG_WARN("Given target nummer %d not available max %d\n",
|
||||
opt->opt_target_dev, num_targets);
|
||||
return res;
|
||||
}
|
||||
target *t = target_attach_n(opt->opt_target_dev, NULL);
|
||||
|
|
|
@ -69,13 +69,13 @@ target *target_new(void)
|
|||
return t;
|
||||
}
|
||||
|
||||
bool target_foreach(void (*cb)(int, target *t, void *context), void *context)
|
||||
int target_foreach(void (*cb)(int, target *t, void *context), void *context)
|
||||
{
|
||||
int i = 1;
|
||||
target *t = target_list;
|
||||
for (; t; t = t->next, i++)
|
||||
cb(i, t, context);
|
||||
return target_list != NULL;
|
||||
return i;
|
||||
}
|
||||
|
||||
void target_mem_map_free(target *t)
|
||||
|
|
Loading…
Reference in New Issue