From c69049091ec6e1383805064d3c472264384ffb57 Mon Sep 17 00:00:00 2001 From: Alexandru Gagniuc Date: Thu, 13 Dec 2012 11:08:38 -0600 Subject: [PATCH] libsigrok.h: Don't store subdriver in sr_dev_driver 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 --- hardware/serial-dmm/api.c | 4 ++-- hardware/serial-dmm/protocol.h | 1 + libsigrok.h | 2 -- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/hardware/serial-dmm/api.c b/hardware/serial-dmm/api.c index 6e9eaa24..d29af1b5 100644 --- a/hardware/serial-dmm/api.c +++ b/hardware/serial-dmm/api.c @@ -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") diff --git a/hardware/serial-dmm/protocol.h b/hardware/serial-dmm/protocol.h index 77f89c74..7540d806 100644 --- a/hardware/serial-dmm/protocol.h +++ b/hardware/serial-dmm/protocol.h @@ -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); diff --git a/libsigrok.h b/libsigrok.h index 90a57f79..d68ec143 100644 --- a/libsigrok.h +++ b/libsigrok.h @@ -631,8 +631,6 @@ struct sr_dev_driver { /* Dynamic */ void *priv; - - int subdriver; }; struct sr_session {