return ret;
}
+/**
+ * Dummmy driver dev_open() callback API helper.
+ *
+ * @param[in] sdi The device instance to use. May be NULL (unused).
+ *
+ * @retval SR_OK Success.
+ */
+SR_PRIV int std_dummy_dev_open(struct sr_dev_inst *sdi)
+{
+ (void)sdi;
+
+ return SR_OK;
+}
+
+/**
+ * Dummmy driver dev_close() callback API helper.
+ *
+ * @param[in] sdi The device instance to use. May be NULL (unused).
+ *
+ * @retval SR_OK Success.
+ */
+SR_PRIV int std_dummy_dev_close(struct sr_dev_inst *sdi)
+{
+ (void)sdi;
+
+ return SR_OK;
+}
+
+/**
+ * Dummmy driver dev_acquisition_start() callback API helper.
+ *
+ * @param[in] sdi The device instance to use. May be NULL (unused).
+ *
+ * @retval SR_OK Success.
+ */
+SR_PRIV int std_dummy_dev_acquisition_start(const struct sr_dev_inst *sdi)
+{
+ (void)sdi;
+
+ return SR_OK;
+}
+
+/**
+ * Dummmy driver dev_acquisition_stop() callback API helper.
+ *
+ * @param[in] sdi The device instance to use. May be NULL (unused).
+ *
+ * @retval SR_OK Success.
+ */
+SR_PRIV int std_dummy_dev_acquisition_stop(struct sr_dev_inst *sdi)
+{
+ (void)sdi;
+
+ return SR_OK;
+}
+
/**
* Standard API helper for sending an SR_DF_HEADER packet.
*
* This function can be used to implement the dev_clear() driver API
* callback. dev_close() is called before every sr_dev_inst is cleared.
*
- * The only limitation is driver-specific device contexts (sdi->priv).
+ * The only limitation is driver-specific device contexts (sdi->priv / devc).
* These are freed, but any dynamic allocation within structs stored
* there cannot be freed.
*
* @param[in] driver The driver which will have its instances released.
* Must not be NULL.
* @param[in] clear_private If not NULL, this points to a function called
- * with sdi->priv as argument. The function can then clear
+ * with sdi->priv (devc) as argument. The function can then clear
* any device instance-specific resources kept there.
- * It must also clear the struct pointed to by sdi->priv.
+ * It must NOT clear the struct pointed to by sdi->priv (devc),
+ * since this function will always free it after clear_private()
+ * has run.
*
* @retval SR_OK Success.
* @retval SR_ERR_ARG Invalid argument.
* @retval SR_ERR_BUG Implementation bug.
* @retval other Other error.
*/
-SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver,
+SR_PRIV int std_dev_clear_with_callback(const struct sr_dev_driver *driver,
std_dev_clear_callback clear_private)
{
struct drv_context *drvc;
if (sdi->inst_type == SR_INST_MODBUS)
sr_modbus_free(sdi->conn);
}
+
+ /* Clear driver-specific stuff, if any. */
if (clear_private)
- /* The helper function is responsible for freeing
- * its own sdi->priv! */
clear_private(sdi->priv);
- else
- g_free(sdi->priv);
+
+ /* Clear sdi->priv (devc). */
+ g_free(sdi->priv);
sr_dev_inst_free(sdi);
}
return ret;
}
+SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver)
+{
+ return std_dev_clear_with_callback(driver, NULL);
+}
+
/**
* Standard driver dev_list() callback API helper.
*