]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/microchip-pickit2/api.c
scpi-dmm: Keysight 34465A is a 6.5 digit meter, bump digits count
[libsigrok.git] / src / hardware / microchip-pickit2 / api.c
index 41e7baa2e909e30f56463cf36a493d5405bdd3b3..4eb755d274d057e3eae731e378c8f815b9589e4e 100644 (file)
@@ -42,7 +42,7 @@
  * - The current implementation silently accepts sample count limits beyond
  *   1024, just won't provide more than 1024 samples to the session. A
  *   future implementation could cap the settings upon reception. Apps
- *   like Pulseview may not be able to specify 1024, and pass 1000 or
+ *   like PulseView may not be able to specify 1024, and pass 1000 or
  *   2000 instead (the latter results in 1024 getting used).
  * - The manual suggests that users can assign names to devices. The
  *   current implementation supports conn= specs with USB VID:PID pairs
@@ -66,7 +66,7 @@
 
 static struct sr_dev_driver microchip_pickit2_driver_info;
 
-static const char *pickit2_channel_names[] = {
+static const char *channel_names[] = {
        "pin4", "pin5", "pin6",
 };
 
@@ -162,10 +162,10 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                cg = g_malloc0(sizeof(*cg));
                sdi->channel_groups = g_slist_append(NULL, cg);
                cg->name = g_strdup("Logic");
-               ch_count = ARRAY_SIZE(pickit2_channel_names);
+               ch_count = ARRAY_SIZE(channel_names);
                for (ch_idx = 0; ch_idx < ch_count; ch_idx++) {
                        ch = sr_channel_new(sdi, ch_idx, SR_CHANNEL_LOGIC,
-                               TRUE, pickit2_channel_names[ch_idx]);
+                               TRUE, channel_names[ch_idx]);
                        cg->channels = g_slist_append(cg->channels, ch);
                }
 
@@ -232,6 +232,8 @@ static int dev_close(struct sr_dev_inst *sdi)
        usb = sdi->conn;
        devc = sdi->priv;
 
+       if (!usb)
+               return SR_OK;
        if (!usb->devhdl)
                return SR_OK;
 
@@ -264,10 +266,10 @@ static int config_get(uint32_t key, GVariant **data,
        struct sr_usb_dev_inst *usb;
        uint64_t rate, ratio;
 
-       devc = sdi ? sdi->priv : NULL;
-       (void)devc;
        (void)cg;
 
+       devc = sdi ? sdi->priv : NULL;
+
        switch (key) {
        case SR_CONF_CONN:
                if (!sdi->conn)
@@ -296,10 +298,10 @@ static int config_set(uint32_t key, GVariant *data,
        struct dev_context *devc;
        int idx;
 
-       devc = sdi ? sdi->priv : NULL;
-
        (void)cg;
 
+       devc = sdi ? sdi->priv : NULL;
+
        switch (key) {
        case SR_CONF_SAMPLERATE:
                if (!devc)
@@ -454,5 +456,4 @@ static struct sr_dev_driver microchip_pickit2_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
-
 SR_REGISTER_DEV_DRIVER(microchip_pickit2_driver_info);