{
int *hwcaps, i;
+ sr_spew("dev: %s: requesting hwcap %d", __func__, hwcap);
+
if (!dev) {
sr_err("dev: %s: dev was NULL", __func__);
return FALSE; /* TODO: SR_ERR_ARG. */
}
+ /*
+ * Virtual devices (which have dev->driver set to NULL) always say that
+ * they don't have the capability (they can't call hwcap_get_all()).
+ */
if (!dev->driver) {
- sr_err("dev: %s: dev->driver was NULL", __func__);
+ sr_dbg("dev: %s: dev->driver was NULL, this seems to be "
+ "a virtual device without capabilities", __func__);
return FALSE; /* TODO: SR_ERR_ARG. */
}
return SR_ERR_ARG;
}
+ if (!session) {
+ sr_err("session: %s: session was NULL", __func__);
+ return SR_ERR_BUG;
+ }
+
+ /* If dev->driver is NULL, this is a virtual device. */
if (!dev->driver) {
- sr_err("session: %s: dev->driver was NULL", __func__);
- return SR_ERR_ARG;
+ sr_dbg("session: %s: dev->driver was NULL, this seems to be "
+ "a virtual device; continuing", __func__);
+ /* Just add the device, don't run dev_open(). */
+ session->devs = g_slist_append(session->devs, dev);
+ return SR_OK;
}
+ /* dev->driver is non-NULL (i.e. we have a real device). */
if (!dev->driver->dev_open) {
sr_err("session: %s: dev->driver->dev_open was NULL",
__func__);
return SR_ERR_ARG;
}
- if (!session) {
- sr_err("session: %s: session was NULL", __func__);
- return SR_ERR_BUG;
- }
-
if ((ret = dev->driver->dev_open(dev->driver_index)) != SR_OK) {
sr_err("session: %s: dev_open failed (%d)", __func__, ret);
return ret;
return SR_ERR_ARG;
}
- if (!dev->driver) {
- sr_err("session: %s: dev->driver was NULL", __func__);
- return SR_ERR_ARG;
- }
-
if (!packet) {
sr_err("session: %s: packet was NULL", __func__);
return SR_ERR_ARG;