X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Ffx2lafw%2Fapi.c;h=ab3345f32cc81db6758261e48e1cd5423867b554;hb=94b138a3c3d07cf5581c07536c53a97cebf885d9;hp=1fb2235f1e57bedf1ed61c216eaf0ce6361a94ae;hpb=4f840ce965b1c30c5ab75afecc56193cbaf5c1b3;p=libsigrok.git diff --git a/src/hardware/fx2lafw/api.c b/src/hardware/fx2lafw/api.c index 1fb2235f..ab3345f3 100644 --- a/src/hardware/fx2lafw/api.c +++ b/src/hardware/fx2lafw/api.c @@ -106,9 +106,8 @@ static const uint32_t devopts[] = { }; static const char *channel_names[] = { - "0", "1", "2", "3", "4", "5", "6", "7", - "8", "9", "10", "11", "12", "13", "14", "15", - NULL, + "0", "1", "2", "3", "4", "5", "6", "7", + "8", "9", "10", "11", "12", "13", "14", "15", }; static const int32_t soft_trigger_matches[] = { @@ -427,7 +426,7 @@ static int dev_close(struct sr_dev_inst *sdi) struct sr_usb_dev_inst *usb; usb = sdi->conn; - if (usb->devhdl == NULL) + if (!usb->devhdl) return SR_ERR; sr_info("fx2lafw: Closing device on %d.%d (logical) / %s (physical) interface %d.", @@ -518,30 +517,30 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd ret = SR_OK; switch (key) { - case SR_CONF_SAMPLERATE: - arg = g_variant_get_uint64(data); - for (i = 0; i < ARRAY_SIZE(samplerates); i++) { - if (samplerates[i] == arg) { - devc->cur_samplerate = arg; - break; - } + case SR_CONF_SAMPLERATE: + arg = g_variant_get_uint64(data); + for (i = 0; i < ARRAY_SIZE(samplerates); i++) { + if (samplerates[i] == arg) { + devc->cur_samplerate = arg; + break; } - if (i == ARRAY_SIZE(samplerates)) - ret = SR_ERR_ARG; - break; - case SR_CONF_LIMIT_SAMPLES: - devc->limit_samples = g_variant_get_uint64(data); - break; - case SR_CONF_CAPTURE_RATIO: - devc->capture_ratio = g_variant_get_uint64(data); - if (devc->capture_ratio > 100) { - devc->capture_ratio = 0; - ret = SR_ERR; - } else - ret = SR_OK; - break; - default: - ret = SR_ERR_NA; + } + if (i == ARRAY_SIZE(samplerates)) + ret = SR_ERR_ARG; + break; + case SR_CONF_LIMIT_SAMPLES: + devc->limit_samples = g_variant_get_uint64(data); + break; + case SR_CONF_CAPTURE_RATIO: + devc->capture_ratio = g_variant_get_uint64(data); + if (devc->capture_ratio > 100) { + devc->capture_ratio = 0; + ret = SR_ERR; + } else + ret = SR_OK; + break; + default: + ret = SR_ERR_NA; } return ret; @@ -598,9 +597,8 @@ static int receive_data(int fd, int revents, void *cb_data) (void)fd; (void)revents; - (void)cb_data; - drvc = (struct drv_context *) cb_data; + drvc = (struct drv_context *)cb_data; tv.tv_sec = tv.tv_usec = 0; libusb_handle_events_timeout(drvc->sr_ctx->libusb_ctx, &tv); @@ -631,7 +629,7 @@ static int start_transfers(const struct sr_dev_inst *sdi) if (devc->limit_samples > 0) pre_trigger_samples = devc->capture_ratio * devc->limit_samples/100; devc->stl = soft_trigger_logic_new(sdi, trigger, pre_trigger_samples); - if (devc->stl == NULL) + if (!devc->stl) return SR_ERR_MALLOC; devc->trigger_fired = FALSE; } else @@ -679,7 +677,7 @@ static int start_transfers(const struct sr_dev_inst *sdi) return SR_OK; } -static void dslogic_trigger_receive(struct libusb_transfer *transfer) +static void LIBUSB_CALL dslogic_trigger_receive(struct libusb_transfer *transfer) { const struct sr_dev_inst *sdi; struct dslogic_trigger_pos *tpos;