]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/motech-lps-30x/api.c
Constify a few arrays and variables.
[libsigrok.git] / src / hardware / motech-lps-30x / api.c
index 9c01ea455077ac8041a75909bba6c59d1e0b846e..0ed6b09b458f56a00a396afaac19e13863a9c077 100644 (file)
@@ -88,7 +88,7 @@ static const char *channel_modes[] = {
        "Track2",
 };
 
-static struct lps_modelspec models[] = {
+static const struct lps_modelspec models[] = {
        { LPS_UNKNOWN, "Dummy", 0,
                {
 
@@ -134,9 +134,9 @@ static struct lps_modelspec models[] = {
        },
 };
 
-static int init_lps301(struct sr_context *sr_ctx)
+static int init_lps301(struct sr_dev_driver *di, struct sr_context *sr_ctx)
 {
-       return std_init(sr_ctx, &motech_lps_301_driver_info, LOG_PREFIX);
+       return std_init(sr_ctx, di, LOG_PREFIX);
 }
 
 /** Send command to device with va_list.
@@ -402,8 +402,7 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
                serialcomm = SERIALCOMM;
 
        /* Init serial port. */
-       if (!(serial = sr_serial_dev_inst_new(conn, serialcomm)))
-               return NULL;
+       serial = sr_serial_dev_inst_new(conn, serialcomm);
 
        if (serial_open(serial, SERIAL_RDWR) != SR_OK)
                goto exit_err;
@@ -442,7 +441,6 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
                        goto exit_err;
                }
 
-
                g_strstrip(buf);
                verstr = buf + 4;
        }
@@ -471,8 +469,7 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o
        /* Setup channels and channel groups. */
        for (cnt = 0; cnt < models[modelid].num_channels; cnt++) {
                snprintf(channel, sizeof(channel), "CH%d", cnt + 1);
-               ch = sr_channel_new(cnt, SR_CHANNEL_ANALOG, TRUE, channel);
-               sdi->channels = g_slist_append(sdi->channels, ch);
+               ch = sr_channel_new(sdi, cnt, SR_CHANNEL_ANALOG, TRUE, channel);
 
                devc->channel_status[cnt].info = g_slist_append(NULL, ch);
 
@@ -514,19 +511,14 @@ exit_err:
 }
 
 /** Scan for LPS-301 device. */
-static GSList *scan_lps301(GSList *options)
-{
-       return do_scan(LPS_301, &motech_lps_301_driver_info, options);
-}
-
-static GSList *doDevList(struct sr_dev_driver *drv)
+static GSList *scan_lps301(struct sr_dev_driver *di, GSList *options)
 {
-       return ((struct drv_context *)(drv->priv))->instances;
+       return do_scan(LPS_301, di, options);
 }
 
-static GSList *dev_list_lps301(void)
+static GSList *dev_list_lps301(const struct sr_dev_driver *di)
 {
-       return doDevList(&motech_lps_301_driver_info);
+       return ((struct drv_context *)(di->priv))->instances;
 }
 
 static void dev_clear_private(struct dev_context* devc)
@@ -540,14 +532,14 @@ static void dev_clear_private(struct dev_context* devc)
        g_timer_destroy(devc->elapsed_msec);
 }
 
-static int dev_clear_lps301(void)
+static int dev_clear_lps301(const struct sr_dev_driver *di)
 {
-       return std_dev_clear(&motech_lps_301_driver_info, (std_dev_clear_callback)dev_clear_private);
+       return std_dev_clear(di, (std_dev_clear_callback)dev_clear_private);
 }
 
-static int cleanup(void)
+static int cleanup(const struct sr_dev_driver *di)
 {
-       return dev_clear_lps301();
+       return dev_clear_lps301(di);
 }
 
 static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,