]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/hantek-6xxx/api.c
Put driver pointers into special section
[libsigrok.git] / src / hardware / hantek-6xxx / api.c
index 1d600648ce15420124a89da34f32cd537d9d91a4..65b5f04be96c2a44089526f37d21c462a1438d05 100644 (file)
@@ -74,13 +74,12 @@ static const uint64_t vdivs[][2] = {
        VDIV_VALUES
 };
 
-SR_PRIV struct sr_dev_driver hantek_6xxx_driver_info;
-
 static int read_channel(const struct sr_dev_inst *sdi, uint32_t amount);
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi);
 
-static struct sr_dev_inst *hantek_6xxx_dev_new(const struct hantek_6xxx_profile *prof)
+static struct sr_dev_inst *hantek_6xxx_dev_new(struct sr_dev_driver *di,
+       const struct hantek_6xxx_profile *prof)
 {
        struct sr_dev_inst *sdi;
        struct sr_channel *ch;
@@ -93,7 +92,7 @@ static struct sr_dev_inst *hantek_6xxx_dev_new(const struct hantek_6xxx_profile
        sdi->status = SR_ST_INITIALIZING;
        sdi->vendor = g_strdup(prof->vendor);
        sdi->model = g_strdup(prof->model);
-       sdi->driver = &hantek_6xxx_driver_info;
+       sdi->driver = di;
 
        for (i = 0; i < ARRAY_SIZE(channel_names); i++) {
                ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_names[i]);
@@ -163,11 +162,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;
@@ -228,7 +222,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 = hantek_6xxx_dev_new(prof);
+                               sdi = hantek_6xxx_dev_new(di, prof);
                                sdi->connection_id = g_strdup(connection_id);
                                devices = g_slist_append(devices, sdi);
                                devc = sdi->priv;
@@ -247,7 +241,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 = hantek_6xxx_dev_new(prof);
+                               sdi = hantek_6xxx_dev_new(di, prof);
                                sdi->connection_id = g_strdup(connection_id);
                                sdi->status = SR_ST_INACTIVE;
                                devices = g_slist_append(devices, sdi);
@@ -809,11 +803,11 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV struct sr_dev_driver hantek_6xxx_driver_info = {
+static struct sr_dev_driver hantek_6xxx_driver_info = {
        .name = "hantek-6xxx",
        .longname = "Hantek 6xxx",
        .api_version = 1,
-       .init = init,
+       .init = std_init,
        .cleanup = std_cleanup,
        .scan = scan,
        .dev_list = std_dev_list,
@@ -827,3 +821,4 @@ SR_PRIV struct sr_dev_driver hantek_6xxx_driver_info = {
        .dev_acquisition_stop = dev_acquisition_stop,
        .context = NULL,
 };
+SR_REGISTER_DEV_DRIVER(hantek_6xxx_driver_info);