]> sigrok.org Git - libsigrok.git/commitdiff
libsigrok.h: Don't store subdriver in sr_dev_driver
authorAlexandru Gagniuc <redacted>
Thu, 13 Dec 2012 17:08:38 +0000 (11:08 -0600)
committerUwe Hermann <redacted>
Thu, 13 Dec 2012 22:16:34 +0000 (23:16 +0100)
Not all drivers use subdrivers. The only reason the subdriver field was
introduced was to accomodate the model of serial-dmm.

The sr_dev_driver struct is available to the frontend. Exposing the subdriver
field creates the problem of exposing knowledge of libsigrok's internal driver
layout, even though the drivers are designed to be a flat list to the frontend.

Store the subdriver in the dev_context struct of serial-dmm.

Signed-off-by: Alexandru Gagniuc <redacted>
hardware/serial-dmm/api.c
hardware/serial-dmm/protocol.h
libsigrok.h

index 6e9eaa2478cc4f19d5f7c014b2611fd263c3dd41..d29af1b54d4bcee401b6e3dd4563ddaffbe60616 100644 (file)
@@ -255,6 +255,7 @@ 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;
@@ -446,7 +447,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[sdi->driver->subdriver].receive_data, (void *)sdi);
+                     dmms[devc->subdriver].receive_data, (void *)sdi);
 
        return SR_OK;
 }
@@ -512,7 +513,6 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \
        .dev_acquisition_start = hw_dev_acquisition_start, \
        .dev_acquisition_stop = hw_dev_acquisition_stop, \
        .priv = NULL, \
-       .subdriver = ID_UPPER, \
 };
 
 DRV(digitek_dt4000zc, DIGITEK_DT4000ZC, "digitek-dt4000zc", "Digitek DT4000ZC")
index 77f89c741defe2ab3bf4fdc59925d7af5e67ade7..7540d8069e6a8fd41ee89c2efbde2feefef81ad3 100644 (file)
@@ -81,6 +81,7 @@ 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);
index 90a57f790baaa264c3355e8ed1f102f0f205474f..d68ec1439bcc588cafcde55d0fc411e04750d39a 100644 (file)
@@ -631,8 +631,6 @@ struct sr_dev_driver {
 
        /* Dynamic */
        void *priv;
-
-       int subdriver;
 };
 
 struct sr_session {