diff duart28/find_usb.c @ 39:b9ecfa54fe2b

fc-duart28-conf: replace find and check-eeprom with single show command The original design with separate find and check-eeprom commands was driven by the assumption that we had to bump off the ftdi_sio driver in order to read the EEPROM, while a USB device tree check could be done non-invasively. However, now that we know that we can read the EEPROM non-invasively too, we can simplify the tool with a single show command.
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 10 Sep 2023 19:21:20 +0000
parents 2413a54a1bfc
children
line wrap: on
line diff
--- a/duart28/find_usb.c	Sun Sep 10 07:30:01 2023 +0000
+++ b/duart28/find_usb.c	Sun Sep 10 19:21:20 2023 +0000
@@ -11,6 +11,8 @@
 #include <usb.h>
 #include "../libuwrap/prelim_init.h"
 
+unsigned usb_presenting_pid;
+
 static void
 get_string(usb_dev_handle *usbh, int index, char *buf, size_t buflen)
 {
@@ -23,19 +25,6 @@
 	}
 }
 
-static void
-report_found_dev(struct usb_device *dev, unsigned usb_pid, char string_letter)
-{
-	printf("Found FreeCalypso DUART28 adapter at bus %s device %s,\n",
-		dev->bus->dirname, dev->filename);
-	if (usb_pid == 0x7152 && string_letter == 'C')
-		printf("presenting as DUART28C\n");
-	else if (usb_pid == 0x6010 && string_letter == 'S')
-		printf("presenting as DUART28S\n");
-	else
-		printf("presenting with inconsistent ID!\n");
-}
-
 static int
 is_match(struct usb_device *dev)
 {
@@ -63,7 +52,9 @@
 		return 0;
 	}
 	usb_close(usbh);
-	report_found_dev(dev, desc->idProduct, strbuf[7]);
+	printf("Found FreeCalypso DUART28 adapter at bus %s device %s\n",
+		dev->bus->dirname, dev->filename);
+	usb_presenting_pid = desc->idProduct;
 	return 1;
 }