#include "libsigrok-internal.h"
#include "protocol.h"
-SR_PRIV struct sr_dev_driver driver_info;
+SR_PRIV struct sr_dev_driver ${lib}_driver_info;
static struct sr_dev_driver *di = &${lib}_driver_info;
/* Properly close and free all devices. */
struct dev_context *devc;
GSList *l;
- drvc = di->priv;
+ if (!(drvc = di->priv))
+ return SR_OK;
+
for (l = drvc->instances; l; l = l->next) {
if (!(sdi = l->data))
continue;
if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
sr_err("Driver context malloc failed.");
- return SR_ERR;
+ return SR_ERR_MALLOC;
}
/* TODO */