]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/hantek-6xxx/api.c
manson-hcs-3xxx: Convert to SR_DF_ANALOG.
[libsigrok.git] / src / hardware / hantek-6xxx / api.c
index 1d600648ce15420124a89da34f32cd537d9d91a4..27eacf4a2802c8267a9d7b8738a4fc9c67409232 100644 (file)
@@ -74,8 +74,6 @@ 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);
@@ -85,7 +83,6 @@ static struct sr_dev_inst *hantek_6xxx_dev_new(const struct hantek_6xxx_profile
        struct sr_dev_inst *sdi;
        struct sr_channel *ch;
        struct sr_channel_group *cg;
-       struct drv_context *drvc;
        struct dev_context *devc;
        unsigned int i;
 
@@ -93,7 +90,6 @@ 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;
 
        for (i = 0; i < ARRAY_SIZE(channel_names); i++) {
                ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_names[i]);
@@ -120,8 +116,6 @@ static struct sr_dev_inst *hantek_6xxx_dev_new(const struct hantek_6xxx_profile
        devc->samplerate = DEFAULT_SAMPLERATE;
 
        sdi->priv = devc;
-       drvc = sdi->driver->context;
-       drvc->instances = g_slist_append(drvc->instances, sdi);
 
        return sdi;
 }
@@ -163,11 +157,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;
@@ -264,7 +253,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        }
        libusb_free_device_list(devlist, 1);
 
-       return devices;
+       return std_scan_complete(di, devices);
 }
 
 static int dev_open(struct sr_dev_inst *sdi)
@@ -750,7 +739,7 @@ static int handle_event(int fd, int revents, void *cb_data)
                 */
                usb_source_remove(sdi->session, drvc->sr_ctx);
 
-               std_session_send_df_end(sdi, LOG_PREFIX);
+               std_session_send_df_end(sdi);
 
                devc->dev_state = IDLE;
 
@@ -779,7 +768,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        if (hantek_6xxx_init(sdi) != SR_OK)
                return SR_ERR;
 
-       std_session_send_df_header(sdi, LOG_PREFIX);
+       std_session_send_df_header(sdi);
 
        devc->samp_received = 0;
        devc->dev_state = FLUSH;
@@ -809,11 +798,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 +816,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);