diff cp2102/find_dev.c @ 98:1cacc1ae56f0

cp2102 tools: convert to -d option for non-default device
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 28 Sep 2023 04:45:13 +0000
parents 8d35346f1d46
children
line wrap: on
line diff
--- a/cp2102/find_dev.c	Thu Sep 28 03:26:11 2023 +0000
+++ b/cp2102/find_dev.c	Thu Sep 28 04:45:13 2023 +0000
@@ -22,20 +22,20 @@
 {
 	struct usb_device *dev;
 
-	if (!strcmp(devsel_arg, "default")) {
+	if (devsel_arg) {
+		dev = find_usbdev_by_desc_string(devsel_arg);
+		if (!dev) {
+			fprintf(stderr,
+				"error: specified USB device not found\n");
+			exit(1);
+		}
+	} else {
 		dev = find_usbdev_by_matchspec(&default_id);
 		if (!dev) {
 			fprintf(stderr,
 				"error: no default-ID CP2102 device found\n");
 			exit(1);
 		}
-	} else {
-		dev = find_usbdev_by_desc_string(devsel_arg);
-		if (!dev) {
-			fprintf(stderr,
-				"error: specified USB device not found\n");
-			exit(1);
-		}
 	}
 	return dev;
 }