bmp_serial/linux: Honor opt_list_only (-l).

This commit is contained in:
Uwe Bonnes 2021-04-17 15:33:50 +02:00 committed by UweBonnes
parent d6b24c00c8
commit cf5b4afb38
1 changed files with 5 additions and 5 deletions

View File

@ -248,8 +248,8 @@ int find_debuggers(BMP_CL_OPTIONS_t *cl_opts, bmp_info_t *info)
if (found_bmps < 1) {
DEBUG_WARN("No BMP probe found\n");
return -1;
} else if (found_bmps > 1) {
DEBUG_INFO("Available Probes:\n");
} else if ((found_bmps > 1) || cl_opts->opt_list_only) {
DEBUG_WARN("Available Probes:\n");
}
dir = opendir(DEVICE_BY_ID);
i = 0;
@ -261,7 +261,7 @@ int find_debuggers(BMP_CL_OPTIONS_t *cl_opts, bmp_info_t *info)
if (scan_linux_id(dp->d_name, type, version, serial)) {
DEBUG_WARN("Unexpected device name found \"%s\"\n",
dp->d_name);
} else if (found_bmps == 1) {
} else if ((found_bmps == 1) && (!cl_opts->opt_list_only)) {
strncpy(info->serial, serial, sizeof(info->serial));
found_bmps = 1;
strncpy(info->serial, serial, sizeof(info->serial));
@ -269,13 +269,13 @@ int find_debuggers(BMP_CL_OPTIONS_t *cl_opts, bmp_info_t *info)
strncpy(info->product, type, sizeof(info->product));
strncpy(info->version, version, sizeof(info->version));
break;
} else if (found_bmps > 1) {
} else if (found_bmps > 0) {
DEBUG_WARN("%2d: %s, Black Sphere Technologies, Black Magic "
"Probe (%s), %s\n", i, serial, type, version);
}
}
}
closedir(dir);
return (found_bmps == 1) ? 0 : 1;
return (found_bmps == 1 && !cl_opts->opt_list_only) ? 0 : 1;
}
#endif