SR_PRIV struct sr_dev_driver brymen_bm857_driver_info;
static struct sr_dev_driver *di = &brymen_bm857_driver_info;
-static int init(struct sr_context *sr_ctx)
+static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
{
return std_init(sr_ctx, di, LOG_PREFIX);
}
struct sr_dev_inst *sdi;
struct dev_context *devc;
struct drv_context *drvc;
- struct sr_channel *ch;
struct sr_serial_dev_inst *serial;
GSList *devices;
int ret;
uint8_t buf[128];
size_t len;
- if (!(serial = sr_serial_dev_inst_new(conn, serialcomm)))
- return NULL;
+ serial = sr_serial_dev_inst_new(conn, serialcomm);
if (serial_open(serial, SERIAL_RDWR) != SR_OK)
return NULL;
sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("Brymen");
sdi->model = g_strdup("BM85x");
-
- if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
- sr_err("Device context malloc failed.");
- goto scan_cleanup;
- }
-
+ devc = g_malloc0(sizeof(struct dev_context));
sdi->inst_type = SR_INST_SERIAL;
sdi->conn = serial;
drvc = di->priv;
sdi->priv = devc;
sdi->driver = di;
-
- if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
- goto scan_cleanup;
-
- sdi->channels = g_slist_append(sdi->channels, ch);
+ sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
drvc->instances = g_slist_append(drvc->instances, sdi);
devices = g_slist_append(devices, sdi);
return devices;
}
-static GSList *scan(GSList *options)
+static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
struct drv_context *drvc;
struct sr_config *src;
return devices;
}
-static GSList *dev_list(void)
+static GSList *dev_list(const struct sr_dev_driver *di)
{
return ((struct drv_context *)(di->priv))->instances;
}
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
{
return std_dev_clear(di, NULL);
}