]> sigrok.org Git - libsigrok.git/blobdiff - session.c
sr: fx2lafw: Forgot to add (C) line to fx2lafw.h in recent commit.
[libsigrok.git] / session.c
index 8687f4329917846c1b9d155c01f71650ba66d5d1..f1a8370bf48784641973a978ae5ba45a28f110bb 100644 (file)
--- a/session.c
+++ b/session.c
@@ -97,7 +97,7 @@ SR_API int sr_session_destroy(void)
  *
  * @return SR_OK upon success, SR_ERR_BUG if no session exists.
  */
-SR_API int sr_session_dev_clear(void)
+SR_API int sr_session_dev_remove_all(void)
 {
        if (!session) {
                sr_err("session: %s: session was NULL", __func__);
@@ -127,19 +127,24 @@ SR_API int sr_session_dev_add(struct sr_dev *dev)
                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;
        }
 
@@ -154,11 +159,11 @@ SR_API int sr_session_dev_add(struct sr_dev *dev)
 }
 
 /**
- * Clear all datafeed callbacks in the current session.
+ * Remove all datafeed callbacks in the current session.
  *
  * @return SR_OK upon success, SR_ERR_BUG if no session exists.
  */
-SR_API int sr_session_datafeed_callback_clear(void)
+SR_API int sr_session_datafeed_callback_remove_all(void)
 {
        if (!session) {
                sr_err("session: %s: session was NULL", __func__);
@@ -438,11 +443,6 @@ SR_PRIV int sr_session_send(struct sr_dev *dev,
                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;