]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/center-3xx/api.c
Drop unneeded std_session_send_df_header() comments.
[libsigrok.git] / src / hardware / center-3xx / api.c
index 13831c05a9af4b7b90e4771a31e2587e5bd78d61..7fe70fa9a8030bc01223d053849973c7eb8dcecc 100644 (file)
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#include <config.h>
 #include "protocol.h"
 
 static const uint32_t scanopts[] = {
@@ -37,7 +38,6 @@ static const uint32_t devopts[] = {
 
 static const char *channel_names[] = {
        "T1", "T2", "T3", "T4",
-       NULL,
 };
 
 SR_PRIV struct sr_dev_driver center_309_driver_info;
@@ -72,17 +72,15 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
        struct sr_dev_inst *sdi;
        struct drv_context *drvc;
        struct dev_context *devc;
-       struct sr_channel *ch;
        struct sr_serial_dev_inst *serial;
        GSList *devices;
 
-       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)
                return NULL;
 
-       drvc = center_devs[idx].di->priv;
+       drvc = center_devs[idx].di->context;
        devices = NULL;
        serial_flush(serial);
 
@@ -92,29 +90,18 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
        sdi->status = SR_ST_INACTIVE;
        sdi->vendor = g_strdup(center_devs[idx].vendor);
        sdi->model = g_strdup(center_devs[idx].device);
-
-       if (!(devc = g_try_malloc0(sizeof(struct dev_context)))) {
-               sr_err("Device context malloc failed.");
-               goto scan_cleanup;
-       }
-
+       devc = g_malloc0(sizeof(struct dev_context));
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
-
        sdi->priv = devc;
        sdi->driver = center_devs[idx].di;
 
-       for (i = 0; i <  center_devs[idx].num_channels; i++) {
-               if (!(ch = sr_channel_new(i, SR_CHANNEL_ANALOG,
-                                          TRUE, channel_names[i])))
-                       goto scan_cleanup;
-               sdi->channels = g_slist_append(sdi->channels, ch);
-       }
+       for (i = 0; i < center_devs[idx].num_channels; i++)
+               sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_names[i]);
 
        drvc->instances = g_slist_append(drvc->instances, sdi);
        devices = g_slist_append(devices, sdi);
 
-scan_cleanup:
        serial_close(serial);
 
        return devices;
@@ -154,7 +141,7 @@ static GSList *scan(GSList *options, int idx)
 
 static GSList *dev_list(int idx)
 {
-       return ((struct drv_context *)(center_devs[idx].di->priv))->instances;
+       return ((struct drv_context *)(center_devs[idx].di->context))->instances;
 }
 
 static int cleanup(int idx)
@@ -231,7 +218,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
        devc->num_samples = 0;
        devc->starttime = g_get_monotonic_time();
 
-       /* Send header packet to the session bus. */
        std_session_send_df_header(cb_data, LOG_PREFIX);
 
        /* Poll every 500ms, or whenever some data comes in. */
@@ -250,15 +236,20 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
 
 /* Driver-specific API function wrappers */
 #define HW_INIT(X) \
-static int init_##X(struct sr_context *sr_ctx) { return init(sr_ctx, X); }
+static int init_##X(struct sr_dev_driver *d, \
+       struct sr_context *sr_ctx) { (void)d; return init(sr_ctx, X); }
 #define HW_CLEANUP(X) \
-static int cleanup_##X(void) { return cleanup(X); }
+static int cleanup_##X(const struct sr_dev_driver *d) { \
+       (void)d; return cleanup(X); }
 #define HW_SCAN(X) \
-static GSList *scan_##X(GSList *options) { return scan(options, X); }
+static GSList *scan_##X(struct sr_dev_driver *d, GSList *options) { \
+       (void)d; return scan(options, X); }
 #define HW_DEV_LIST(X) \
-static GSList *dev_list_##X(void) { return dev_list(X); }
+static GSList *dev_list_##X(const struct sr_dev_driver *d) { \
+       (void)d; return dev_list(X); }
 #define HW_DEV_CLEAR(X) \
-static int dev_clear_##X(void) { return dev_clear(X); }
+static int dev_clear_##X(const struct sr_dev_driver *d) { \
+       (void)d; return dev_clear(X); }
 #define HW_DEV_ACQUISITION_START(X) \
 static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \
 void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); }
@@ -287,7 +278,7 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \
        .dev_close = std_serial_dev_close, \
        .dev_acquisition_start = dev_acquisition_start_##ID_UPPER, \
        .dev_acquisition_stop = dev_acquisition_stop, \
-       .priv = NULL, \
+       .context = NULL, \
 };
 
 DRV(center_309, CENTER_309, "center-309", "Center 309")