]> sigrok.org Git - libsigrok.git/blobdiff - hardware/demo/demo.c
serial-dmm: Drop unneeded g_try_malloc0().
[libsigrok.git] / hardware / demo / demo.c
index 345468c41be550174350ecd2ea4b7984edf37499..be989fe70cca85fd4b1cade5b8aff44752cd0b30 100644 (file)
@@ -94,10 +94,10 @@ static const int hwcaps[] = {
 };
 
 static const struct sr_samplerates samplerates = {
-       SR_HZ(1),
-       SR_GHZ(1),
-       SR_HZ(1),
-       NULL,
+       .low  = SR_HZ(1),
+       .high = SR_GHZ(1),
+       .step = SR_HZ(1),
+       .list = NULL,
 };
 
 static const char *pattern_strings[] = {
@@ -148,16 +148,7 @@ static int clear_instances(void)
 
 static int hw_init(struct sr_context *sr_ctx)
 {
-       struct drv_context *drvc;
-
-       if (!(drvc = g_try_malloc0(sizeof(struct drv_context)))) {
-               sr_err("Driver context malloc failed.");
-               return SR_ERR_MALLOC;
-       }
-       drvc->sr_ctx = sr_ctx;
-       di->priv = drvc;
-
-       return SR_OK;
+       return std_hw_init(sr_ctx, di, DRIVER_LOG_DOMAIN);
 }
 
 static GSList *hw_scan(GSList *options)
@@ -171,6 +162,7 @@ static GSList *hw_scan(GSList *options)
        (void)options;
 
        drvc = di->priv;
+
        devices = NULL;
 
        sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, DEMONAME, NULL, NULL);
@@ -231,9 +223,6 @@ static int config_get(int id, const void **data, const struct sr_dev_inst *sdi)
        (void)sdi;
 
        switch (id) {
-       case SR_DI_HWCAPS:
-               *data = hwcaps;
-               break;
        case SR_CONF_SAMPLERATE:
                *data = &cur_samplerate;
                break;
@@ -298,6 +287,9 @@ static int config_list(int key, const void **data, const struct sr_dev_inst *sdi
        (void)sdi;
 
        switch (key) {
+       case SR_CONF_DEVICE_OPTIONS:
+               *data = hwcaps;
+               break;
        case SR_CONF_SAMPLERATE:
                *data = &samplerates;
                break;