]> sigrok.org Git - libsigrok.git/commitdiff
serial-dmm: Eliminate unneeded "subdriver" field.
authorUwe Hermann <redacted>
Sun, 16 Dec 2012 20:28:26 +0000 (21:28 +0100)
committerUwe Hermann <redacted>
Mon, 17 Dec 2012 13:21:12 +0000 (14:21 +0100)
Just use the 'int dmm' + wrapper method that is used for all other
functions which need this information. There is no real need to
special-case the hw_dev_acquisition_start() API call here.

hardware/serial-dmm/api.c
hardware/serial-dmm/protocol.h

index 49e68a218c4d277eec0dfc6da4827ff07b4b5ebb..0067e8c5fe44b82da11b27d8f88a9e73f15828b7 100644 (file)
@@ -254,7 +254,6 @@ static GSList *scan(const char *conn, const char *serialcomm, int dmm)
        }
 
        devc->serial = serial;
-       devc->subdriver = dmm;
 
        sdi->priv = devc;
        sdi->driver = dmms[dmm].di;
@@ -406,7 +405,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
 }
 
 static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
-                                   void *cb_data)
+                                   void *cb_data, int dmm)
 {
        struct sr_datafeed_packet packet;
        struct sr_datafeed_header header;
@@ -446,7 +445,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
 
        /* Poll every 50ms, or whenever some data comes in. */
        sr_source_add(devc->serial->fd, G_IO_IN, 50,
-                     dmms[devc->subdriver].receive_data, (void *)sdi);
+                     dmms[dmm].receive_data, (void *)sdi);
 
        return SR_OK;
 }
@@ -488,6 +487,9 @@ static GSList *hw_scan_##X(GSList *options) { return hw_scan(options, X); }
 static GSList *hw_dev_list_##X(void) { return hw_dev_list(X); }
 #define CLEAR_INSTANCES(X) \
 static int clear_instances_##X(void) { return clear_instances(X); }
+#define HW_DEV_ACQUISITION_START(X) \
+static int hw_dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \
+void *cb_data) { return hw_dev_acquisition_start(sdi, cb_data, X); }
 
 /* Driver structs and API function wrappers */
 #define DRV(ID, ID_UPPER, NAME, LONGNAME) \
@@ -496,6 +498,7 @@ HW_CLEANUP(ID_UPPER) \
 HW_SCAN(ID_UPPER) \
 HW_DEV_LIST(ID_UPPER) \
 CLEAR_INSTANCES(ID_UPPER) \
+HW_DEV_ACQUISITION_START(ID_UPPER) \
 SR_PRIV struct sr_dev_driver ID##_driver_info = { \
        .name = NAME, \
        .longname = LONGNAME, \
@@ -509,7 +512,7 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \
        .dev_close = hw_dev_close, \
        .info_get = hw_info_get, \
        .dev_config_set = hw_dev_config_set, \
-       .dev_acquisition_start = hw_dev_acquisition_start, \
+       .dev_acquisition_start = hw_dev_acquisition_start_##ID_UPPER, \
        .dev_acquisition_stop = hw_dev_acquisition_stop, \
        .priv = NULL, \
 };
index 7540d8069e6a8fd41ee89c2efbde2feefef81ad3..77f89c741defe2ab3bf4fdc59925d7af5e67ade7 100644 (file)
@@ -81,7 +81,6 @@ struct dev_context {
        uint8_t buf[DMM_BUFSIZE];
        int bufoffset;
        int buflen;
-       int subdriver;
 };
 
 SR_PRIV int receive_data_DIGITEK_DT4000ZC(int fd, int revents, void *cb_data);