From: Uwe Hermann Date: Fri, 17 Feb 2012 20:02:52 +0000 (+0100) Subject: sr: Some more s/device_instance/dev_inst/. X-Git-Tag: libsigrok-0.1.0~116 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d68e2d1a21ac5c3f24d88b7689f98764e4d57c30;p=libsigrok.git sr: Some more s/device_instance/dev_inst/. --- diff --git a/hardware/alsa/alsa.c b/hardware/alsa/alsa.c index ffd6778d..5842fdb8 100644 --- a/hardware/alsa/alsa.c +++ b/hardware/alsa/alsa.c @@ -54,7 +54,7 @@ static const char *probe_names[NUM_PROBES + 1] = { NULL, }; -static GSList *device_instances = NULL; +static GSList *dev_insts = NULL; struct alsa { uint64_t cur_rate; @@ -66,7 +66,7 @@ struct alsa { static int hw_init(const char *deviceinfo) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct alsa *alsa; /* Avoid compiler warnings. */ @@ -83,7 +83,7 @@ static int hw_init(const char *deviceinfo) sdi->priv = alsa; - device_instances = g_slist_append(device_instances, sdi); + dev_insts = g_slist_append(dev_insts, sdi); return 1; free_alsa: @@ -93,11 +93,11 @@ free_alsa: static int hw_opendev(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct alsa *alsa; int err; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return SR_ERR; alsa = sdi->priv; @@ -128,10 +128,10 @@ static int hw_opendev(int device_index) static int hw_closedev(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct alsa *alsa; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("alsa: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -152,9 +152,9 @@ static int hw_closedev(int device_index) static int hw_cleanup(void) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; - if (!(sdi = sr_dev_inst_get(device_instances, 0))) { + if (!(sdi = sr_dev_inst_get(dev_insts, 0))) { sr_err("alsa: %s: sdi was NULL", __func__); return SR_ERR_BUG; } @@ -166,11 +166,11 @@ static int hw_cleanup(void) static void *hw_get_device_info(int device_index, int device_info_id) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct alsa *alsa; void *info = NULL; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return NULL; alsa = sdi->priv; @@ -210,10 +210,10 @@ static int *hw_get_capabilities(void) static int hw_set_configuration(int device_index, int capability, void *value) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct alsa *alsa; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return SR_ERR; alsa = sdi->priv; @@ -233,7 +233,7 @@ static int hw_set_configuration(int device_index, int capability, void *value) static int receive_data(int fd, int revents, void *user_data) { - struct sr_device_instance *sdi = user_data; + struct sr_dev_inst *sdi = user_data; struct alsa *alsa = sdi->priv; struct sr_datafeed_packet packet; struct sr_analog_sample *sample; @@ -291,7 +291,7 @@ static int receive_data(int fd, int revents, void *user_data) static int hw_start_acquisition(int device_index, gpointer session_device_id) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct alsa *alsa; struct sr_datafeed_packet packet; struct sr_datafeed_header header; @@ -299,7 +299,7 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id) int count; int err; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return SR_ERR; alsa = sdi->priv; diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index d2a7b6e8..9f85d5f7 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -41,7 +41,7 @@ #define TRIGGER_TYPES "rf10" #define NUM_PROBES 16 -static GSList *device_instances = NULL; +static GSList *dev_insts = NULL; static uint64_t supported_samplerates[] = { SR_KHZ(200), @@ -417,7 +417,7 @@ static int bin2bitbang(const char *filename, static int hw_init(const char *deviceinfo) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct sigma *sigma; /* Avoid compiler warnings. */ @@ -445,14 +445,15 @@ static int hw_init(const char *deviceinfo) sigma->use_triggers = 0; /* Register SIGMA device. */ - sdi = sr_dev_inst_new(0, SR_ST_INITIALIZING, - USB_VENDOR_NAME, USB_MODEL_NAME, USB_MODEL_VERSION); - if (!sdi) + if (!(sdi = sr_dev_inst_new(0, SR_ST_INITIALIZING, USB_VENDOR_NAME, + USB_MODEL_NAME, USB_MODEL_VERSION))) { + sr_err("sigma: %s: sdi was NULL", __func__); goto free; + } sdi->priv = sigma; - device_instances = g_slist_append(device_instances, sdi); + dev_insts = g_slist_append(dev_insts, sdi); /* We will open the device again when we need it. */ ftdi_usb_close(&sigma->ftdic); @@ -556,11 +557,11 @@ static int upload_firmware(int firmware_idx, struct sigma *sigma) static int hw_opendev(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct sigma *sigma; int ret; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return SR_ERR; sigma = sdi->priv; @@ -580,8 +581,7 @@ static int hw_opendev(int device_index) return SR_OK; } -static int set_samplerate(struct sr_device_instance *sdi, - uint64_t samplerate) +static int set_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate) { int i, ret; struct sigma *sigma = sdi->priv; @@ -624,7 +624,7 @@ static int set_samplerate(struct sr_device_instance *sdi, * The Sigma supports complex triggers using boolean expressions, but this * has not been implemented yet. */ -static int configure_probes(struct sr_device_instance *sdi, GSList *probes) +static int configure_probes(struct sr_dev_inst *sdi, GSList *probes) { struct sigma *sigma = sdi->priv; struct sr_probe *probe; @@ -700,10 +700,10 @@ static int configure_probes(struct sr_device_instance *sdi, GSList *probes) static int hw_closedev(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct sigma *sigma; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("sigma: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -725,11 +725,11 @@ static int hw_closedev(int device_index) static int hw_cleanup(void) { GSList *l; - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; int ret = SR_OK; /* Properly close all devices. */ - for (l = device_instances; l; l = l->next) { + for (l = dev_insts; l; l = l->next) { if (!(sdi = l->data)) { /* Log error, but continue cleaning up the rest. */ sr_err("sigma: %s: sdi was NULL, continuing", __func__); @@ -738,19 +738,19 @@ static int hw_cleanup(void) } sr_dev_inst_free(sdi); } - g_slist_free(device_instances); - device_instances = NULL; + g_slist_free(dev_insts); + dev_insts = NULL; return ret; } static void *hw_get_device_info(int device_index, int device_info_id) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct sigma *sigma; void *info = NULL; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("sigma: %s: sdi was NULL", __func__); return NULL; } @@ -783,9 +783,9 @@ static void *hw_get_device_info(int device_index, int device_info_id) static int hw_get_status(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; - sdi = sr_dev_inst_get(device_instances, device_index); + sdi = sr_dev_inst_get(dev_insts, device_index); if (sdi) return sdi->status; else @@ -799,11 +799,11 @@ static int *hw_get_capabilities(void) static int hw_set_configuration(int device_index, int capability, void *value) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct sigma *sigma; int ret; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return SR_ERR; sigma = sdi->priv; @@ -875,7 +875,7 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts, uint16_t *lastsample, int triggerpos, uint16_t limit_chunk, void *session_data) { - struct sr_device_instance *sdi = session_data; + struct sr_dev_inst *sdi = session_data; struct sigma *sigma = sdi->priv; uint16_t tsdiff, ts; uint16_t samples[65536 * sigma->samples_per_event]; @@ -1006,7 +1006,7 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts, static int receive_data(int fd, int revents, void *session_data) { - struct sr_device_instance *sdi = session_data; + struct sr_dev_inst *sdi = session_data; struct sigma *sigma = sdi->priv; struct sr_datafeed_packet packet; const int chunks_per_read = 32; @@ -1254,7 +1254,7 @@ static int build_basic_trigger(struct triggerlut *lut, struct sigma *sigma) static int hw_start_acquisition(int device_index, gpointer session_data) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct sigma *sigma; struct sr_datafeed_packet packet; struct sr_datafeed_header header; @@ -1267,7 +1267,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data) /* Avoid compiler warnings. */ (void)session_data; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return SR_ERR; sigma = sdi->priv; @@ -1371,14 +1371,14 @@ static int hw_start_acquisition(int device_index, gpointer session_data) static int hw_stop_acquisition(int device_index, gpointer session_data) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct sigma *sigma; uint8_t modestatus; /* Avoid compiler warnings. */ (void)session_data; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("sigma: %s: sdi was NULL", __func__); return SR_ERR_BUG; } diff --git a/hardware/chronovu-la8/chronovu-la8.c b/hardware/chronovu-la8/chronovu-la8.c index 6d639af7..22164cfe 100644 --- a/hardware/chronovu-la8/chronovu-la8.c +++ b/hardware/chronovu-la8/chronovu-la8.c @@ -40,7 +40,7 @@ #define BS 4096 /* Block size */ #define NUM_BLOCKS 2048 /* Number of blocks */ -static GSList *device_instances = NULL; +static GSList *dev_insts = NULL; static const char *probe_names[NUM_PROBES + 1] = { "0", @@ -470,7 +470,7 @@ static int configure_probes(struct la8 *la8, GSList *probes) static int hw_init(const char *deviceinfo) { int ret; - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct la8 *la8; /* Avoid compiler errors. */ @@ -522,13 +522,13 @@ static int hw_init(const char *deviceinfo) sdi = sr_dev_inst_new(0, SR_ST_INITIALIZING, USB_VENDOR_NAME, USB_MODEL_NAME, USB_MODEL_VERSION); if (!sdi) { - sr_err("la8: %s: sr_device_instance_new failed", __func__); + sr_err("la8: %s: sr_dev_inst_new failed", __func__); goto err_close_ftdic; } sdi->priv = la8; - device_instances = g_slist_append(device_instances, sdi); + dev_insts = g_slist_append(dev_insts, sdi); sr_spew("la8: %s finished successfully", __func__); @@ -553,10 +553,10 @@ err_free_nothing: static int hw_opendev(int device_index) { int ret; - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct la8 *la8; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("la8: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -608,7 +608,7 @@ err_opendev_close_ftdic: return SR_ERR; } -static int set_samplerate(struct sr_device_instance *sdi, uint64_t samplerate) +static int set_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate) { struct la8 *la8; @@ -640,10 +640,10 @@ static int set_samplerate(struct sr_device_instance *sdi, uint64_t samplerate) static int hw_closedev(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct la8 *la8; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("la8: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -674,11 +674,11 @@ static int hw_closedev(int device_index) static int hw_cleanup(void) { GSList *l; - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; int ret = SR_OK; /* Properly close all devices. */ - for (l = device_instances; l; l = l->next) { + for (l = dev_insts; l; l = l->next) { if (!(sdi = l->data)) { /* Log error, but continue cleaning up the rest. */ sr_err("la8: %s: sdi was NULL, continuing", __func__); @@ -687,21 +687,21 @@ static int hw_cleanup(void) } sr_dev_inst_free(sdi); /* Returns void. */ } - g_slist_free(device_instances); /* Returns void. */ - device_instances = NULL; + g_slist_free(dev_insts); /* Returns void. */ + dev_insts = NULL; return ret; } static void *hw_get_device_info(int device_index, int device_info_id) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct la8 *la8; void *info; sr_spew("la8: entering %s", __func__); - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("la8: %s: sdi was NULL", __func__); return NULL; } @@ -743,9 +743,9 @@ static void *hw_get_device_info(int device_index, int device_info_id) static int hw_get_status(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("la8: %s: sdi was NULL, device not found", __func__); return SR_ST_NOT_FOUND; } @@ -764,12 +764,12 @@ static int *hw_get_capabilities(void) static int hw_set_configuration(int device_index, int capability, void *value) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct la8 *la8; sr_spew("la8: entering %s", __func__); - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("la8: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -970,7 +970,7 @@ static void send_block_to_session_bus(struct la8 *la8, int block) static int receive_data(int fd, int revents, void *session_data) { int i, ret; - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct la8 *la8; /* Avoid compiler errors. */ @@ -1014,7 +1014,7 @@ static int receive_data(int fd, int revents, void *session_data) static int hw_start_acquisition(int device_index, gpointer session_data) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct la8 *la8; struct sr_datafeed_packet packet; struct sr_datafeed_header header; @@ -1023,7 +1023,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data) sr_spew("la8: entering %s", __func__); - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("la8: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -1089,13 +1089,13 @@ static int hw_start_acquisition(int device_index, gpointer session_data) static int hw_stop_acquisition(int device_index, gpointer session_data) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct la8 *la8; struct sr_datafeed_packet packet; sr_dbg("la8: stopping acquisition"); - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("la8: %s: sdi was NULL", __func__); return SR_ERR_BUG; } diff --git a/hardware/demo/demo.c b/hardware/demo/demo.c index ae473627..d6e149de 100644 --- a/hardware/demo/demo.c +++ b/hardware/demo/demo.c @@ -125,8 +125,8 @@ static uint8_t pattern_sigrok[] = { 0xbe, 0xbe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; -/* List of struct sr_device_instance, maintained by opendev()/closedev(). */ -static GSList *device_instances = NULL; +/* List of struct sr_dev_inst, maintained by opendev()/closedev(). */ +static GSList *dev_insts = NULL; static uint64_t cur_samplerate = SR_KHZ(200); static uint64_t limit_samples = 0; static uint64_t limit_msec = 0; @@ -138,18 +138,18 @@ static int hw_stop_acquisition(int device_index, gpointer session_data); static int hw_init(const char *deviceinfo) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; /* Avoid compiler warnings. */ (void)deviceinfo; sdi = sr_dev_inst_new(0, SR_ST_ACTIVE, DEMONAME, NULL, NULL); if (!sdi) { - sr_err("demo: %s: sr_device_instance_new failed", __func__); + sr_err("demo: %s: sr_dev_inst_new failed", __func__); return 0; } - device_instances = g_slist_append(device_instances, sdi); + dev_insts = g_slist_append(dev_insts, sdi); return 1; } @@ -182,10 +182,10 @@ static int hw_cleanup(void) static void *hw_get_device_info(int device_index, int device_info_id) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; void *info = NULL; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("demo: %s: sdi was NULL", __func__); return NULL; } diff --git a/hardware/link-mso19/link-mso19.c b/hardware/link-mso19/link-mso19.c index f663fe35..5b4b4cff 100644 --- a/hardware/link-mso19/link-mso19.c +++ b/hardware/link-mso19/link-mso19.c @@ -91,10 +91,10 @@ static struct sr_samplerates samplerates = { supported_samplerates, }; -static GSList *device_instances = NULL; +static GSList *dev_insts = NULL; -static int mso_send_control_message(struct sr_device_instance *sdi, - uint16_t payload[], int n) +static int mso_send_control_message(struct sr_dev_inst *sdi, + uint16_t payload[], int n) { int fd = sdi->serial->fd; int i, w, ret, s = n * 2 + sizeof(mso_head) + sizeof(mso_foot); @@ -137,7 +137,7 @@ ret: return ret; } -static int mso_reset_adc(struct sr_device_instance *sdi) +static int mso_reset_adc(struct sr_dev_inst *sdi) { struct mso *mso = sdi->priv; uint16_t ops[2]; @@ -150,7 +150,7 @@ static int mso_reset_adc(struct sr_device_instance *sdi) return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops)); } -static int mso_reset_fsm(struct sr_device_instance *sdi) +static int mso_reset_fsm(struct sr_dev_inst *sdi) { struct mso *mso = sdi->priv; uint16_t ops[1]; @@ -162,7 +162,7 @@ static int mso_reset_fsm(struct sr_device_instance *sdi) return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops)); } -static int mso_toggle_led(struct sr_device_instance *sdi, int state) +static int mso_toggle_led(struct sr_dev_inst *sdi, int state) { struct mso *mso = sdi->priv; uint16_t ops[1]; @@ -176,8 +176,7 @@ static int mso_toggle_led(struct sr_device_instance *sdi, int state) return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops)); } -static int mso_check_trigger(struct sr_device_instance *sdi, - uint8_t *info) +static int mso_check_trigger(struct sr_dev_inst *sdi, uint8_t *info) { uint16_t ops[] = { mso_trans(REG_TRIGGER, 0) }; char buf[1]; @@ -197,7 +196,7 @@ static int mso_check_trigger(struct sr_device_instance *sdi, return ret; } -static int mso_read_buffer(struct sr_device_instance *sdi) +static int mso_read_buffer(struct sr_dev_inst *sdi) { uint16_t ops[] = { mso_trans(REG_BUFFER, 0) }; @@ -205,7 +204,7 @@ static int mso_read_buffer(struct sr_device_instance *sdi) return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops)); } -static int mso_arm(struct sr_device_instance *sdi) +static int mso_arm(struct sr_dev_inst *sdi) { struct mso *mso = sdi->priv; uint16_t ops[] = { @@ -218,7 +217,7 @@ static int mso_arm(struct sr_device_instance *sdi) return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops)); } -static int mso_force_capture(struct sr_device_instance *sdi) +static int mso_force_capture(struct sr_dev_inst *sdi) { struct mso *mso = sdi->priv; uint16_t ops[] = { @@ -230,7 +229,7 @@ static int mso_force_capture(struct sr_device_instance *sdi) return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops)); } -static int mso_dac_out(struct sr_device_instance *sdi, uint16_t val) +static int mso_dac_out(struct sr_dev_inst *sdi, uint16_t val) { struct mso *mso = sdi->priv; uint16_t ops[] = { @@ -243,7 +242,7 @@ static int mso_dac_out(struct sr_device_instance *sdi, uint16_t val) return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops)); } -static int mso_clkrate_out(struct sr_device_instance *sdi, uint16_t val) +static int mso_clkrate_out(struct sr_dev_inst *sdi, uint16_t val) { uint16_t ops[] = { mso_trans(REG_CLKRATE1, (val >> 8) & 0xff), @@ -254,8 +253,7 @@ static int mso_clkrate_out(struct sr_device_instance *sdi, uint16_t val) return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops)); } -static int mso_configure_rate(struct sr_device_instance *sdi, - uint32_t rate) +static int mso_configure_rate(struct sr_dev_inst *sdi, uint32_t rate) { struct mso *mso = sdi->priv; unsigned int i; @@ -280,7 +278,7 @@ static inline uint16_t mso_calc_raw_from_mv(struct mso *mso) mso->vbit)); } -static int mso_configure_trigger(struct sr_device_instance *sdi) +static int mso_configure_trigger(struct sr_dev_inst *sdi) { struct mso *mso = sdi->priv; uint16_t ops[16]; @@ -352,7 +350,7 @@ static int mso_configure_trigger(struct sr_device_instance *sdi) return mso_send_control_message(sdi, ARRAY_AND_SIZE(ops)); } -static int mso_configure_threshold_level(struct sr_device_instance *sdi) +static int mso_configure_threshold_level(struct sr_dev_inst *sdi) { struct mso *mso = sdi->priv; @@ -360,7 +358,7 @@ static int mso_configure_threshold_level(struct sr_device_instance *sdi) } static int mso_parse_serial(const char *iSerial, const char *iProduct, - struct mso *mso) + struct mso *mso) { unsigned int u1, u2, u3, u4, u5, u6; @@ -400,7 +398,7 @@ static int mso_parse_serial(const char *iSerial, const char *iProduct, static int hw_init(const char *deviceinfo) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; int devcnt = 0; struct udev *udev; struct udev_enumerate *enumerate; @@ -498,13 +496,13 @@ static int hw_init(const char *deviceinfo) sdi->serial = sr_serial_dev_inst_new(path, -1); if (!sdi->serial) - goto err_device_instance_free; + goto err_dev_inst_free; - device_instances = g_slist_append(device_instances, sdi); + dev_insts = g_slist_append(dev_insts, sdi); devcnt++; continue; -err_device_instance_free: +err_dev_inst_free: sr_dev_inst_free(sdi); err_free_mso: g_free(mso); @@ -520,12 +518,12 @@ ret: static int hw_cleanup(void) { GSList *l; - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; int ret; ret = SR_OK; /* Properly close all devices. */ - for (l = device_instances; l; l = l->next) { + for (l = dev_insts; l; l = l->next) { if (!(sdi = l->data)) { /* Log error, but continue cleaning up the rest. */ sr_err("mso19: %s: sdi was NULL, continuing", __func__); @@ -536,19 +534,19 @@ static int hw_cleanup(void) serial_close(sdi->serial->fd); sr_dev_inst_free(sdi); } - g_slist_free(device_instances); - device_instances = NULL; + g_slist_free(dev_insts); + dev_insts = NULL; return ret; } static int hw_opendev(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct mso *mso; int ret = SR_ERR; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return ret; mso = sdi->priv; @@ -586,9 +584,9 @@ static int hw_opendev(int device_index) static int hw_closedev(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("mso19: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -606,11 +604,11 @@ static int hw_closedev(int device_index) static void *hw_get_device_info(int device_index, int device_info_id) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct mso *mso; void *info = NULL; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return NULL; mso = sdi->priv; @@ -639,9 +637,9 @@ static void *hw_get_device_info(int device_index, int device_info_id) static int hw_get_status(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return SR_ST_NOT_FOUND; return sdi->status; @@ -654,9 +652,9 @@ static int *hw_get_capabilities(void) static int hw_set_configuration(int device_index, int capability, void *value) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return SR_ERR; switch (capability) { @@ -680,7 +678,7 @@ static int hw_set_configuration(int device_index, int capability, void *value) /* FIXME: Pass errors? */ static int receive_data(int fd, int revents, void *user_data) { - struct sr_device_instance *sdi = user_data; + struct sr_dev_inst *sdi = user_data; struct mso *mso = sdi->priv; struct sr_datafeed_packet packet; struct sr_datafeed_logic logic; @@ -747,13 +745,13 @@ static int receive_data(int fd, int revents, void *user_data) static int hw_start_acquisition(int device_index, gpointer session_device_id) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct mso *mso; struct sr_datafeed_packet packet; struct sr_datafeed_header header; int ret = SR_ERR; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return ret; mso = sdi->priv; diff --git a/hardware/openbench-logic-sniffer/ols.c b/hardware/openbench-logic-sniffer/ols.c index c322f789..504cd515 100644 --- a/hardware/openbench-logic-sniffer/ols.c +++ b/hardware/openbench-logic-sniffer/ols.c @@ -99,8 +99,8 @@ static struct sr_samplerates samplerates = { NULL, }; -/* List of struct sr_serial_device_instance */ -static GSList *device_instances = NULL; +/* List of struct sr_serial_dev_inst */ +static GSList *dev_insts = NULL; static int send_shortcommand(int fd, uint8_t command) { @@ -222,9 +222,9 @@ static struct ols_device *ols_device_new(void) return ols; } -static struct sr_device_instance *get_metadata(int fd) +static struct sr_dev_inst *get_metadata(int fd) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct ols_device *ols; uint32_t tmp_int; uint8_t key, type, token; @@ -349,7 +349,7 @@ static struct sr_device_instance *get_metadata(int fd) static int hw_init(const char *deviceinfo) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct ols_device *ols; GSList *ports, *l; GPollFD *fds, probefd; @@ -453,7 +453,7 @@ static int hw_init(const char *deviceinfo) sdi->priv = ols; } ols->serial = sr_serial_dev_inst_new(device_names[i], -1); - device_instances = g_slist_append(device_instances, sdi); + dev_insts = g_slist_append(dev_insts, sdi); final_devcnt++; serial_close(fds[i].fd); fds[i].fd = 0; @@ -482,10 +482,10 @@ hw_init_free_ports: static int hw_opendev(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct ols_device *ols; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return SR_ERR; ols = sdi->priv; @@ -501,10 +501,10 @@ static int hw_opendev(int device_index) static int hw_closedev(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct ols_device *ols; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("ols: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -524,12 +524,12 @@ static int hw_closedev(int device_index) static int hw_cleanup(void) { GSList *l; - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct ols_device *ols; int ret = SR_OK; /* Properly close and free all devices. */ - for (l = device_instances; l; l = l->next) { + for (l = dev_insts; l; l = l->next) { if (!(sdi = l->data)) { /* Log error, but continue cleaning up the rest. */ sr_err("ols: %s: sdi was NULL, continuing", __func__); @@ -549,19 +549,19 @@ static int hw_cleanup(void) sr_serial_dev_inst_free(ols->serial); sr_dev_inst_free(sdi); } - g_slist_free(device_instances); - device_instances = NULL; + g_slist_free(dev_insts); + dev_insts = NULL; return ret; } static void *hw_get_device_info(int device_index, int device_info_id) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct ols_device *ols; void *info; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return NULL; ols = sdi->priv; @@ -592,9 +592,9 @@ static void *hw_get_device_info(int device_index, int device_info_id) static int hw_get_status(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return SR_ST_NOT_FOUND; return sdi->status; @@ -605,7 +605,7 @@ static int *hw_get_capabilities(void) return capabilities; } -static int set_configuration_samplerate(struct sr_device_instance *sdi, +static int set_configuration_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate) { struct ols_device *ols; @@ -640,12 +640,12 @@ static int set_configuration_samplerate(struct sr_device_instance *sdi, static int hw_set_configuration(int device_index, int capability, void *value) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct ols_device *ols; int ret; uint64_t *tmp_u64; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return SR_ERR; ols = sdi->priv; @@ -697,7 +697,7 @@ static int receive_data(int fd, int revents, void *session_data) { struct sr_datafeed_packet packet; struct sr_datafeed_logic logic; - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct ols_device *ols; GSList *l; int num_channels, offset, i, j; @@ -705,7 +705,7 @@ static int receive_data(int fd, int revents, void *session_data) /* find this device's ols_device struct by its fd */ ols = NULL; - for (l = device_instances; l; l = l->next) { + for (l = dev_insts; l; l = l->next) { sdi = l->data; if (ols->serial->fd == fd) { ols = sdi->priv; @@ -876,7 +876,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data) { struct sr_datafeed_packet *packet; struct sr_datafeed_header *header; - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct ols_device *ols; uint32_t trigger_config[4]; uint32_t data; @@ -885,7 +885,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data) int num_channels; int i; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return SR_ERR; ols = sdi->priv; diff --git a/hardware/openbench-logic-sniffer/ols.h b/hardware/openbench-logic-sniffer/ols.h index 5661cbcc..923e3e75 100644 --- a/hardware/openbench-logic-sniffer/ols.h +++ b/hardware/openbench-logic-sniffer/ols.h @@ -88,7 +88,7 @@ struct ols_device { unsigned char tmp_sample[4]; unsigned char *raw_sample_buf; - struct sr_serial_device_instance *serial; + struct sr_serial_dev_inst *serial; }; #endif diff --git a/hardware/saleae-logic/saleae-logic.c b/hardware/saleae-logic/saleae-logic.c index 35662821..a499191e 100644 --- a/hardware/saleae-logic/saleae-logic.c +++ b/hardware/saleae-logic/saleae-logic.c @@ -87,8 +87,8 @@ static struct sr_samplerates samplerates = { supported_samplerates, }; -/* List of struct sr_device_instance, maintained by opendev()/closedev(). */ -static GSList *device_instances = NULL; +/* List of struct sr_dev_inst, maintained by opendev()/closedev(). */ +static GSList *dev_insts = NULL; static libusb_context *usb_context = NULL; static int new_saleae_logic_firmware = 0; @@ -169,11 +169,11 @@ static int sl_open_device(int device_index) { libusb_device **devlist; struct libusb_device_descriptor des; - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct fx2_device *fx2; int err, skip, i; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return SR_ERR; fx2 = sdi->priv; @@ -237,7 +237,7 @@ static int sl_open_device(int device_index) return SR_OK; } -static void close_device(struct sr_device_instance *sdi) +static void close_device(struct sr_dev_inst *sdi) { struct fx2_device *fx2; @@ -321,7 +321,7 @@ static struct fx2_device *fx2_device_new(void) static int hw_init(const char *deviceinfo) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct libusb_device_descriptor des; struct fx2_profile *fx2_prof; struct fx2_device *fx2; @@ -366,7 +366,7 @@ static int hw_init(const char *deviceinfo) fx2 = fx2_device_new(); fx2->profile = fx2_prof; sdi->priv = fx2; - device_instances = g_slist_append(device_instances, sdi); + dev_insts = g_slist_append(dev_insts, sdi); if (check_conf_profile(devlist[i])) { /* Already has the firmware, so fix the new address. */ @@ -396,11 +396,11 @@ static int hw_init(const char *deviceinfo) static int hw_opendev(int device_index) { GTimeVal cur_time; - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct fx2_device *fx2; int timediff, err; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return SR_ERR; fx2 = sdi->priv; @@ -450,9 +450,9 @@ static int hw_opendev(int device_index) static int hw_closedev(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("logic: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -466,12 +466,12 @@ static int hw_closedev(int device_index) static int hw_cleanup(void) { GSList *l; - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct fx2_device *fx2; int ret = SR_OK; /* Properly close and free all devices. */ - for (l = device_instances; l; l = l->next) { + for (l = dev_insts; l; l = l->next) { if (!(sdi = l->data)) { /* Log error, but continue cleaning up the rest. */ sr_err("logic: %s: sdi was NULL, continuing", __func__); @@ -490,8 +490,8 @@ static int hw_cleanup(void) sr_dev_inst_free(sdi); } - g_slist_free(device_instances); - device_instances = NULL; + g_slist_free(dev_insts); + dev_insts = NULL; if (usb_context) libusb_exit(usb_context); @@ -502,11 +502,11 @@ static int hw_cleanup(void) static void *hw_get_device_info(int device_index, int device_info_id) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct fx2_device *fx2; void *info = NULL; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return NULL; fx2 = sdi->priv; @@ -536,9 +536,9 @@ static void *hw_get_device_info(int device_index, int device_info_id) static int hw_get_status(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; - sdi = sr_dev_inst_get(device_instances, device_index); + sdi = sr_dev_inst_get(dev_insts, device_index); if (sdi) return sdi->status; else @@ -591,7 +591,7 @@ static uint8_t new_firmware_divider_value(uint64_t samplerate) return 0; } -static int set_configuration_samplerate(struct sr_device_instance *sdi, +static int set_configuration_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate) { struct fx2_device *fx2; @@ -630,12 +630,12 @@ static int set_configuration_samplerate(struct sr_device_instance *sdi, static int hw_set_configuration(int device_index, int capability, void *value) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct fx2_device *fx2; int ret; uint64_t *tmp_u64; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return SR_ERR; fx2 = sdi->priv; @@ -810,7 +810,7 @@ static void receive_transfer(struct libusb_transfer *transfer) static int hw_start_acquisition(int device_index, gpointer session_data) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct sr_datafeed_packet *packet; struct sr_datafeed_header *header; struct fx2_device *fx2; @@ -819,7 +819,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data) int size, i; unsigned char *buf; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return SR_ERR; fx2 = sdi->priv; fx2->session_data = session_data; diff --git a/hardware/saleae-logic/saleae-logic.h b/hardware/saleae-logic/saleae-logic.h index e7fe9c00..2855485e 100644 --- a/hardware/saleae-logic/saleae-logic.h +++ b/hardware/saleae-logic/saleae-logic.h @@ -71,7 +71,7 @@ struct fx2_device { */ void *session_data; - struct sr_usb_device_instance *usb; + struct sr_usb_dev_inst *usb; }; #endif diff --git a/hardware/zeroplus-logic-cube/zeroplus.c b/hardware/zeroplus-logic-cube/zeroplus.c index d0b8b806..722aed6f 100644 --- a/hardware/zeroplus-logic-cube/zeroplus.c +++ b/hardware/zeroplus-logic-cube/zeroplus.c @@ -110,8 +110,8 @@ static const char *probe_names[] = { NULL, }; -/* List of struct sr_device_instance, maintained by opendev()/closedev(). */ -static GSList *device_instances = NULL; +/* List of struct sr_dev_inst, maintained by opendev()/closedev(). */ +static GSList *dev_insts = NULL; static libusb_context *usb_context = NULL; @@ -163,7 +163,7 @@ struct zp { uint8_t trigger_value[NUM_TRIGGER_STAGES]; // uint8_t trigger_buffer[NUM_TRIGGER_STAGES]; - struct sr_usb_device_instance *usb; + struct sr_usb_dev_inst *usb; }; static int hw_set_configuration(int device_index, int capability, void *value); @@ -182,7 +182,7 @@ static unsigned int get_memory_size(int type) return 0; } -static int opendev4(struct sr_device_instance **sdi, libusb_device *dev, +static int opendev4(struct sr_dev_inst **sdi, libusb_device *dev, struct libusb_device_descriptor *des) { struct zp *zp; @@ -239,14 +239,14 @@ static int opendev4(struct sr_device_instance **sdi, libusb_device *dev, return 0; } -static struct sr_device_instance *zp_open_device(int device_index) +static struct sr_dev_inst *zp_open_device(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; libusb_device **devlist; struct libusb_device_descriptor des; int err, i; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) return NULL; libusb_get_device_list(usb_context, &devlist); @@ -269,7 +269,7 @@ static struct sr_device_instance *zp_open_device(int device_index) return sdi; } -static void close_device(struct sr_device_instance *sdi) +static void close_device(struct sr_dev_inst *sdi) { struct zp *zp; @@ -291,7 +291,7 @@ static void close_device(struct sr_device_instance *sdi) sdi->status = SR_ST_INACTIVE; } -static int configure_probes(struct sr_device_instance *sdi, GSList *probes) +static int configure_probes(struct sr_dev_inst *sdi, GSList *probes) { struct zp *zp; struct sr_probe *probe; @@ -338,7 +338,7 @@ static int configure_probes(struct sr_device_instance *sdi, GSList *probes) static int hw_init(const char *deviceinfo) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct libusb_device_descriptor des; libusb_device **devlist; int err, devcnt, i; @@ -386,19 +386,18 @@ static int hw_init(const char *deviceinfo) * the zeroplus range? */ /* Register the device with libsigrok. */ - sdi = sr_dev_inst_new(devcnt, + if (!(sdi = sr_dev_inst_new(devcnt, SR_ST_INACTIVE, USB_VENDOR_NAME, - USB_MODEL_NAME, USB_MODEL_VERSION); - if (!sdi) { - sr_err("zp: %s: sr_device_instance_new failed", + USB_MODEL_NAME, USB_MODEL_VERSION))) { + sr_err("zp: %s: sr_dev_inst_new failed", __func__); return 0; } sdi->priv = zp; - device_instances = - g_slist_append(device_instances, sdi); + dev_insts = + g_slist_append(dev_insts, sdi); zp->usb = sr_usb_dev_inst_new( libusb_get_bus_number(devlist[i]), libusb_get_device_address(devlist[i]), NULL); @@ -412,7 +411,7 @@ static int hw_init(const char *deviceinfo) static int hw_opendev(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct zp *zp; int err; @@ -473,9 +472,9 @@ static int hw_opendev(int device_index) static int hw_closedev(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("zp: %s: sdi was NULL", __func__); return SR_ERR; /* TODO: SR_ERR_ARG? */ } @@ -489,17 +488,17 @@ static int hw_closedev(int device_index) static int hw_cleanup(void) { GSList *l; - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; - for (l = device_instances; l; l = l->next) { + for (l = dev_insts; l; l = l->next) { sdi = l->data; /* Properly close all devices... */ close_device(sdi); /* ...and free all their memory. */ sr_dev_inst_free(sdi); } - g_slist_free(device_instances); - device_instances = NULL; + g_slist_free(dev_insts); + dev_insts = NULL; if (usb_context) libusb_exit(usb_context); @@ -510,11 +509,11 @@ static int hw_cleanup(void) static void *hw_get_device_info(int device_index, int device_info_id) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct zp *zp; void *info; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("zp: %s: sdi was NULL", __func__); return NULL; } @@ -555,9 +554,9 @@ static void *hw_get_device_info(int device_index, int device_info_id) static int hw_get_status(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; - sdi = sr_dev_inst_get(device_instances, device_index); + sdi = sr_dev_inst_get(dev_insts, device_index); if (sdi) return sdi->status; else @@ -569,7 +568,7 @@ static int *hw_get_capabilities(void) return capabilities; } -static int set_configuration_samplerate(struct sr_device_instance *sdi, +static int set_configuration_samplerate(struct sr_dev_inst *sdi, uint64_t samplerate) { struct zp *zp; @@ -600,11 +599,11 @@ static int set_configuration_samplerate(struct sr_device_instance *sdi, static int hw_set_configuration(int device_index, int capability, void *value) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; uint64_t *tmp_u64; struct zp *zp; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("zp: %s: sdi was NULL", __func__); return SR_ERR; } @@ -631,7 +630,7 @@ static int hw_set_configuration(int device_index, int capability, void *value) static int hw_start_acquisition(int device_index, gpointer session_data) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct sr_datafeed_packet packet; struct sr_datafeed_logic logic; struct sr_datafeed_header header; @@ -641,7 +640,7 @@ static int hw_start_acquisition(int device_index, gpointer session_data) unsigned char *buf; struct zp *zp; - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("zp: %s: sdi was NULL", __func__); return SR_ERR; } @@ -708,13 +707,13 @@ static int hw_start_acquisition(int device_index, gpointer session_data) static int hw_stop_acquisition(int device_index, gpointer session_device_id) { struct sr_datafeed_packet packet; - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct zp *zp; packet.type = SR_DF_END; sr_session_bus(session_device_id, &packet); - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("zp: %s: sdi was NULL", __func__); return SR_ERR_BUG; } diff --git a/hwplugin.c b/hwplugin.c index 368bb827..c560002f 100644 --- a/hwplugin.c +++ b/hwplugin.c @@ -165,12 +165,12 @@ SR_PRIV void sr_hw_cleanup_all(void) } } -SR_PRIV struct sr_device_instance *sr_dev_inst_new(int index, int status, +SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status, const char *vendor, const char *model, const char *version) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; - if (!(sdi = g_try_malloc(sizeof(struct sr_device_instance)))) { + if (!(sdi = g_try_malloc(sizeof(struct sr_dev_inst)))) { sr_err("hwplugin: %s: sdi malloc failed", __func__); return NULL; } @@ -186,14 +186,13 @@ SR_PRIV struct sr_device_instance *sr_dev_inst_new(int index, int status, return sdi; } -SR_PRIV struct sr_device_instance *sr_dev_inst_get( - GSList *device_instances, int device_index) +SR_PRIV struct sr_dev_inst *sr_dev_inst_get(GSList *dev_insts, int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; GSList *l; - for (l = device_instances; l; l = l->next) { - sdi = (struct sr_device_instance *)(l->data); + for (l = dev_insts; l; l = l->next) { + sdi = (struct sr_dev_inst *)(l->data); if (sdi->index == device_index) return sdi; } @@ -202,7 +201,7 @@ SR_PRIV struct sr_device_instance *sr_dev_inst_get( return NULL; } -SR_PRIV void sr_dev_inst_free(struct sr_device_instance *sdi) +SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi) { g_free(sdi->priv); g_free(sdi->vendor); @@ -213,12 +212,12 @@ SR_PRIV void sr_dev_inst_free(struct sr_device_instance *sdi) #ifdef HAVE_LIBUSB_1_0 -SR_PRIV struct sr_usb_device_instance *sr_usb_dev_inst_new(uint8_t bus, +SR_PRIV struct sr_usb_dev_inst *sr_usb_dev_inst_new(uint8_t bus, uint8_t address, struct libusb_device_handle *hdl) { - struct sr_usb_device_instance *udi; + struct sr_usb_dev_inst *udi; - if (!(udi = g_try_malloc(sizeof(struct sr_usb_device_instance)))) { + if (!(udi = g_try_malloc(sizeof(struct sr_usb_dev_inst)))) { sr_err("hwplugin: %s: udi malloc failed", __func__); return NULL; } @@ -230,7 +229,7 @@ SR_PRIV struct sr_usb_device_instance *sr_usb_dev_inst_new(uint8_t bus, return udi; } -SR_PRIV void sr_usb_dev_inst_free(struct sr_usb_device_instance *usb) +SR_PRIV void sr_usb_dev_inst_free(struct sr_usb_dev_inst *usb) { /* Avoid compiler warnings. */ (void)usb; @@ -240,12 +239,12 @@ SR_PRIV void sr_usb_dev_inst_free(struct sr_usb_device_instance *usb) #endif -SR_PRIV struct sr_serial_device_instance *sr_serial_dev_inst_new( - const char *port, int fd) +SR_PRIV struct sr_serial_dev_inst *sr_serial_dev_inst_new(const char *port, + int fd) { - struct sr_serial_device_instance *serial; + struct sr_serial_dev_inst *serial; - if (!(serial = g_try_malloc(sizeof(struct sr_serial_device_instance)))) { + if (!(serial = g_try_malloc(sizeof(struct sr_serial_dev_inst)))) { sr_err("hwplugin: %s: serial malloc failed", __func__); return NULL; } @@ -256,8 +255,7 @@ SR_PRIV struct sr_serial_device_instance *sr_serial_dev_inst_new( return serial; } -SR_PRIV void sr_serial_dev_inst_free( - struct sr_serial_device_instance *serial) +SR_PRIV void sr_serial_dev_inst_free(struct sr_serial_dev_inst *serial) { g_free(serial->port); } diff --git a/session_driver.c b/session_driver.c index 01870c01..7f2bf92a 100644 --- a/session_driver.c +++ b/session_driver.c @@ -40,7 +40,7 @@ struct session_vdevice { }; static char *sessionfile = NULL; -static GSList *device_instances = NULL; +static GSList *dev_insts = NULL; static int capabilities[] = { SR_HWCAP_CAPTUREFILE, SR_HWCAP_CAPTURE_UNITSIZE, @@ -54,12 +54,12 @@ static int capabilities[] = { */ static struct session_vdevice *get_vdevice_by_index(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct session_vdevice *vdevice; /* TODO: Sanity checks on device_index. */ - if (!(sdi = sr_dev_inst_get(device_instances, device_index))) { + if (!(sdi = sr_dev_inst_get(dev_insts, device_index))) { sr_err("session driver: %s: device instance with device " "index %d was not found", __func__, device_index); return NULL; @@ -83,7 +83,7 @@ static struct session_vdevice *get_vdevice_by_index(int device_index) */ static int feed_chunk(int fd, int revents, void *session_data) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; struct session_vdevice *vdevice; struct sr_datafeed_packet packet; struct sr_datafeed_logic logic; @@ -98,7 +98,7 @@ static int feed_chunk(int fd, int revents, void *session_data) sr_dbg("session_driver: feed chunk"); got_data = FALSE; - for (l = device_instances; l; l = l->next) { + for (l = dev_insts; l; l = l->next) { sdi = l->data; vdevice = sdi->priv; if (!vdevice) @@ -163,10 +163,10 @@ static int hw_cleanup(void) { GSList *l; - for (l = device_instances; l; l = l->next) + for (l = dev_insts; l; l = l->next) sr_dev_inst_free(l->data); - g_slist_free(device_instances); - device_instances = NULL; + g_slist_free(dev_insts); + dev_insts = NULL; sr_session_source_remove(-1); @@ -177,7 +177,7 @@ static int hw_cleanup(void) static int hw_opendev(int device_index) { - struct sr_device_instance *sdi; + struct sr_dev_inst *sdi; sdi = sr_dev_inst_new(device_index, SR_ST_INITIALIZING, NULL, NULL, NULL); @@ -189,7 +189,7 @@ static int hw_opendev(int device_index) return SR_ERR_MALLOC; } - device_instances = g_slist_append(device_instances, sdi); + dev_insts = g_slist_append(dev_insts, sdi); return SR_OK; } diff --git a/sigrok-internal.h b/sigrok-internal.h index d8005443..d5b7d072 100644 --- a/sigrok-internal.h +++ b/sigrok-internal.h @@ -41,29 +41,29 @@ #define DATASTORE_CHUNKSIZE (512 * 1024) #ifdef HAVE_LIBUSB_1_0 -struct sr_usb_device_instance { +struct sr_usb_dev_inst { uint8_t bus; uint8_t address; struct libusb_device_handle *devhdl; }; #endif -struct sr_serial_device_instance { +struct sr_serial_dev_inst { char *port; int fd; }; #ifdef HAVE_LIBUSB_1_0 /* USB-specific instances */ -SR_PRIV struct sr_usb_device_instance *sr_usb_dev_inst_new(uint8_t bus, +SR_PRIV struct sr_usb_dev_inst *sr_usb_dev_inst_new(uint8_t bus, uint8_t address, struct libusb_device_handle *hdl); -SR_PRIV void sr_usb_dev_inst_free(struct sr_usb_device_instance *usb); +SR_PRIV void sr_usb_dev_inst_free(struct sr_usb_dev_inst *usb); #endif /* Serial-specific instances */ -SR_PRIV struct sr_serial_device_instance *sr_serial_dev_inst_new( +SR_PRIV struct sr_serial_dev_inst *sr_serial_dev_inst_new( const char *port, int fd); -SR_PRIV void sr_serial_dev_inst_free(struct sr_serial_device_instance *serial); +SR_PRIV void sr_serial_dev_inst_free(struct sr_serial_dev_inst *serial); /*--- log.c -----------------------------------------------------------------*/ @@ -85,11 +85,11 @@ SR_PRIV int sr_session_bus(struct sr_device *device, struct sr_datafeed_packet *packet); /* Generic device instances */ -SR_PRIV struct sr_device_instance *sr_dev_inst_new(int index, - int status, const char *vendor, const char *model, const char *version); -SR_PRIV struct sr_device_instance *sr_dev_inst_get( - GSList *device_instances, int device_index); -SR_PRIV void sr_dev_inst_free(struct sr_device_instance *sdi); +SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status, + const char *vendor, const char *model, const char *version); +SR_PRIV struct sr_dev_inst *sr_dev_inst_get(GSList *dev_insts, + int device_index); +SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi); SR_PRIV void sr_source_remove(int fd); SR_PRIV void sr_source_add(int fd, int events, int timeout, @@ -121,10 +121,10 @@ SR_PRIV int ezusb_upload_firmware(libusb_device *dev, int configuration, /*--- hardware/common/misc.c ------------------------------------------------*/ #ifdef HAVE_LIBUSB_1_0 -SR_PRIV int opendev2(int device_index, struct sr_device_instance **sdi, +SR_PRIV int opendev2(int device_index, struct sr_dev_inst **sdi, libusb_device *dev, struct libusb_device_descriptor *des, int *skip, uint16_t vid, uint16_t pid, int interface); -SR_PRIV int opendev3(struct sr_device_instance **sdi, libusb_device *dev, +SR_PRIV int opendev3(struct sr_dev_inst **sdi, libusb_device *dev, struct libusb_device_descriptor *des, uint16_t vid, uint16_t pid, int interface); #endif diff --git a/sigrok.h b/sigrok.h index c6809468..e8e770f6 100644 --- a/sigrok.h +++ b/sigrok.h @@ -276,7 +276,7 @@ struct sr_hwcap_option { char *shortname; }; -struct sr_device_instance { +struct sr_dev_inst { int index; int status; int instance_type; @@ -286,7 +286,7 @@ struct sr_device_instance { void *priv; }; -/* sr_device_instance types */ +/* sr_dev_inst types */ enum { SR_USB_INSTANCE, SR_SERIAL_INSTANCE, @@ -310,7 +310,7 @@ enum { /* Device info IDs */ enum { - /* struct sr_device_instance for this specific device */ + /* struct sr_dev_inst for this specific device */ SR_DI_INSTANCE, /* The number of probes connected to this device */ SR_DI_NUM_PROBES,