]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/uni-t-dmm/api.c
Simplify channel creation.
[libsigrok.git] / src / hardware / uni-t-dmm / api.c
index 35ceaaed4a12c5bc64535037911edd99c2199dea..f7b8a94106b46cb2a9faecac4a4c207c4216daf1 100644 (file)
@@ -38,6 +38,7 @@ static const uint32_t devopts[] = {
 };
 
 SR_PRIV struct sr_dev_driver tecpel_dmm_8061_driver_info;
+SR_PRIV struct sr_dev_driver uni_t_ut372_driver_info;
 SR_PRIV struct sr_dev_driver uni_t_ut60a_driver_info;
 SR_PRIV struct sr_dev_driver uni_t_ut60e_driver_info;
 SR_PRIV struct sr_dev_driver uni_t_ut60g_driver_info;
@@ -67,6 +68,13 @@ SR_PRIV struct dmm_info udmms[] = {
                sr_fs9721_00_temp_c,
                &tecpel_dmm_8061_driver_info, receive_data_TECPEL_DMM_8061,
        },
+       {
+               "UNI-T", "UT372", 2400,
+               UT372_PACKET_SIZE,
+               sr_ut372_packet_valid, sr_ut372_parse,
+               NULL,
+               &uni_t_ut372_driver_info, receive_data_UNI_T_UT372,
+       },
        {
                "UNI-T", "UT60A", 2400,
                FS9721_PACKET_SIZE,
@@ -227,7 +235,6 @@ static GSList *scan(GSList *options, int dmm)
        struct drv_context *drvc;
        struct sr_usb_dev_inst *usb;
        struct sr_config *src;
-       struct sr_channel *ch;
        const char *conn;
 
        drvc = udmms[dmm].di->priv;
@@ -252,27 +259,17 @@ static GSList *scan(GSList *options, int dmm)
 
        for (l = usb_devices; l; l = l->next) {
                usb = l->data;
-
-               if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-                       sr_err("Device context malloc failed.");
-                       return NULL;
-               }
-
+               devc = g_malloc0(sizeof(struct dev_context));
                devc->first_run = TRUE;
-
-               sdi = sr_dev_inst_new();
+               sdi = g_malloc0(sizeof(struct sr_dev_inst));
                sdi->status = SR_ST_INACTIVE;
                sdi->vendor = g_strdup(udmms[dmm].vendor);
                sdi->model = g_strdup(udmms[dmm].device);
                sdi->priv = devc;
                sdi->driver = udmms[dmm].di;
-               if (!(ch = sr_channel_new(0, SR_CHANNEL_ANALOG, TRUE, "P1")))
-                       return NULL;
-               sdi->channels = g_slist_append(sdi->channels, ch);
-
+               sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "P1");
                sdi->inst_type = SR_INST_USB;
                sdi->conn = usb;
-
                drvc->instances = g_slist_append(drvc->instances, sdi);
                devices = g_slist_append(devices, sdi);
        }
@@ -455,6 +452,7 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \
 };
 
 DRV(tecpel_dmm_8061, TECPEL_DMM_8061, "tecpel-dmm-8061", "Tecpel DMM-8061")
+DRV(uni_t_ut372, UNI_T_UT372, "uni-t-ut372", "UNI-T UT372")
 DRV(uni_t_ut60a, UNI_T_UT60A, "uni-t-ut60a", "UNI-T UT60A")
 DRV(uni_t_ut60e, UNI_T_UT60E, "uni-t-ut60e", "UNI-T UT60E")
 DRV(uni_t_ut60g, UNI_T_UT60G, "uni-t-ut60g", "UNI-T UT60G")