]> sigrok.org Git - libsigrok.git/commitdiff
Change sr_dev_inst_new() to take no parameters.
authorUwe Hermann <redacted>
Wed, 12 Nov 2014 01:06:15 +0000 (02:06 +0100)
committerUwe Hermann <redacted>
Wed, 12 Nov 2014 16:18:46 +0000 (17:18 +0100)
Change all callers to set the fields manually as needed.

51 files changed:
src/device.c
src/hardware/agilent-dmm/api.c
src/hardware/appa-55ii/api.c
src/hardware/asix-sigma/asix-sigma.c
src/hardware/atten-pps3xxx/api.c
src/hardware/beaglelogic/api.c
src/hardware/brymen-bm86x/api.c
src/hardware/brymen-dmm/api.c
src/hardware/cem-dt-885x/api.c
src/hardware/center-3xx/api.c
src/hardware/chronovu-la/api.c
src/hardware/colead-slm/api.c
src/hardware/conrad-digi-35-cpu/api.c
src/hardware/demo/demo.c
src/hardware/fluke-dmm/api.c
src/hardware/fx2lafw/api.c
src/hardware/gmc-mh-1x-2x/api.c
src/hardware/hameg-hmo/api.c
src/hardware/hantek-dso/api.c
src/hardware/ikalogic-scanalogic2/api.c
src/hardware/ikalogic-scanaplus/api.c
src/hardware/kecheng-kc-330b/api.c
src/hardware/lascar-el-usb/protocol.c
src/hardware/manson-hcs-3xxx/api.c
src/hardware/mic-985xx/api.c
src/hardware/motech-lps-30x/api.c
src/hardware/norma-dmm/api.c
src/hardware/openbench-logic-sniffer/api.c
src/hardware/openbench-logic-sniffer/protocol.c
src/hardware/pipistrello-ols/protocol.c
src/hardware/rigol-ds/api.c
src/hardware/saleae-logic16/api.c
src/hardware/scpi-pps/api.c
src/hardware/serial-dmm/api.c
src/hardware/sysclk-lwla/api.c
src/hardware/teleinfo/api.c
src/hardware/testo/api.c
src/hardware/tondaj-sl-814/api.c
src/hardware/uni-t-dmm/api.c
src/hardware/uni-t-ut32x/api.c
src/hardware/victor-dmm/api.c
src/hardware/yokogawa-dlm/api.c
src/hardware/zeroplus-logic-cube/api.c
src/input/binary.c
src/input/chronovu_la8.c
src/input/csv.c
src/input/vcd.c
src/input/wav.c
src/lcr/es51919.c
src/libsigrok-internal.h
src/session_file.c

index fb40182c13b6404a773fe0814520fe0092f64823..a45bd9826e4dd01820c0c0e6760a9978bf96b369 100644 (file)
@@ -203,32 +203,22 @@ SR_API gboolean sr_dev_has_option(const struct sr_dev_inst *sdi, int key)
 
 /** @private
  *  Allocate and init a new device instance struct.
- *  @param[in]  index   @copydoc sr_dev_inst::index
- *  @param[in]  status  @copydoc sr_dev_inst::status
- *  @param[in]  vendor  @copydoc sr_dev_inst::vendor
- *  @param[in]  model   @copydoc sr_dev_inst::model
- *  @param[in]  version @copydoc sr_dev_inst::version
  *
- *  @retval NULL Error
  *  @retval struct sr_dev_inst *. Dynamically allocated, free using
  *              sr_dev_inst_free().
  */
-SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int status,
-               const char *vendor, const char *model, const char *version)
+SR_PRIV struct sr_dev_inst *sr_dev_inst_new(void)
 {
        struct sr_dev_inst *sdi;
 
-       if (!(sdi = g_try_malloc(sizeof(struct sr_dev_inst)))) {
-               sr_err("Device instance malloc failed.");
-               return NULL;
-       }
+       sdi = g_malloc0(sizeof(struct sr_dev_inst));
 
        sdi->driver = NULL;
-       sdi->status = status;
+       sdi->status = -1;
        sdi->inst_type = -1;
-       sdi->vendor = vendor ? g_strdup(vendor) : NULL;
-       sdi->model = model ? g_strdup(model) : NULL;
-       sdi->version = version ? g_strdup(version) : NULL;
+       sdi->vendor = NULL;
+       sdi->model = NULL;
+       sdi->version = NULL;
        sdi->serial_num = NULL;
        sdi->connection_id = NULL;
        sdi->channels = NULL;
@@ -248,10 +238,10 @@ SR_API struct sr_dev_inst *sr_dev_inst_user_new(const char *vendor,
 {
        struct sr_dev_inst *sdi;
 
-       sdi = sr_dev_inst_new(0, vendor, model, version);
-       if (!sdi)
-               return NULL;
-
+       sdi = sr_dev_inst_new();
+       sdi->vendor = g_strdup(vendor);
+       sdi->model = g_strdup(model);
+       sdi->version = g_strdup(version);
        sdi->inst_type = SR_INST_USER;
 
        return sdi;
index 084f9b4d89171699c3f87cbd8d3785fb43e8a796..9dcbd230761042590eba8c117fda520693a4a416 100644 (file)
@@ -136,9 +136,11 @@ static GSList *scan(GSList *options)
                for (i = 0; supported_agdmm[i].model; i++) {
                        if (strcmp(supported_agdmm[i].modelname, tokens[1]))
                                continue;
-                       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, "Agilent",
-                                       tokens[1], tokens[3])))
-                               return NULL;
+                       sdi = sr_dev_inst_new();
+                       sdi->status = SR_ST_INACTIVE;
+                       sdi->vendor = g_strdup("Agilent");
+                       sdi->model = g_strdup(tokens[1]);
+                       sdi->version = g_strdup(tokens[3]);
                        if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
                                sr_err("Device context malloc failed.");
                                return NULL;
index ab3ad7906575142f6da3da2bc6cd8fcb7b71a392..01c5f5ba5ad1d623383fcb634822a3d5c86aabca 100644 (file)
@@ -96,8 +96,10 @@ static GSList *scan(GSList *options)
 
        sr_info("Found device on port %s.", conn);
 
-       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, "APPA", "55II", NULL)))
-               goto scan_cleanup;
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INACTIVE;
+       sdi->vendor = g_strdup("APPA");
+       sdi->model = g_strdup("55II");
 
        if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
                sr_err("Device context malloc failed.");
