}
/* Returns the next enabled channel, wrapping around if necessary. */
+/** @private */
SR_PRIV struct sr_channel *sr_next_enabled_channel(const struct sr_dev_inst *sdi,
+
struct sr_channel *cur_channel)
{
struct sr_channel *next_channel;
/**
* Free struct sr_usb_dev_inst * allocated by sr_usb_dev_inst().
*
- * @param usb The struct sr_usb_dev_inst * to free. Must not be NULL.
+ * @param usb The struct sr_usb_dev_inst * to free. If NULL, this
+ * function does nothing.
*
* @private
*/
/**
* Free struct sr_serial_dev_inst * allocated by sr_serial_dev_inst().
*
- * @param serial The struct sr_serial_dev_inst * to free. Must not be NULL.
+ * @param serial The struct sr_serial_dev_inst * to free. If NULL, this
+ * function will do nothing.
*
* @private
*/
SR_PRIV void sr_serial_dev_inst_free(struct sr_serial_dev_inst *serial)
{
+ if (!serial)
+ return;
+
g_free(serial->port);
g_free(serial->serialcomm);
g_free(serial);
/** @private */
SR_PRIV void sr_usbtmc_dev_inst_free(struct sr_usbtmc_dev_inst *usbtmc)
{
+ if (!usbtmc)
+ return;
+
g_free(usbtmc->device);
g_free(usbtmc);
}
if (!sdi || !sdi->driver || !sdi->driver->dev_close)
return SR_ERR;
+ if (sdi->status != SR_ST_ACTIVE) {
+ sr_err("%s: Device instance not active, can't close.",
+ sdi->driver->name);
+ return SR_ERR_DEV_CLOSED;
+ }
+
+ sr_dbg("%s: Closing device.", sdi->driver->name)
+
ret = sdi->driver->dev_close(sdi);
return ret;