@@ -217,6 +217,7 @@ static int hub_phys_count = 0;
217
217
/* default options */
218
218
static char opt_vendor [16 ] = "" ;
219
219
static char opt_search [64 ] = "" ; /* Search by attached device description */
220
+ static char opt_searchhub [64 ] = "" ; /* Search by hub description */
220
221
static char opt_location [32 ] = "" ; /* Hub location a-b.c.d */
221
222
static int opt_level = 0 ; /* Hub location level (e.g., a-b is level 2, a-b.c is level 3)*/
222
223
static int opt_ports = ALL_HUB_PORTS ; /* Bitmask of ports to operate on */
@@ -240,7 +241,7 @@ static int is_rpi_4b = 0;
240
241
static int is_rpi_5 = 0 ;
241
242
242
243
static const char short_options [] =
243
- "l:L:n:a:p:d:r:w:s:hvefRN"
244
+ "l:L:n:a:p:d:r:w:s:H: hvefRN"
244
245
#if defined(__linux__ )
245
246
"S"
246
247
#if (LIBUSB_API_VERSION >= 0x01000107 ) /* 1.0.23 */
@@ -253,6 +254,7 @@ static const struct option long_options[] = {
253
254
{ "location" , required_argument , NULL , 'l' },
254
255
{ "vendor" , required_argument , NULL , 'n' },
255
256
{ "search" , required_argument , NULL , 's' },
257
+ { "searchhub" ,required_argument , NULL , 'H' },
256
258
{ "level" , required_argument , NULL , 'L' },
257
259
{ "ports" , required_argument , NULL , 'p' },
258
260
{ "action" , required_argument , NULL , 'a' },
@@ -288,6 +290,7 @@ static int print_usage(void)
288
290
"--location, -l - limit hub by location [all smart hubs].\n"
289
291
"--level -L - limit hub by location level (e.g. a-b.c is level 3).\n"
290
292
"--vendor, -n - limit hub by vendor id [%s] (partial ok).\n"
293
+ "--searchhub,-H - limit hub by description.\n"
291
294
"--search, -s - limit hub by attached device description.\n"
292
295
"--delay, -d - delay for cycle/flash action [%g sec].\n"
293
296
"--repeat, -r - repeat power off count [%d] (some devices need it to turn off).\n"
@@ -963,6 +966,12 @@ static int usb_find_hubs(void)
963
966
}
964
967
}
965
968
}
969
+ if (strlen (opt_searchhub ) > 0 ) {
970
+ /* Search by hub description */
971
+ if (strstr (info .ds .description , opt_searchhub ) == NULL ) {
972
+ info .actionable = 0 ;
973
+ }
974
+ }
966
975
if (strlen (opt_location ) > 0 ) {
967
976
if (strcasecmp (opt_location , info .location )) {
968
977
info .actionable = 0 ;
@@ -1149,6 +1158,9 @@ int main(int argc, char *argv[])
1149
1158
case 's' :
1150
1159
snprintf (opt_search , sizeof (opt_search ), "%s" , optarg );
1151
1160
break ;
1161
+ case 'H' :
1162
+ snprintf (opt_searchhub , sizeof (opt_searchhub ), "%s" , optarg );
1163
+ break ;
1152
1164
case 'p' :
1153
1165
if (!strcasecmp (optarg , "all" )) { /* all ports is the default */
1154
1166
break ;
0 commit comments