index 3a15b2817531742ad590d9627ebb51f176e46e6a..24c786da0d65b9f420934d70831ea1c6477b5e7d 100644 (file)
@@ -380,11 +380,10 @@ static GSList *scan(GSList *options)
        devc->use_triggers = 0;
 
        /* Register SIGMA device. */
-       if (!(sdi = sr_dev_inst_new(SR_ST_INITIALIZING, USB_VENDOR_NAME,
-                                   USB_MODEL_NAME, NULL))) {
-               sr_err("%s: sdi was NULL", __func__);
-               goto free;
-       }
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INITIALIZING;
+       sdi->vendor = g_strdup(USB_VENDOR_NAME);
+       sdi->model = g_strdup(USB_MODEL_NAME);
        sdi->driver = di;
 
        for (i = 0; i < ARRAY_SIZE(channel_names); i++) {
index f29377e34617da5cfb22cdce0fc190e4ea959aa6..2a3ac8f5701210a345a3907fc9367c3d1699c4c5 100644 (file)
@@ -164,7 +164,10 @@ static GSList *scan(GSList *options, int modelid)
                return NULL;
        }
 
-       sdi = sr_dev_inst_new(SR_ST_INACTIVE, "Atten", model->name, NULL);
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INACTIVE;
+       sdi->vendor = g_strdup("Atten");
+       sdi->model = g_strdup(model->name);
        sdi->driver = di;
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
index 9abbbefc972e059b0aeaed04e13518182c789392..910bb843b5919addb45d8bed5704a1f60b8d90d9 100644 (file)
@@ -97,7 +97,10 @@ static GSList *scan(GSList *options)
        if (!g_file_test(BEAGLELOGIC_DEV_NODE, G_FILE_TEST_EXISTS))
                return NULL;
 
-       sdi = sr_dev_inst_new(SR_ST_INACTIVE, NULL, "BeagleLogic", "1.0");
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INACTIVE;
+       sdi->model = g_strdup("BeagleLogic");
+       sdi->version = g_strdup("1.0");
        sdi->driver = di;
 
        /* Unless explicitly specified, keep max channels to 8 only */
index f22535419fffdc8378c9bda879a2e0f290ada147..c38665c1d8c678aa56da697447cec60fed525860 100644 (file)
@@ -73,11 +73,10 @@ static GSList *scan(GSList *options)
        for (l = usb_devices; l; l = l->next) {
                usb = l->data;
 
-               if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE,
-                                           "Brymen", "BM869", NULL))) {
-                       sr_err("sr_dev_inst_new returned NULL.");
-                       return NULL;
-               }
+               sdi = sr_dev_inst_new();
+               sdi->status = SR_ST_INACTIVE;
+               sdi->vendor = g_strdup("Brymen");
+               sdi->model = g_strdup("BM869");
 
                if (!(devc = g_try_malloc0(sizeof(*devc)))) {
                        sr_err("Device context malloc failed.");
index 0a10956b989a90b99a1f659d59c3c70bdb772f5e..210d7e617f21e6f16ce36c05417dae3e66696a4a 100644 (file)
@@ -75,8 +75,10 @@ static GSList *brymen_scan(const char *conn, const char *serialcomm)
 
        sr_info("Found device on port %s.", conn);
 
-       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, "Brymen", "BM85x", NULL)))
-               goto scan_cleanup;
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INACTIVE;
+       sdi->vendor = g_strdup("Brymen");
+       sdi->model = g_strdup("BM85x");
 
        if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
                sr_err("Device context malloc failed.");
index 4cd0ccb6e745986ab9f82b323a64086be708e0f9..252946e330fcf3b075673f5c80c8819feee94008 100644 (file)
@@ -109,9 +109,10 @@ static GSList *scan(GSList *options)
        while (g_get_monotonic_time() - start < MAX_SCAN_TIME) {
                if (serial_read_nonblocking(serial, &c, 1) == 1 && c == 0xa5) {
                        /* Found one. */
-                       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, "CEM",
-                                       "DT-885x", NULL)))
-                               return NULL;
+                       sdi = sr_dev_inst_new();
+                       sdi->status = SR_ST_INACTIVE;
+                       sdi->vendor = g_strdup("CEM");
+                       sdi->model = g_strdup("DT-885x");
 
                        if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
                                sr_dbg("Device context malloc failed.");
index 9226c5a094c269a8f0ca5e8d1857bbdf3dfab167..0d671fbfff8b1d703893f473657ac63a031dc2bd 100644 (file)
@@ -85,9 +85,10 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
 
        sr_info("Found device on port %s.", conn);
 
-       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, center_devs[idx].vendor,
-                                   center_devs[idx].device, NULL)))
-               goto scan_cleanup;
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INACTIVE;
+       sdi->vendor = g_strdup(center_devs[idx].vendor);
+       sdi->model = g_strdup(center_devs[idx].device);
 
        if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
                sr_err("Device context malloc failed.");
