]> sigrok.org Git - libsigrok.git/blobdiff - hardware/fx2lafw/fx2lafw.c
fx2lafw: use new init/scan API
[libsigrok.git] / hardware / fx2lafw / fx2lafw.c
index 7142a35de7037f9070bc651f0798b1935bf50d76..5bc5e262be173c5b0fc90eef408bd98b63f2ee2b 100644 (file)
 #include "command.h"
 
 static const struct fx2lafw_profile supported_fx2[] = {
-       /*
-        * CWAV USBee DX
-        * XZL Studio DX
-        */
-       { 0x08a9, 0x0015, "CWAV", "USBee DX", NULL,
-               FIRMWARE_DIR "/fx2lafw-cwav-usbeedx.fw",
-               0 },
        /*
         * CWAV USBee AX
         * EE Electronics ESLA201A
@@ -45,6 +38,13 @@ static const struct fx2lafw_profile supported_fx2[] = {
        { 0x08a9, 0x0014, "CWAV", "USBee AX", NULL,
                FIRMWARE_DIR "/fx2lafw-cwav-usbeeax.fw",
                0 },
+       /*
+        * CWAV USBee DX
+        * XZL-Studio DX
+        */
+       { 0x08a9, 0x0015, "CWAV", "USBee DX", NULL,
+               FIRMWARE_DIR "/fx2lafw-cwav-usbeedx.fw",
+               DEV_CAPS_16BIT },
 
        /*
         * CWAV USBee SX
@@ -382,26 +382,33 @@ static struct context *fx2lafw_dev_new(void)
  * API callbacks
  */
 
-static int hw_init(const char *devinfo)
+static int hw_init(void)
 {
-       struct sr_dev_inst *sdi;
+
+       if (libusb_init(&usb_context) != 0) {
+               sr_warn("fx2lafw: Failed to initialize libusb.");
+               return SR_ERR;
+       }
+
+       return SR_OK;
+}
+
+static GSList *hw_scan(GSList *options)
+{
+       GSList *devices;
        struct libusb_device_descriptor des;
+       struct sr_dev_inst *sdi;
        const struct fx2lafw_profile *prof;
        struct context *ctx;
+       struct sr_probe *probe;
        libusb_device **devlist;
-       int ret;
-       int devcnt = 0;
-       int i, j;
+       int devcnt, num_logic_probes, ret, i, j;
 
        /* Avoid compiler warnings. */
-       (void)devinfo;
-
-       if (libusb_init(&usb_context) != 0) {
-               sr_warn("fx2lafw: Failed to initialize libusb.");
-               return 0;
-       }
+       (void)options;
 
        /* Find all fx2lafw compatible devices and upload firmware to them. */
+       devices = NULL;
        libusb_get_device_list(usb_context, &devlist);
        for (i = 0; devlist[i]; i++) {
 
@@ -451,12 +458,10 @@ static int hw_init(const char *devinfo)
                        ctx->usb = sr_usb_dev_inst_new
                                (libusb_get_bus_number(devlist[i]), 0xff, NULL);
                }
-
-               devcnt++;
        }
        libusb_free_device_list(devlist, 1);
 
-       return devcnt;
+       return devices;
 }
 
 static int hw_dev_open(int dev_index)
@@ -1012,6 +1017,7 @@ SR_PRIV struct sr_dev_driver fx2lafw_driver_info = {
        .api_version = 1,
        .init = hw_init,
        .cleanup = hw_cleanup,
+       .scan = hw_scan,
        .dev_open = hw_dev_open,
        .dev_close = hw_dev_close,
        .dev_info_get = hw_dev_info_get,