A device is opened when it is added to a session, in the same fashion it should
be closed again when it is removed from a session.
Also remove all still attached devices from a session when the session is
destroyed.
Signed-off-by: Lars-Peter Clausen <redacted>
return SR_ERR_BUG;
}
- g_slist_free(session->devs);
- session->devs = NULL;
+ sr_session_dev_remove_all();
/* TODO: Error checks needed? */
return SR_OK;
}
+static void sr_dev_close(struct sr_dev *dev)
+{
+ if (dev->driver->dev_close)
+ dev->driver->dev_close(dev->driver_index);
+}
+
/**
* Remove all the devices from the current session. TODO?
*
return SR_ERR_BUG;
}
- g_slist_free(session->devs);
+ g_slist_free_full(session->devs, (GDestroyNotify)sr_dev_close);
session->devs = NULL;
return SR_OK;