index d65dabb6661b731efa703c4047ea8f7452eddb41..3dc0598ec30aba688b00c712012dff6c3cb31029 100644 (file)
@@ -120,13 +120,10 @@ static int add_device(int idx, int model, GSList **devices)
        devc->cur_samplerate = devc->prof->max_samplerate;
 
        /* Register the device with libsigrok. */
-       sdi = sr_dev_inst_new(SR_ST_INITIALIZING,
-                             "ChronoVu", devc->prof->modelname, NULL);
-       if (!sdi) {
-               sr_err("Failed to create device instance.");
-               ret = SR_ERR;
-               goto err_free_final_buf;
-       }
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INITIALIZING;
+       sdi->vendor = g_strdup("ChronoVu");
+       sdi->model = g_strdup(devc->prof->modelname);
        sdi->driver = di;
        sdi->priv = devc;
 
@@ -147,7 +144,6 @@ static int add_device(int idx, int model, GSList **devices)
 
 err_free_dev_inst:
        sr_dev_inst_free(sdi);
-err_free_final_buf:
        g_free(devc->final_buf);
 err_free_devc:
        g_free(devc);
index 9ea441781520244c00e52ffaf5a4d5215044fc7d..fa94119680032c1c6430c600c058d0c2c3cee75a 100644 (file)
@@ -82,9 +82,10 @@ static GSList *scan(GSList *options)
        if (!serialcomm)
                serialcomm = SERIALCOMM;
 
-       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, "Colead",
-                       "SL-5868P", NULL)))
-               return NULL;
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INACTIVE;
+       sdi->vendor = g_strdup("Colead");
+       sdi->model = g_strdup("SL-5868P");
 
        if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
                sr_dbg("Device context malloc failed.");
index e820e253b8dda0511fdf6c8be523884038b4ad95..8a9650ecc8def2841af255f802906bc7bf21055d 100644 (file)
@@ -94,9 +94,10 @@ static GSList *scan(GSList *options)
 
        sr_spew("Conrad DIGI 35 CPU assumed at %s.", conn);
 
-       if (!(sdi = sr_dev_inst_new(SR_ST_ACTIVE, "Conrad", "DIGI 35 CPU", NULL)))
-               return NULL;
-
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_ACTIVE;
+       sdi->vendor = g_strdup("Conrad");
+       sdi->model = g_strdup("DIGI 35 CPU");
        sdi->conn = serial;
        sdi->priv = NULL;
        sdi->driver = di;
index 2a8ea2341242691d1034bf6584ab51b02ae7e1b2..b5cb276c9747f4011ed42ef8917abe1cf3866aa5 100644 (file)
@@ -289,11 +289,10 @@ static GSList *scan(GSList *options)
        }
 
        devices = NULL;
-       sdi = sr_dev_inst_new(SR_ST_ACTIVE, "Demo device", NULL, NULL);
-       if (!sdi) {
-               sr_err("Device instance creation failed.");
-               return NULL;
-       }
+
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_ACTIVE;
+       sdi->model = "Demo device";
        sdi->driver = di;
 
        devc = g_malloc(sizeof(struct dev_context));
index 7ece648774f1a20a94c08e7e7e6201f3b710de1a..b7638fa2b18b6f355590489dcefcf2cd978fc755 100644 (file)
@@ -122,9 +122,11 @@ static GSList *fluke_scan(const char *conn, const char *serialcomm)
                                        continue;
                                /* Skip leading spaces in version number. */
                                for (s = 0; tokens[1][s] == ' '; s++);
-                               if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, "Fluke",
-                                               tokens[0] + 6, tokens[1] + s)))
-                                       return NULL;
+                               sdi = sr_dev_inst_new();
+                               sdi->status = SR_ST_INACTIVE;
+                               sdi->vendor = g_strdup("Fluke");
+                               sdi->model = g_strdup(tokens[0] + 6);
+                               sdi->version = g_strdup(tokens[1] + s);
                                if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
                                        sr_err("Device context malloc failed.");
                                        return NULL;
index a4a679a4e32159a5e71ed8bb8921b0d37820a663..41f71d1bb2ab86d5585d82e029dbd1e327f7697c 100644 (file)
@@ -238,10 +238,11 @@ static GSList *scan(GSList *options)
                if (!prof)
                        continue;
 
-               sdi = sr_dev_inst_new(SR_ST_INITIALIZING,
-                       prof->vendor, prof->model, prof->model_version);
-               if (!sdi)
-                       return NULL;
+               sdi = sr_dev_inst_new();
+               sdi->status = SR_ST_INITIALIZING;
+               sdi->vendor = g_strdup(prof->vendor);
+               sdi->model = g_strdup(prof->model);
+               sdi->version = g_strdup(prof->model_version);
                sdi->driver = di;
                sdi->serial_num = g_strdup(serial_num);
                sdi->connection_id = g_strdup(connection_id);
index 7c7ca88e27b862ba35c0ff655cc0d1c6fed2da34..464fe5029bec61c76f8912cf979dc12b6f24bfe7 100644 (file)
@@ -223,9 +223,10 @@ static GSList *scan_1x_2x_rs232(GSList *options)
 
        if (model != METRAHIT_NONE) {
                sr_spew("%s %s detected!", VENDOR_GMC, gmc_model_str(model));
-               if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, VENDOR_GMC,
-                               gmc_model_str(model), NULL)))
-                       return NULL;
+               sdi = sr_dev_inst_new();
+               sdi->status = SR_ST_INACTIVE;
+               sdi->vendor = g_strdup(VENDOR_GMC);
+               sdi->model = g_strdup(gmc_model_str(model));
                if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
                        sr_err("Device context malloc failed.");
                        return NULL;
