devcnt = g_slist_length(gdi->instances);
if (!(sdi = sr_dev_inst_new(devcnt, SR_ST_ACTIVE,
- "Generic DMM", NULL, NULL))) {
+ NULL, NULL, NULL))) {
sr_err("genericdmm: sr_dev_inst_new returned NULL.");
return NULL;
}
GSList *l, *ldef, *defopts, *newopts, *devices;
struct sr_hwopt *opt, *defopt;
struct dev_profile *pr, *profile;
+ struct sr_dev_inst *sdi;
const char *model;
/* Separate model from the options list. */
newopts = g_slist_append(newopts, opt);
}
if (!model) {
- sr_err("Need a model to scan for.");
+ /* This driver only works when a model is specified. */
return NULL;
}
if (devices) {
/* TODO: need to fix up sdi->index fields */
- /* Add a copy of these new devices to the driver instances. */
- for (l = devices; l; l = l->next)
+ for (l = devices; l; l = l->next) {
+ /* The default connection-based scanner doesn't really
+ * know about profiles, so it never filled in the vendor
+ * or model. Do that now.
+ */
+ sdi = l->data;
+ sdi->driver = gdi;
+ if (!sdi->vendor)
+ sdi->vendor = g_strdup(profile->vendor);
+ if (!sdi->model)
+ sdi->model = g_strdup(profile->model);
+ /* Add a copy of these new devices to the driver instances. */
gdi->instances = g_slist_append(gdi->instances, l->data);
+ }
}
return devices;
}
-static int hw_dev_open(int dev_index)
+static int hw_dev_open(struct sr_dev_inst *sdi)
{
- struct sr_dev_inst *sdi;
struct context *ctx;
- if (!(sdi = sr_dev_inst_get(gdi->instances, dev_index))) {
- sr_err("genericdmm: sdi was NULL.");
- return SR_ERR_BUG;
- }
-
if (!(ctx = sdi->priv)) {
sr_err("genericdmm: sdi->priv was NULL.");
return SR_ERR_BUG;
return SR_OK;
}
-static int hw_dev_close(int dev_index)
+static int hw_dev_close(struct sr_dev_inst *sdi)
{
- struct sr_dev_inst *sdi;
struct context *ctx;
- if (!(sdi = sr_dev_inst_get(gdi->instances, dev_index))) {
- sr_err("genericdmm: %s: sdi was NULL.", __func__);
- return SR_ERR_BUG;
- }
-
if (!(ctx = sdi->priv)) {
sr_err("genericdmm: %s: sdi->priv was NULL.", __func__);
return SR_ERR_BUG;
}
- /* TODO: Check for != NULL. */
-
switch (ctx->profile->transport) {
case DMM_TRANSPORT_USBHID:
/* TODO */
return SR_OK;
}
-static int hw_info_get(int dev_info_id, const void **data,
+static int hw_info_get(int info_id, const void **data,
const struct sr_dev_inst *sdi)
{
struct context *ctx;
- switch (dev_info_id) {
+ switch (info_id) {
case SR_DI_INST:
*data = sdi;
sr_spew("genericdmm: Returning sdi.");
return SR_OK;
}
-static int hw_dev_status_get(int dev_index)
-{
- struct sr_dev_inst *sdi;
-
- if (!(sdi = sr_dev_inst_get(gdi->instances, dev_index))) {
- sr_err("genericdmm: sdi was NULL, device not found.");
- return SR_ST_NOT_FOUND;
- }
-
- sr_dbg("genericdmm: Returning status: %d.", sdi->status);
-
- return sdi->status;
-}
-
-static int hw_dev_config_set(int dev_index, int hwcap, const void *value)
+static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
+ const void *value)
{
- struct sr_dev_inst *sdi;
struct context *ctx;
- if (!(sdi = sr_dev_inst_get(gdi->instances, dev_index))) {
- sr_err("genericdmm: sdi was NULL.");
- return SR_ERR_BUG;
- }
-
if (!(ctx = sdi->priv)) {
sr_err("genericdmm: sdi->priv was NULL.");
return SR_ERR_BUG;
}
- sr_spew("genericdmm: dev_index %d, hwcap %d.", dev_index, hwcap);
-
switch (hwcap) {
case SR_HWCAP_LIMIT_MSEC:
if (*(const uint64_t *)value == 0) {
return TRUE;
}
-static int hw_dev_acquisition_start(int dev_index, void *cb_data)
+static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
+ void *cb_data)
{
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct sr_datafeed_meta_analog meta;
- struct sr_dev_inst *sdi;
struct context *ctx;
- if (!(sdi = sr_dev_inst_get(gdi->instances, dev_index))) {
- sr_err("genericdmm: sdi was NULL.");
- return SR_ERR_BUG;
- }
-
if (!(ctx = sdi->priv)) {
sr_err("genericdmm: sdi->priv was NULL.");
return SR_ERR_BUG;
return SR_OK;
}
-static int hw_dev_acquisition_stop(int dev_index, void *cb_data)
+static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
+ void *cb_data)
{
struct sr_datafeed_packet packet;
/* Avoid compiler warnings. */
- (void)dev_index;
+ (void)sdi;
sr_dbg("genericdmm: Stopping acquisition.");
.dev_open = hw_dev_open,
.dev_close = hw_dev_close,
.info_get = hw_info_get,
- .dev_status_get = hw_dev_status_get,
.dev_config_set = hw_dev_config_set,
.dev_acquisition_start = hw_dev_acquisition_start,
.dev_acquisition_stop = hw_dev_acquisition_stop,