From: Aurelien Jacobs Date: Fri, 17 Jan 2014 09:47:42 +0000 (+0100) Subject: scpi: add a struct drv_context parameter to scpi_dev_inst_new() X-Git-Tag: libsigrok-0.3.0~156 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=17bdda58686a208424520b64f9324eba259ff535;p=libsigrok.git scpi: add a struct drv_context parameter to scpi_dev_inst_new() --- diff --git a/hardware/common/scpi.c b/hardware/common/scpi.c index fc61855f..2307a8b5 100644 --- a/hardware/common/scpi.c +++ b/hardware/common/scpi.c @@ -87,8 +87,8 @@ static const struct sr_scpi_dev_inst *scpi_devs[] = { #endif }; -SR_PRIV struct sr_scpi_dev_inst *scpi_dev_inst_new(const char *resource, - const char *serialcomm) +SR_PRIV struct sr_scpi_dev_inst *scpi_dev_inst_new(struct drv_context *drvc, + const char *resource, const char *serialcomm) { struct sr_scpi_dev_inst *scpi = NULL; const struct sr_scpi_dev_inst *scpi_dev; @@ -103,7 +103,7 @@ SR_PRIV struct sr_scpi_dev_inst *scpi_dev_inst_new(const char *resource, *scpi = *scpi_dev; scpi->priv = g_malloc0(scpi->priv_size); params = g_strsplit(resource, "/", 0); - if (scpi->dev_inst_new(scpi->priv, resource, + if (scpi->dev_inst_new(scpi->priv, drvc, resource, params, serialcomm) != SR_OK) { sr_scpi_free(scpi); scpi = NULL; diff --git a/hardware/common/scpi_serial.c b/hardware/common/scpi_serial.c index cf962af7..6e73c894 100644 --- a/hardware/common/scpi_serial.c +++ b/hardware/common/scpi_serial.c @@ -35,11 +35,12 @@ struct scpi_serial { size_t read; }; -static int scpi_serial_dev_inst_new(void *priv, const char *resource, - char **params, const char *serialcomm) +static int scpi_serial_dev_inst_new(void *priv, struct drv_context *drvc, + const char *resource, char **params, const char *serialcomm) { struct scpi_serial *sscpi = priv; + (void)drvc; (void)params; if (!(sscpi->serial = sr_serial_dev_inst_new(resource, serialcomm))) diff --git a/hardware/common/scpi_tcp.c b/hardware/common/scpi_tcp.c index 796ea9a8..21235f36 100644 --- a/hardware/common/scpi_tcp.c +++ b/hardware/common/scpi_tcp.c @@ -51,11 +51,12 @@ struct scpi_tcp { int response_bytes_read; }; -static int scpi_tcp_dev_inst_new(void *priv, const char *resource, - char **params, const char *serialcomm) +static int scpi_tcp_dev_inst_new(void *priv, struct drv_context *drvc, + const char *resource, char **params, const char *serialcomm) { struct scpi_tcp *tcp = priv; + (void)drvc; (void)resource; (void)serialcomm; diff --git a/hardware/common/scpi_usbtmc.c b/hardware/common/scpi_usbtmc.c index 75fcf3ae..6cd79641 100644 --- a/hardware/common/scpi_usbtmc.c +++ b/hardware/common/scpi_usbtmc.c @@ -37,11 +37,12 @@ struct usbtmc_scpi { int response_bytes_read; }; -static int scpi_usbtmc_dev_inst_new(void *priv, const char *resource, - char **params, const char *serialcomm) +static int scpi_usbtmc_dev_inst_new(void *priv, struct drv_context *drvc, + const char *resource, char **params, const char *serialcomm) { struct usbtmc_scpi *uscpi = priv; + (void)drvc; (void)params; (void)serialcomm; diff --git a/hardware/common/scpi_vxi.c b/hardware/common/scpi_vxi.c index 0377d52b..4bdb6ab9 100644 --- a/hardware/common/scpi_vxi.c +++ b/hardware/common/scpi_vxi.c @@ -37,11 +37,12 @@ struct scpi_vxi { unsigned int read_complete; }; -static int scpi_vxi_dev_inst_new(void *priv, const char *resource, - char **params, const char *serialcomm) +static int scpi_vxi_dev_inst_new(void *priv, struct drv_context *drvc, + const char *resource, char **params, const char *serialcomm) { struct scpi_vxi *vxi = priv; + (void)drvc; (void)resource; (void)serialcomm; diff --git a/hardware/hameg-hmo/api.c b/hardware/hameg-hmo/api.c index b63ee51b..5abd8c5f 100644 --- a/hardware/hameg-hmo/api.c +++ b/hardware/hameg-hmo/api.c @@ -220,7 +220,7 @@ static struct sr_dev_inst *hmo_probe_serial_device(const char *serial_device, scpi = NULL; hw_info = NULL; - if (!(scpi = scpi_dev_inst_new(serial_device, serial_options))) + if (!(scpi = scpi_dev_inst_new(di->priv, serial_device, serial_options))) goto fail; sr_info("Probing %s.", serial_device); diff --git a/hardware/rigol-ds/api.c b/hardware/rigol-ds/api.c index 706391f4..0f319cbd 100644 --- a/hardware/rigol-ds/api.c +++ b/hardware/rigol-ds/api.c @@ -269,7 +269,7 @@ static int probe_port(const char *resource, const char *serialcomm, GSList **dev *devices = NULL; - if (!(scpi = scpi_dev_inst_new(resource, serialcomm))) + if (!(scpi = scpi_dev_inst_new(di->priv, resource, serialcomm))) return SR_ERR; if (sr_scpi_open(scpi) != SR_OK) { diff --git a/libsigrok-internal.h b/libsigrok-internal.h index 6e665c58..951d91d9 100644 --- a/libsigrok-internal.h +++ b/libsigrok-internal.h @@ -438,8 +438,8 @@ struct sr_scpi_dev_inst { const char *name; const char *prefix; int priv_size; - int (*dev_inst_new)(void *priv, const char *resource, char **params, - const char *serialcomm); + int (*dev_inst_new)(void *priv, struct drv_context *drvc, + const char *resource, char **params, const char *serialcomm); int (*open)(void *priv); int (*source_add)(void *priv, int events, int timeout, sr_receive_data_callback_t cb, void *cb_data); @@ -453,8 +453,8 @@ struct sr_scpi_dev_inst { void *priv; }; -SR_PRIV struct sr_scpi_dev_inst *scpi_dev_inst_new(const char *resource, - const char *serialcomm); +SR_PRIV struct sr_scpi_dev_inst *scpi_dev_inst_new(struct drv_context *drvc, + const char *resource, const char *serialcomm); SR_PRIV int sr_scpi_open(struct sr_scpi_dev_inst *scpi); SR_PRIV int sr_scpi_source_add(struct sr_scpi_dev_inst *scpi, int events, int timeout, sr_receive_data_callback_t cb, void *cb_data);