@@ -303,9 +304,9 @@ static GSList *scan_2x_bd232(GSList *options)
                goto exit_err;
        }
 
-       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, VENDOR_GMC, NULL, NULL)))
-               goto exit_err;
-
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INACTIVE;
+       sdi->vendor = g_strdup(VENDOR_GMC);
        sdi->priv = devc;
 
        /* Send message 03 "Query multimeter version and status" */
@@ -354,8 +355,9 @@ static GSList *scan_2x_bd232(GSList *options)
                                goto exit_err;
                        }
 
-                       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, VENDOR_GMC, NULL, NULL)))
-                               goto exit_err;
+                       sdi = sr_dev_inst_new();
+                       sdi->status = SR_ST_INACTIVE;
+                       sdi->vendor = g_strdup(VENDOR_GMC);
                }
        };
 
index 31c11e2b361caacf439ad49bf3db9051ab3125e8..f9ba81b8051cd6b331b2021cb83374e38880f88b 100644 (file)
@@ -75,16 +75,15 @@ static struct sr_dev_inst *hmo_probe_serial_device(struct sr_scpi_dev_inst *scpi
        if (check_manufacturer(hw_info->manufacturer) != SR_OK)
                goto fail;
 
-       if (!(sdi = sr_dev_inst_new(SR_ST_ACTIVE,
-                                   hw_info->manufacturer, hw_info->model,
-                                   hw_info->firmware_version))) {
-               goto fail;
-       }
-
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_ACTIVE;
+       sdi->vendor = g_strdup(hw_info->manufacturer);
+       sdi->model = g_strdup(hw_info->model);
+       sdi->version = g_strdup(hw_info->firmware_version);
+       sdi->serial_num = g_strdup(hw_info->serial_number);
        sdi->driver = di;
        sdi->inst_type = SR_INST_SCPI;
        sdi->conn = scpi;
-       sdi->serial_num = g_strdup(hw_info->serial_number);
 
        sr_scpi_hw_info_free(hw_info);
        hw_info = NULL;
index e6420a24176f98310e5f816181f4f829d687659e..201518a4e71b3967add0124a6ffe6a69ec5bd743 100644 (file)
@@ -172,7 +172,10 @@ static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
        struct dev_context *devc;
        int i;
 
-       sdi = sr_dev_inst_new(SR_ST_INITIALIZING, prof->vendor, prof->model, NULL);
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INITIALIZING;
+       sdi->vendor = g_strdup(prof->vendor);
+       sdi->model = g_strdup(prof->model);
        sdi->driver = di;
 
        /*
index 89d12ea9fb3a3fed7110e9ac8aee87d39a09893d..d459210f12a0cfcfbc7682d7c6ec2a68e9b7691e 100644 (file)
@@ -70,7 +70,6 @@ static GSList *scan(GSList *options)
        struct sr_usb_dev_inst *usb;
        struct device_info dev_info;
        int ret, i;
-       char *fw_ver_str;
 
        (void)options;
 
@@ -113,34 +112,16 @@ static GSList *scan(GSList *options)
                        continue;
                }
 
-               fw_ver_str = g_strdup_printf("%u.%u", dev_info.fw_ver_major,
-                       dev_info.fw_ver_minor);
-               if (!fw_ver_str) {
-                       sr_err("Firmware string malloc failed.");
-                       sr_usb_dev_inst_free(usb);
-                       libusb_free_transfer(devc->xfer_in);
-                       libusb_free_transfer(devc->xfer_out);
-                       g_free(devc);
-                       continue;
-               }
-
-               sdi = sr_dev_inst_new(SR_ST_INACTIVE, VENDOR_NAME,
-                       MODEL_NAME, fw_ver_str);
-               g_free(fw_ver_str);
-               if (!sdi) {
-                       sr_err("sr_dev_inst_new failed.");
-                       sr_usb_dev_inst_free(usb);
-                       libusb_free_transfer(devc->xfer_in);
-                       libusb_free_transfer(devc->xfer_out);
-                       g_free(devc);
-                       continue;
-               }
-
+               sdi = sr_dev_inst_new();
+               sdi->status = SR_ST_INACTIVE;
+               sdi->vendor = g_strdup(VENDOR_NAME);
+               sdi->model = g_strdup(MODEL_NAME);
+               sdi->version = g_strdup_printf("%u.%u", dev_info.fw_ver_major, dev_info.fw_ver_minor);
+               sdi->serial_num = g_strdup_printf("%d", dev_info.serial);
                sdi->priv = devc;
                sdi->driver = di;
                sdi->inst_type = SR_INST_USB;
                sdi->conn = usb;
-               sdi->serial_num = g_strdup_printf("%d", dev_info.serial);
 
                for (i = 0; channel_names[i]; i++) {
                        ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
index 95bd3c1a1e4b13e6ca291f09fee046715d47ec34..5075364624946c4d48563f5c6e6f2b16f540614d 100644 (file)
@@ -123,12 +123,10 @@ static GSList *scan(GSList *options)
        }
 
        /* Register the device with libsigrok. */
-       sdi = sr_dev_inst_new(SR_ST_INITIALIZING,
-                       USB_VENDOR_NAME, USB_MODEL_NAME, NULL);
-       if (!sdi) {
-               sr_err("Failed to create device instance.");
-               goto err_close_ftdic;
-       }
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INITIALIZING;
+       sdi->vendor = g_strdup(USB_VENDOR_NAME);
+       sdi->model = g_strdup(USB_MODEL_NAME);
        sdi->driver = di;
        sdi->priv = devc;
 
@@ -147,7 +145,6 @@ static GSList *scan(GSList *options)
 
        return devices;
 
-err_close_ftdic:
        scanaplus_close(devc);
 err_free_ftdic:
        ftdi_free(devc->ftdic); /* NOT free() or g_free()! */
index 0e5baef5ea697079dede396d27f09a75efa6c9ca..721ceda12937045c100794fce79147d88d118210 100644 (file)
@@ -129,10 +129,10 @@ static GSList *scan(GSList *options)
                for (l = usb_devices; l; l = l->next) {
                        if (scan_kecheng(l->data, &model) != SR_OK)
                                continue;
-                       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, VENDOR,
-                                       model, NULL)))
-                               return NULL;
-                       g_free(model);
+                       sdi = sr_dev_inst_new();
+                       sdi->status = SR_ST_INACTIVE;
+                       sdi->vendor = g_strdup(VENDOR);
+                       sdi->model = model; /* Already g_strndup()'d. */
                        sdi->driver = di;
                        sdi->inst_type = SR_INST_USB;
                        sdi->conn = l->data;
