]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/gmc-mh-1x-2x/api.c
sr_dev_close(): Set status to SR_ST_INACTIVE.
[libsigrok.git] / src / hardware / gmc-mh-1x-2x / api.c
index 048a0afc6e3d2909853e4b49ca7c91accd92c249..8bac10f14c7cc10e48a9f3cf580512af3646fbf8 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/** @file
- *  Gossen Metrawatt Metrahit 1x/2x drivers
- *  @internal
+/**
+ * @file
+ *
+ * Gossen Metrawatt Metrahit 1x/2x drivers
+ *
+ * @internal
  */
 
 #include <config.h>
@@ -40,7 +43,7 @@ static const uint32_t scanopts[] = {
 /** Hardware capabilities for Metrahit 1x/2x devices in send mode. */
 static const uint32_t devopts_sm[] = {
        SR_CONF_MULTIMETER,
-       SR_CONF_THERMOMETER,    /**< All GMC 1x/2x multimeters seem to support this */
+       SR_CONF_THERMOMETER, /**< All GMC 1x/2x multimeters seem to support this */
        SR_CONF_CONTINUOUS,
        SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
        SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
@@ -49,7 +52,7 @@ static const uint32_t devopts_sm[] = {
 /** Hardware capabilities for Metrahit 2x devices in bidirectional Mode. */
 static const uint32_t devopts_bd[] = {
        SR_CONF_MULTIMETER,
-       SR_CONF_THERMOMETER,    /**< All GMC 1x/2x multimeters seem to support this */
+       SR_CONF_THERMOMETER, /**< All GMC 1x/2x multimeters seem to support this */
        SR_CONF_CONTINUOUS,
        SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET,
        SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET,
@@ -118,7 +121,7 @@ static enum model scan_model_sm(struct sr_serial_dev_inst *serial)
                        for (cnt = 0; cnt < 4; cnt++) {
                                byte = read_byte(serial, timeout_us);
                                if ((byte == -1) ||
-                                               ((byte & MSGID_MASK) != MSGID_DATA))
+                                       ((byte & MSGID_MASK) != MSGID_DATA))
                                {
                                        model = METRAHIT_NONE;
                                        bytecnt = 100;
@@ -320,11 +323,9 @@ static GSList *scan_2x_bd232(struct sr_dev_driver *di, GSList *options)
 exit_err:
        sr_info("scan_2x_bd232(): Error!");
 
-       if (serial)
-               sr_serial_dev_inst_free(serial);
+       sr_serial_dev_inst_free(serial);
        g_free(devc);
-       if (sdi)
-               sr_dev_inst_free(sdi);
+       sr_dev_inst_free(sdi);
 
        return NULL;
 }
@@ -333,13 +334,11 @@ static int dev_close(struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
 
-       std_serial_dev_close(sdi);
+       devc = sdi->priv;
 
-       sdi->status = SR_ST_INACTIVE;
-       if ((devc = sdi->priv))
-               devc->model = METRAHIT_NONE;
+       devc->model = METRAHIT_NONE;
 
-       return SR_OK;
+       return std_serial_dev_close(sdi);
 }
 
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,
@@ -426,9 +425,6 @@ static int dev_acquisition_start_1x_2x_rs232(const struct sr_dev_inst *sdi)
        struct dev_context *devc;
        struct sr_serial_dev_inst *serial;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        devc = sdi->priv;
        devc->settings_ok = FALSE;
        devc->buflen = 0;
@@ -449,9 +445,6 @@ static int dev_acquisition_start_2x_bd232(const struct sr_dev_inst *sdi)
        struct dev_context *devc;
        struct sr_serial_dev_inst *serial;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        devc = sdi->priv;
        devc->settings_ok = FALSE;
        devc->buflen = 0;