]> sigrok.org Git - libsigrok.git/commitdiff
usb.c: Moved in usb_match_manuf_product
authorJoel Holdsworth <redacted>
Mon, 12 Jun 2017 17:30:52 +0000 (11:30 -0600)
committerUwe Hermann <redacted>
Mon, 19 Jun 2017 22:18:16 +0000 (00:18 +0200)
src/hardware/fx2lafw/api.c
src/hardware/fx2lafw/protocol.c
src/hardware/fx2lafw/protocol.h
src/libsigrok-internal.h
src/usb.c

index 71aabd9ffa160539fda10136ec2cd5478271db00..58ed64d7eb1324f86356d8d0a3cf48a83507903e 100644 (file)
@@ -412,13 +412,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                        devc->dslogic = TRUE;
                        devc->samplerates = dslogic_samplerates;
                        devc->num_samplerates = ARRAY_SIZE(dslogic_samplerates);
-                       has_firmware = match_manuf_prod(devlist[i], "DreamSourceLab", "DSLogic")
-                                       || match_manuf_prod(devlist[i], "DreamSourceLab", "DSCope");
+                       has_firmware = usb_match_manuf_prod(devlist[i], "DreamSourceLab", "DSLogic")
+                                       || usb_match_manuf_prod(devlist[i], "DreamSourceLab", "DSCope");
                } else {
                        devc->dslogic = FALSE;
                        devc->samplerates = samplerates;
                        devc->num_samplerates = ARRAY_SIZE(samplerates);
-                       has_firmware = match_manuf_prod(devlist[i],
+                       has_firmware = usb_match_manuf_prod(devlist[i],
                                        "sigrok", "fx2lafw");
                }
 
index 7e2df5ad9e0ed9b11ee9c0f586b7a19b9b1bd8fe..6aca18080d63c1f1e2981d88e89969ad2556e1ed 100644 (file)
@@ -141,49 +141,6 @@ SR_PRIV int fx2lafw_command_start_acquisition(const struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-/**
- * Check the USB configuration to determine if this is an fx2lafw device.
- *
- * @return TRUE if the device's configuration profile matches fx2lafw
- *         configuration, FALSE otherwise.
- */
-SR_PRIV gboolean match_manuf_prod(libusb_device *dev, const char *manufacturer,
-               const char *product)
-{
-       struct libusb_device_descriptor des;
-       struct libusb_device_handle *hdl;
-       gboolean ret;
-       unsigned char strdesc[64];
-
-       hdl = NULL;
-       ret = FALSE;
-       while (!ret) {
-               /* Assume the FW has not been loaded, unless proven wrong. */
-               libusb_get_device_descriptor(dev, &des);
-
-               if (libusb_open(dev, &hdl) != 0)
-                       break;
-
-               if (libusb_get_string_descriptor_ascii(hdl,
-                               des.iManufacturer, strdesc, sizeof(strdesc)) < 0)
-                       break;
-               if (strcmp((const char *)strdesc, manufacturer))
-                       break;
-
-               if (libusb_get_string_descriptor_ascii(hdl,
-                               des.iProduct, strdesc, sizeof(strdesc)) < 0)
-                       break;
-               if (strcmp((const char *)strdesc, product))
-                       break;
-
-               ret = TRUE;
-       }
-       if (hdl)
-               libusb_close(hdl);
-
-       return ret;
-}
-
 SR_PRIV int fx2lafw_dev_open(struct sr_dev_inst *sdi, struct sr_dev_driver *di)
 {
        libusb_device **devlist;
index c3d6f32e35245c69593fd48ab6592f7b1616ae6e..6113af8f648ea1e7d0c05e486b0e15e403888e0c 100644 (file)
@@ -145,8 +145,6 @@ struct dev_context {
 };
 
 SR_PRIV int fx2lafw_command_start_acquisition(const struct sr_dev_inst *sdi);
-SR_PRIV gboolean match_manuf_prod(libusb_device *dev, const char *manufacturer,
-               const char *product);
 SR_PRIV int fx2lafw_dev_open(struct sr_dev_inst *sdi, struct sr_dev_driver *di);
 SR_PRIV struct dev_context *fx2lafw_dev_new(void);
 SR_PRIV void fx2lafw_abort_acquisition(struct dev_context *devc);
index 2e041a26aef37edac32f4823ae3e864685085bc4..73e49ef4106b9886cb38ae3401ff2d0ecea14b52 100644 (file)
@@ -1050,6 +1050,8 @@ SR_PRIV int usb_source_add(struct sr_session *session, struct sr_context *ctx,
                int timeout, sr_receive_data_callback cb, void *cb_data);
 SR_PRIV int usb_source_remove(struct sr_session *session, struct sr_context *ctx);
 SR_PRIV int usb_get_port_path(libusb_device *dev, char *path, int path_len);
+SR_PRIV gboolean usb_match_manuf_prod(libusb_device *dev,
+               const char *manufacturer, const char *product);
 #endif
 
 
index f53119a6aab181b08c2faf338777da9db9db0712..c4d5567399de247148e4fd7a289e575686073129 100644 (file)
--- a/src/usb.c
+++ b/src/usb.c
@@ -510,3 +510,47 @@ SR_PRIV int usb_get_port_path(libusb_device *dev, char *path, int path_len)
 
        return SR_OK;
 }
+
+/**
+ * Check the USB configuration to determine if this device has a given 
+ * manufacturer and product string.
+ *
+ * @return TRUE if the device's configuration profile strings
+ *         configuration, FALSE otherwise.
+ */
+SR_PRIV gboolean usb_match_manuf_prod(libusb_device *dev,
+               const char *manufacturer, const char *product)
+{
+       struct libusb_device_descriptor des;
+       struct libusb_device_handle *hdl;
+       gboolean ret;
+       unsigned char strdesc[64];
+
+       hdl = NULL;
+       ret = FALSE;
+       while (!ret) {
+               /* Assume the FW has not been loaded, unless proven wrong. */
+               libusb_get_device_descriptor(dev, &des);
+
+               if (libusb_open(dev, &hdl) != 0)
+                       break;
+
+               if (libusb_get_string_descriptor_ascii(hdl,
+                               des.iManufacturer, strdesc, sizeof(strdesc)) < 0)
+                       break;
+               if (strcmp((const char *)strdesc, manufacturer))
+                       break;
+
+               if (libusb_get_string_descriptor_ascii(hdl,
+                               des.iProduct, strdesc, sizeof(strdesc)) < 0)
+                       break;
+               if (strcmp((const char *)strdesc, product))
+                       break;
+
+               ret = TRUE;
+       }
+       if (hdl)
+               libusb_close(hdl);
+
+       return ret;
+}