index 7459a1f183f8a056888aec197129ff6cc2dbb2aa..ab5b6734426539b8eec698f3509b08c68aae5754 100644 (file)
@@ -323,9 +323,11 @@ static struct sr_dev_inst *lascar_identify(unsigned char *config)
                        return NULL;
                }
 
-               if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, LASCAR_VENDOR,
-                               profile->modelname, firmware)))
-                       return NULL;
+               sdi = sr_dev_inst_new();
+               sdi->status = SR_ST_INACTIVE;
+               sdi->vendor = g_strdup(LASCAR_VENDOR);
+               sdi->model = g_strdup(profile->modelname);
+               sdi->version = g_strdup(firmware);
                sdi->driver = di;
 
                if (profile->logformat == LOG_TEMP_RH) {
index fad2e8dae6f161c9b7a6cef4a5510d7b17f7554c..6be41b9fd9b67460d98fffbe78c5ef20b3fcd6f5 100644 (file)
@@ -150,12 +150,10 @@ static GSList *scan(GSList *options)
        }
 
        /* Init device instance, etc. */
-       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, "Manson",
-                                   models[model_id].name, NULL))) {
-               sr_err("Failed to create device instance.");
-               return NULL;
-       }
-
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INACTIVE;
+       sdi->vendor = g_strdup("Manson");
+       sdi->model = g_strdup(models[model_id].name);
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
        sdi->driver = di;
index eb5d25d4f2cbec74735604c239c79f3d834490af..5969b1037fcdb4a149640b17ddab0694f12893a6 100644 (file)
@@ -84,9 +84,10 @@ static GSList *mic_scan(const char *conn, const char *serialcomm, int idx)
        sr_info("Found device on port %s.", conn);
 
        /* TODO: Fill in version from protocol response. */
-       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, mic_devs[idx].vendor,
-                                   mic_devs[idx].device, NULL)))
-               goto scan_cleanup;
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INACTIVE;
+       sdi->vendor = g_strdup(mic_devs[idx].vendor);
+       sdi->model = g_strdup(mic_devs[idx].device);
 
        if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
                sr_err("Device context malloc failed.");
index bcbc2954310882e3b184a3fb011b594cbba34f2a..40bb2d9578873a0baa4f5708f714d07309d3eda6 100644 (file)
@@ -375,9 +375,9 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
        GSList *devices;
        const char *conn, *serialcomm;
        int cnt;
-       gchar  buf[LINELEN_MAX];
+       gchar buf[LINELEN_MAX];
        gchar channel[10];
-       char*  verstr;
+       char *verstr;
 
        sdi = NULL;
        devc = NULL;
@@ -444,7 +444,11 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
                Therefore just print an error message, but do not exit with error. */
                sr_err("Failed to query for hardware version: %d %s", errno, strerror(errno));
 
-       sdi = sr_dev_inst_new(SR_ST_INACTIVE, VENDOR_MOTECH, models[modelid].modelstr, verstr);
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INACTIVE;
+       sdi->vendor = g_strdup(VENDOR_MOTECH);
+       sdi->model = g_strdup(models[modelid].modelstr);
+       sdi->version = g_strdup(verstr);
        sdi->driver = drv;
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
index f95e7398701c3e9e6923f804f1753f55a48a2fe6..ab9b36e292d047feb3713e1658c7dcae8ee96c0b 100644 (file)
@@ -144,9 +144,11 @@ static GSList *do_scan(struct sr_dev_driver* drv, GSList *options)
                        auxtype = xgittoint(buf[7]);
                        sr_spew("%s %s DMM %s detected!", get_brandstr(drv), get_typestr(auxtype, drv), buf + 9);
 
-                       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE,
-                                               get_brandstr(drv), get_typestr(auxtype, drv), buf + 9)))
-                               return NULL;
+                       sdi = sr_dev_inst_new();
+                       sdi->status = SR_ST_INACTIVE;
+                       sdi->vendor = g_strdup(get_brandstr(drv));
+                       sdi->model = g_strdup(get_typestr(auxtype, drv));
+                       sdi->version = g_strdup(buf + 9);
                        if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
                                sr_err("Device context malloc failed.");
                                return NULL;
