]> sigrok.org Git - sigrok-util.git/blobdiff - source/drv-api.c
sr_hw_info() shouldn't log invalid requests.
[sigrok-util.git] / source / drv-api.c
index dbeea02fc826207e771ed104d85f84228202362c..64f5ee18601abe1d922a00a4a6319b0d9beed092 100644 (file)
@@ -33,7 +33,9 @@ static int clear_instances(void)
        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;
@@ -51,17 +53,18 @@ static int clear_instances(void)
        return SR_OK;
 }
 
-static int hw_init(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;
+               return SR_ERR_MALLOC;
        }
 
        /* TODO */
 
+       drvc->sr_ctx = sr_ctx;
        di->priv = drvc;
 
        return SR_OK;
@@ -121,7 +124,6 @@ static int hw_info_get(int info_id, const void **data,
        switch (info_id) {
        /* TODO */
        default:
-               sr_err("Unknown info_id: %d.", info_id);
                return SR_ERR_ARG;
        }
 
@@ -157,8 +159,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
        return SR_OK;
 }
 
-static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi,
-                                  void *cb_data)
+static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
 {
        (void)cb_data;