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 <mr.nuke.me@gmail.com>
This commit is contained in:
Alexandru Gagniuc 2012-12-13 11:08:38 -06:00 committed by Uwe Hermann
parent d128bf12b2
commit c69049091e
3 changed files with 3 additions and 4 deletions

View 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")

View 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);

View File

@ -631,8 +631,6 @@ struct sr_dev_driver {
/* Dynamic */
void *priv;
int subdriver;
};
struct sr_session {