index aaf42ab80f48d96451fc37fcb32b1500ce2ee678..174d333d5e4f232f6f31dd02cb34b9c74ad2f2e6 100644 (file)
@@ -177,8 +177,11 @@ static GSList *scan(GSList *options)
        } else {
                /* Not an OLS -- some other board that uses the sump protocol. */
                sr_info("Device does not support metadata.");
-               sdi = sr_dev_inst_new(SR_ST_INACTIVE,
-                               "Sump", "Logic Analyzer", "v1.0");
+               sdi = sr_dev_inst_new();
+               sdi->status = SR_ST_INACTIVE;
+               sdi->vendor = g_strdup("Sump");
+               sdi->model = g_strdup("Logic Analyzer");
+               sdi->version = g_strdup("v1.0");
                sdi->driver = di;
                for (i = 0; i < 32; i++) {
                        if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
index 0a816d01625ad238d7fb548007bd67903da09c76..c2b66615e5156781163d9ca02de723d11a018598 100644 (file)
@@ -152,7 +152,8 @@ SR_PRIV struct sr_dev_inst *get_metadata(struct sr_serial_dev_inst *serial)
        GString *tmp_str, *devname, *version;
        guchar tmp_c;
 
-       sdi = sr_dev_inst_new(SR_ST_INACTIVE, NULL, NULL, NULL);
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INACTIVE;
        sdi->driver = di;
        devc = ols_dev_new();
        sdi->priv = devc;
index 62d77e96576ffc88e8507766c3e459ed1527b91d..81bbe8e647fe02e09f9b45716e1a0896adcd8c7f 100644 (file)
@@ -226,7 +226,8 @@ SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, str
        guchar tmp_c;
        int index, i;
 
-       sdi = sr_dev_inst_new(SR_ST_INACTIVE, NULL, NULL, NULL);
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INACTIVE;
        sdi->driver = di;
        sdi->priv = devc;
 
index 0234c9c0df3ab5d63d8796ed9e1ad1c9596a17f8..763276626111dec61126018424e8792fd0634755 100644 (file)
@@ -291,14 +291,16 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
                }
        }
 
-       if (!model || !(sdi = sr_dev_inst_new(SR_ST_ACTIVE,
-                                             model->series->vendor->name,
-                                                 model->name,
-                                                 hw_info->firmware_version))) {
+       if (!model) {
                sr_scpi_hw_info_free(hw_info);
                return NULL;
        }
 
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_ACTIVE;
+       sdi->vendor = g_strdup(model->series->vendor->name);
+       sdi->model = g_strdup(model->name);
+       sdi->version = g_strdup(hw_info->firmware_version);
        sdi->conn = scpi;
        sdi->driver = di;
        sdi->inst_type = SR_INST_SCPI;
index bc5a3b9a5228672335e6b427d243c6b24892d316..f151fbd9243df42443c815052ab221a934b47841 100644 (file)
@@ -198,10 +198,10 @@ static GSList *scan(GSList *options)
                if (des.idVendor != LOGIC16_VID || des.idProduct != LOGIC16_PID)
                        continue;
 
-               sdi = sr_dev_inst_new(SR_ST_INITIALIZING,
-                                     "Saleae", "Logic16", NULL);
-               if (!sdi)
-                       return NULL;
+               sdi = sr_dev_inst_new();
+               sdi->status = SR_ST_INITIALIZING;
+               sdi->vendor = g_strdup("Saleae");
+               sdi->model = g_strdup("Logic16");
                sdi->driver = di;
                sdi->connection_id = g_strdup(connection_id);
 
index c8502fc5591474e7a1d7d65dd27590a9c5a42e81..b62574e2abbb02492e8305f8aaad18139c97efac 100644 (file)
@@ -90,8 +90,11 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
                return NULL;
        }
 
-       sdi = sr_dev_inst_new(SR_ST_ACTIVE, vendor, hw_info->model,
-                       hw_info->firmware_version);
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_ACTIVE;
+       sdi->vendor = g_strdup(vendor);
+       sdi->model = g_strdup(hw_info->model);
+       sdi->version = g_strdup(hw_info->firmware_version);
        sdi->conn = scpi;
        sdi->driver = di;
        sdi->inst_type = SR_INST_SCPI;
index 70f05f2d52ccc8f7339a5b9a3eef9816ec452b71..87e63b10f4f07b6413c056ebdd0e60d4632992ce 100644 (file)
@@ -456,9 +456,10 @@ static GSList *sdmm_scan(const char *conn, const char *serialcomm, int dmm)
 
        sr_info("Found device on port %s.", conn);
 
-       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, dmms[dmm].vendor,
-                                   dmms[dmm].device, NULL)))
-               goto scan_cleanup;
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INACTIVE;
+       sdi->vendor = g_strdup(dmms[dmm].vendor);
+       sdi->model = g_strdup(dmms[dmm].device);
 
        if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
                sr_err("Device context malloc failed.");
index 11d78d4915d3945eff62f4b9fdeaaee8909cb5fb..f2fc191600c5a8c4af7706c24545b871d4953052 100644 (file)
@@ -99,7 +99,7 @@ static GSList *gen_channel_list(int num_channels)
        return list;
 }
 
-static struct sr_dev_inst *dev_inst_new()
+static struct sr_dev_inst *dev_inst_new(void)
 {
        struct sr_dev_inst *sdi;
        struct dev_context *devc;
@@ -112,13 +112,10 @@ static struct sr_dev_inst *dev_inst_new()
        }
 
        /* Register the device with libsigrok. */
-       sdi = sr_dev_inst_new(SR_ST_INACTIVE,
-                             VENDOR_NAME, MODEL_NAME, NULL);
-       if (!sdi) {
-               sr_err("Failed to instantiate device.");
-               g_free(devc);
-               return NULL;
-       }
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INACTIVE;
+       sdi->vendor = g_strdup(VENDOR_NAME);
+       sdi->model = g_strdup(MODEL_NAME);
 
        /* Enable all channels to match the default channel configuration. */
        devc->channel_mask = ALL_CHANNELS_MASK;
