X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fsysclk-lwla%2Fapi.c;h=3fe9b2bd0b6f43fc8e8ca39744a13f117c613c79;hb=145d794facd93b182e6c85d7613ce2e6d9a66d48;hp=90d7897dda3dee2f025c07119be0261cea688a39;hpb=aac29cc192ccf82b64e77b5e6b11b411da32deed;p=libsigrok.git diff --git a/src/hardware/sysclk-lwla/api.c b/src/hardware/sysclk-lwla/api.c index 90d7897d..3fe9b2bd 100644 --- a/src/hardware/sysclk-lwla/api.c +++ b/src/hardware/sysclk-lwla/api.c @@ -74,42 +74,20 @@ static const char *const signal_edge_names[] = { "r", "f" }; SR_PRIV struct sr_dev_driver sysclk_lwla_driver_info; static struct sr_dev_driver *const di = &sysclk_lwla_driver_info; -static int init(struct sr_context *sr_ctx) +static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) { return std_init(sr_ctx, di, LOG_PREFIX); } -static GSList *gen_channel_list(int num_channels) -{ - GSList *list; - struct sr_channel *ch; - int i; - char name[8]; - - list = NULL; - - for (i = num_channels; i > 0; --i) { - /* The LWLA series simply number channels from CH1 to CHxx. */ - g_snprintf(name, sizeof(name), "CH%d", i); - - ch = sr_channel_new(i - 1, SR_CHANNEL_LOGIC, TRUE, name); - list = g_slist_prepend(list, ch); - } - - return list; -} - static struct sr_dev_inst *dev_inst_new(void) { struct sr_dev_inst *sdi; struct dev_context *devc; + int i; + char name[8]; /* Allocate memory for our private driver context. */ - devc = g_try_new0(struct dev_context, 1); - if (!devc) { - sr_err("Device context malloc failed."); - return NULL; - } + devc = g_malloc0(sizeof(struct dev_context)); /* Register the device with libsigrok. */ sdi = g_malloc0(sizeof(struct sr_dev_inst)); @@ -122,12 +100,16 @@ static struct sr_dev_inst *dev_inst_new(void) devc->samplerate = DEFAULT_SAMPLERATE; sdi->priv = devc; - sdi->channels = gen_channel_list(NUM_CHANNELS); + for (i = NUM_CHANNELS; i > 0; --i) { + /* The LWLA series simply number channels from CH1 to CHxx. */ + g_snprintf(name, sizeof(name), "CH%d", i); + sr_channel_new(sdi, i - 1, SR_CHANNEL_LOGIC, TRUE, name); + } return sdi; } -static GSList *scan(GSList *options) +static GSList *scan(struct sr_dev_driver *di, GSList *options) { GSList *usb_devices, *devices, *node; struct drv_context *drvc; @@ -172,7 +154,7 @@ static GSList *scan(GSList *options) return devices; } -static GSList *dev_list(void) +static GSList *dev_list(const struct sr_dev_driver *di) { struct drv_context *drvc; @@ -193,7 +175,7 @@ static void clear_dev_context(void *priv) g_free(devc); } -static int dev_clear(void) +static int dev_clear(const struct sr_dev_driver *di) { return std_dev_clear(di, &clear_dev_context); } @@ -261,9 +243,9 @@ static int dev_close(struct sr_dev_inst *sdi) return SR_OK; } -static int cleanup(void) +static int cleanup(const struct sr_dev_driver *di) { - return dev_clear(); + return dev_clear(di); } static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi,