]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/hantek-dso/api.c
Put driver pointers into special section
[libsigrok.git] / src / hardware / hantek-dso / api.c
index ddea80846f80011f5e45257b2a0409bfcdbfdf31..275bbf99d5f7775bf72ecbf1b5990764e9e29208 100644 (file)
@@ -52,7 +52,7 @@ static const uint32_t drvopts[] = {
 };
 
 static const uint32_t devopts[] = {
-       SR_CONF_CONTINUOUS | SR_CONF_SET,
+       SR_CONF_CONTINUOUS,
        SR_CONF_LIMIT_FRAMES | SR_CONF_SET,
        SR_CONF_CONN | SR_CONF_GET,
        SR_CONF_TIMEBASE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
@@ -160,11 +160,10 @@ static const char *coupling[] = {
        "GND",
 };
 
-SR_PRIV struct sr_dev_driver hantek_dso_driver_info;
-
 static int dev_acquisition_stop(struct sr_dev_inst *sdi);
 
-static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
+static struct sr_dev_inst *dso_dev_new(struct sr_dev_driver *di,
+       const struct dso_profile *prof)
 {
        struct sr_dev_inst *sdi;
        struct sr_channel *ch;
@@ -177,7 +176,7 @@ static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
        sdi->status = SR_ST_INITIALIZING;
        sdi->vendor = g_strdup(prof->vendor);
        sdi->model = g_strdup(prof->model);
-       sdi->driver = &hantek_dso_driver_info;
+       sdi->driver = di;
 
        /*
         * Add only the real channels -- EXT isn't a source of data, only
@@ -209,7 +208,7 @@ static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
        devc->triggersource = g_strdup(DEFAULT_TRIGGER_SOURCE);
        devc->triggerposition = DEFAULT_HORIZ_TRIGGERPOS;
        sdi->priv = devc;
-       drvc = hantek_dso_driver_info.context;
+       drvc = di->context;
        drvc->instances = g_slist_append(drvc->instances, sdi);
 
        return sdi;
@@ -254,11 +253,6 @@ static int dev_clear(const struct sr_dev_driver *di)
        return std_dev_clear(di, clear_dev_context);
 }
 
-static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx)
-{
-       return std_init(sr_ctx, di, LOG_PREFIX);
-}
-
 static GSList *scan(struct sr_dev_driver *di, GSList *options)
 {
        struct drv_context *drvc;
@@ -319,7 +313,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                                /* Device matches the pre-firmware profile. */
                                prof = &dev_profiles[j];
                                sr_dbg("Found a %s %s.", prof->vendor, prof->model);
-                               sdi = dso_dev_new(prof);
+                               sdi = dso_dev_new(di, prof);
                                sdi->connection_id = g_strdup(connection_id);
                                devices = g_slist_append(devices, sdi);
                                devc = sdi->priv;
@@ -338,7 +332,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
                                /* Device matches the post-firmware profile. */
                                prof = &dev_profiles[j];
                                sr_dbg("Found a %s %s.", prof->vendor, prof->model);
-                               sdi = dso_dev_new(prof);
+                               sdi = dso_dev_new(di, prof);
                                sdi->connection_id = g_strdup(connection_id);
                                sdi->status = SR_ST_INACTIVE;
                                devices = g_slist_append(devices, sdi);
@@ -1000,11 +994,11 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver hantek_dso_driver_info = {
+static struct sr_dev_driver hantek_dso_driver_info = {
        .name = "hantek-dso",
        .longname = "Hantek DSO",
        .api_version = 1,
-       .init = init,
+       .init = std_init,
        .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = std_dev_list,
@@ -1018,3 +1012,4 @@ SR_PRIV struct sr_dev_driver hantek_dso_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(hantek_dso_driver_info);