index 63432f58d922632c6de71096be4ab76ed0b2f288..3e6a4d4521fff4e9656e5cd1128a0bf0ab3cd408 100644 (file)
@@ -92,8 +92,10 @@ static GSList *scan(GSList *options)
 
        sr_info("Found device on port %s.", conn);
 
-       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, "EDF", "Teleinfo", NULL)))
-               goto scan_cleanup;
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INACTIVE;
+       sdi->vendor = g_strdup("EDF");
+       sdi->model = g_strdup("Teleinfo");
 
        if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
                sr_err("Device context malloc failed.");
index 3ceb08698d9ff24c8b7f86cb0fd3fb2d68a15c7c..6f0e4e1a7adbd317a704c5e1a7519e2138be0227 100644 (file)
@@ -124,8 +124,10 @@ static GSList *scan(GSList *options)
                if (strcmp(product, "testo 435/635/735"))
                        continue;
 
-               sdi = sr_dev_inst_new(SR_ST_INACTIVE, "Testo",
-                               "435/635/735", NULL);
+               sdi = sr_dev_inst_new();
+               sdi->status = SR_ST_INACTIVE;
+               sdi->vendor = g_strdup("Testo");
+               sdi->model = g_strdup("435/635/735");
                sdi->driver = di;
                sdi->inst_type = SR_INST_USB;
                sdi->conn = sr_usb_dev_inst_new(libusb_get_bus_number(devlist[i]),
index 4578c21f1c4a7f68ac495deadcf65dbcaffc2c70..d725ec355b5ea17452a91c91fb7df94ca3381908 100644 (file)
@@ -84,11 +84,10 @@ static GSList *scan(GSList *options)
        if (!serialcomm)
                serialcomm = SERIALCOMM;
 
-       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, "Tondaj",
-                                   "SL-814", NULL))) {
-               sr_err("Failed to create device instance.");
-               return NULL;
-       }
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INACTIVE;
+       sdi->vendor = g_strdup("Tondaj");
+       sdi->model = g_strdup("SL-814");
 
        if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
                sr_err("Device context malloc failed.");
index a69885d6cc46ca57052261723bfecaf537c498b1..35ceaaed4a12c5bc64535037911edd99c2199dea 100644 (file)
@@ -260,11 +260,10 @@ static GSList *scan(GSList *options, int dmm)
 
                devc->first_run = TRUE;
 
-               if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE,
-                               udmms[dmm].vendor, udmms[dmm].device, NULL))) {
-                       sr_err("sr_dev_inst_new returned NULL.");
-                       return NULL;
-               }
+               sdi = sr_dev_inst_new();
+               sdi->status = SR_ST_INACTIVE;
+               sdi->vendor = g_strdup(udmms[dmm].vendor);
+               sdi->model = g_strdup(udmms[dmm].device);
                sdi->priv = devc;
                sdi->driver = udmms[dmm].di;
                if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
index ab1618e872fe99a9e738ee390bc1536875894dd9..a50d4a4fcdcb64a09c4d098b83e46fa6d98d0d67 100644 (file)
@@ -79,9 +79,10 @@ static GSList *scan(GSList *options)
                /* We have a list of sr_usb_dev_inst matching the connection
                 * string. Wrap them in sr_dev_inst and we're done. */
                for (l = usb_devices; l; l = l->next) {
-                       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, VENDOR,
-                                       MODEL, NULL)))
-                               return NULL;
+                       sdi = sr_dev_inst_new();
+                       sdi->status = SR_ST_INACTIVE;
+                       sdi->vendor = g_strdup(VENDOR);
+                       sdi->model = g_strdup(MODEL);
                        sdi->driver = di;
                        sdi->inst_type = SR_INST_USB;
                        sdi->conn = l->data;
index 7ce468e560a7011bfca388cfaeea7e8a8d2ed28b..fe419443c559a0ef050cfabdecfd2b10eb6b5ff4 100644 (file)
@@ -82,9 +82,9 @@ static GSList *scan(GSList *options)
 
                usb_get_port_path(devlist[i], connection_id, sizeof(connection_id));
 
-               if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE,
-                               VICTOR_VENDOR, NULL, NULL)))
-                       return NULL;
+               sdi = sr_dev_inst_new();
+               sdi->status = SR_ST_INACTIVE;
+               sdi->vendor = g_strdup(VICTOR_VENDOR);
                sdi->driver = di;
                sdi->connection_id = g_strdup(connection_id);
 
index 23d21185278d9b4044ac3a7701c4d91589172913..48e9a0ced109be33d1537bb4565c79da6acc2cdb 100644 (file)
@@ -62,9 +62,11 @@ static struct sr_dev_inst *probe_usbtmc_device(struct sr_scpi_dev_inst *scpi)
        if (dlm_model_get(hw_info->model, &model_name, &model_index) != SR_OK)
                goto fail;
 
-       if (!(sdi = sr_dev_inst_new(SR_ST_ACTIVE, MANUFACTURER_NAME,
-                       model_name, hw_info->firmware_version)))
-               goto fail;
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_ACTIVE;
+       sdi->vendor = g_strdup(MANUFACTURER_NAME);
+       sdi->model = g_strdup(model_name);
+       sdi->version = g_strdup(hw_info->firmware_version);
 
        sdi->serial_num = g_strdup(hw_info->serial_number);
 
index 3eeb9811a7cdc6f136f7600525ed7142dc9a1b5f..76ae1e331d1112808d75babe1d2e736485f0824e 100644 (file)
@@ -222,11 +222,10 @@ static GSList *scan(GSList *options)
                sr_info("Found ZEROPLUS %s.", prof->model_name);
 
                /* Register the device with libsigrok. */
