X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Flink-mso19%2Fapi.c;h=8b4ccc7fd43c6bea97a2a079b01388642c5f7209;hb=41812aca436805b0614f2a8f31cf2f8ce494aea0;hp=5112fe285d2d0103b41e9c1b5f4f4421ce1c63f4;hpb=f57d8ffe66612a1fdc20ed09c222f8ea59bd84d4;p=libsigrok.git diff --git a/src/hardware/link-mso19/api.c b/src/hardware/link-mso19/api.c index 5112fe28..8b4ccc7f 100644 --- a/src/hardware/link-mso19/api.c +++ b/src/hardware/link-mso19/api.c @@ -38,9 +38,9 @@ static const uint32_t devopts[] = { * * See also: http://www.linkinstruments.com/images/mso19_1113.gif */ -SR_PRIV const char *mso19_channel_names[NUM_CHANNELS + 1] = { +static const char *channel_names[] = { /* Note: DSO needs to be first. */ - "DSO", "0", "1", "2", "3", "4", "5", "6", "7", NULL, + "DSO", "0", "1", "2", "3", "4", "5", "6", "7", }; static const uint64_t samplerates[] = { @@ -50,10 +50,9 @@ static const uint64_t samplerates[] = { }; SR_PRIV struct sr_dev_driver link_mso19_driver_info; -static struct sr_dev_driver *di = &link_mso19_driver_info; /* TODO: Use sr_dev_inst to store connection handle & use std_dev_clear(). */ -static int dev_clear(void) +static int dev_clear(const struct sr_dev_driver *di) { GSList *l; struct sr_dev_inst *sdi; @@ -61,7 +60,7 @@ static int dev_clear(void) struct dev_context *devc; int ret = SR_OK; - if (!(drvc = di->priv)) + if (!(drvc = di->context)) return SR_OK; /* Properly close and free all devices. */ @@ -88,12 +87,12 @@ static int dev_clear(void) return ret; } -static int init(struct sr_context *sr_ctx) +static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) { return std_init(sr_ctx, di, LOG_PREFIX); } -static GSList *scan(GSList *options) +static GSList *scan(struct sr_dev_driver *di, GSList *options) { int i; GSList *devices = NULL; @@ -117,7 +116,7 @@ static GSList *scan(GSList *options) } if (!conn) conn = SERIALCONN; - if (serialcomm == NULL) + if (!serialcomm) serialcomm = SERIALCOMM; udev = udev_new(); @@ -195,10 +194,7 @@ static GSList *scan(GSList *options) devc->protocol_trigger.mask[i] = 0xff; } - if (!(devc->serial = sr_serial_dev_inst_new(conn, serialcomm))) { - g_free(devc); - return devices; - } + devc->serial = sr_serial_dev_inst_new(conn, serialcomm); struct sr_dev_inst *sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi->status = SR_ST_INACTIVE; @@ -217,17 +213,13 @@ static GSList *scan(GSList *options) sdi->driver = di; sdi->priv = devc; - for (i = 0; i < NUM_CHANNELS; i++) { - struct sr_channel *ch; + for (i = 0; i < ARRAY_SIZE(channel_names); i++) { chtype = (i == 0) ? SR_CHANNEL_ANALOG : SR_CHANNEL_LOGIC; - if (!(ch = sr_channel_new(i, chtype, TRUE, - mso19_channel_names[i]))) - return 0; - sdi->channels = g_slist_append(sdi->channels, ch); + sr_channel_new(sdi, i, chtype, TRUE, channel_names[i]); } //Add the driver - struct drv_context *drvc = di->priv; + struct drv_context *drvc = di->context; drvc->instances = g_slist_append(drvc->instances, sdi); devices = g_slist_append(devices, sdi); } @@ -235,9 +227,9 @@ static GSList *scan(GSList *options) return devices; } -static GSList *dev_list(void) +static GSList *dev_list(const struct sr_dev_driver *di) { - return ((struct drv_context *)(di->priv))->instances; + return ((struct drv_context *)(di->context))->instances; } static int dev_open(struct sr_dev_inst *sdi) @@ -271,19 +263,19 @@ static int dev_open(struct sr_dev_inst *sdi) return SR_OK; } -static int cleanup(void) +static int cleanup(const struct sr_dev_driver *di) { return dev_clear(); } -static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, +static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct dev_context *devc; (void)cg; - switch (id) { + switch (key) { case SR_CONF_SAMPLERATE: if (sdi) { devc = sdi->priv; @@ -298,7 +290,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi, return SR_OK; } -static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi, +static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { int ret; @@ -314,7 +306,7 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi, if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - switch (id) { + switch (key) { case SR_CONF_SAMPLERATE: // FIXME return mso_configure_rate(sdi, g_variant_get_uint64(data)); @@ -327,8 +319,6 @@ static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi, ret = SR_ERR_ARG; } else { devc->limit_samples = num_samples; - sr_dbg("setting limit_samples to %i\n", - num_samples); ret = SR_OK; } break; @@ -493,5 +483,5 @@ SR_PRIV struct sr_dev_driver link_mso19_driver_info = { .dev_close = std_serial_dev_close, .dev_acquisition_start = dev_acquisition_start, .dev_acquisition_stop = dev_acquisition_stop, - .priv = NULL, + .context = NULL, };