-               if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE,
-                               VENDOR_NAME, prof->model_name, NULL))) {
-                       sr_err("%s: sr_dev_inst_new failed", __func__);
-                       return NULL;
-               }
+               sdi = sr_dev_inst_new();
+               sdi->status = SR_ST_INACTIVE;
+               sdi->vendor = g_strdup(VENDOR_NAME);
+               sdi->model = g_strdup(prof->model_name);
                sdi->driver = di;
                sdi->serial_num = g_strdup(serial_num);
                sdi->connection_id = g_strdup(connection_id);
index 813cf4a46e8be054d8ee0f42fc8dc0aca360191c..b3f12d760b899692e4ef0b6424969b618bfabbd3 100644 (file)
@@ -50,7 +50,7 @@ static int init(struct sr_input *in, GHashTable *options)
                return SR_ERR_ARG;
        }
 
-       in->sdi = sr_dev_inst_new(SR_ST_ACTIVE, NULL, NULL, NULL);
+       in->sdi = sr_dev_inst_new();
        in->priv = inc = g_malloc0(sizeof(struct context));
 
        inc->samplerate = g_variant_get_uint64(g_hash_table_lookup(options, "samplerate"));
index 55331df83ddbac741f73b25adffc4b193375ea21..c1cf4d387991d5d4f311458be5db2bc46787492d 100644 (file)
@@ -62,7 +62,7 @@ static int init(struct sr_input *in, GHashTable *options)
                return SR_ERR_ARG;
        }
 
-       in->sdi = sr_dev_inst_new(SR_ST_ACTIVE, NULL, NULL, NULL);
+       in->sdi = sr_dev_inst_new();
        in->priv = inc = g_malloc0(sizeof(struct context));
 
        inc->samplerate = g_variant_get_uint64(g_hash_table_lookup(options, "samplerate"));
index 49bd73c8739623eaa3cedb93622666aa1bb6f861..b2756fa0aa124453dd266b2373896d2d06b37d21 100644 (file)
@@ -393,7 +393,7 @@ static int init(struct sr_input *in, GHashTable *options)
        struct context *inc;
        const char *s;
 
-       in->sdi = sr_dev_inst_new(SR_ST_ACTIVE, NULL, NULL, NULL);
+       in->sdi = sr_dev_inst_new();
        in->priv = inc = g_malloc0(sizeof(struct context));
 
        inc->single_column = g_variant_get_int32(g_hash_table_lookup(options, "single-column"));
index ef78c9fe477e7bc24a31328018d4778d13089a11..e6bc05e5a6b18130524f7b8d11d85ece2ca054f1 100644 (file)
@@ -429,7 +429,7 @@ static int init(struct sr_input *in, GHashTable *options)
        inc->skip = g_variant_get_int32(g_hash_table_lookup(options, "skip"));
        inc->skip /= inc->downsample;
 
-       in->sdi = sr_dev_inst_new(SR_ST_ACTIVE, NULL, NULL, NULL);
+       in->sdi = sr_dev_inst_new();
        in->priv = inc;
 
        for (i = 0; i < num_channels; i++) {
index 1c0d4fd18082da643d6b2b0d083e277f1d7ff597..8f8a37101200d49488596d7e914d7e8bbd490ad3 100644 (file)
@@ -150,7 +150,7 @@ static int init(struct sr_input *in, GHashTable *options)
 {
        (void)options;
 
-       in->sdi = sr_dev_inst_new(SR_ST_ACTIVE, NULL, NULL, NULL);
+       in->sdi = sr_dev_inst_new();
        in->priv = g_malloc0(sizeof(struct context));
 
        return SR_OK;
index b8773493ac6c49d7f16cc551782aaec601e6af9c..4cacbe9a134c84d54fb2f4fa46d23e1934a1a6d8 100644 (file)
@@ -843,8 +843,10 @@ SR_PRIV struct sr_dev_inst *es51919_serial_scan(GSList *options,
 
        sr_info("Found device on port %s.", serial->port);
 
-       if (!(sdi = sr_dev_inst_new(SR_ST_INACTIVE, vendor, model, NULL)))
-               goto scan_cleanup;
+       sdi = sr_dev_inst_new();
+       sdi->status = SR_ST_INACTIVE;
+       sdi->vendor = g_strdup(vendor);
+       sdi->model = g_strdup(model);
 
        if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
                sr_err("Device context malloc failed.");
index 9e393f422fedd19e988fafb7fad0e726f255ae9d..f98a35a87f2bc4fc8baf9aae3bcc161f6c30a9b2 100644 (file)
@@ -521,8 +521,7 @@ struct sr_dev_inst {
 };
 
 /* Generic device instances */
-SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int status,
-               const char *vendor, const char *model, const char *version);
+SR_PRIV struct sr_dev_inst *sr_dev_inst_new(void);
 SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi);
 
 #ifdef HAVE_LIBUSB_1_0
index bd5b827f41734abf8ceb3056c31c264b26d5ba63..9f8ee75660556dc6cb4b34ca3a23746fed25a945 100644 (file)
@@ -170,8 +170,9 @@ SR_API int sr_session_load(const char *filename, struct sr_session **session)
                        for (j = 0; keys[j]; j++) {
                                val = g_key_file_get_string(kf, sections[i], keys[j], NULL);
                                if (!strcmp(keys[j], "capturefile")) {
-                                       sdi = sr_dev_inst_new(SR_ST_ACTIVE, NULL, NULL, NULL);
+                                       sdi = sr_dev_inst_new();
                                        sdi->driver = &session_driver;
+                                       sdi->status = SR_ST_ACTIVE;
                                        if (!session_driver_initialized) {
                                                /* first device, init the driver */
                                                session_driver_initialized = 1;