X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=device.c;h=dd3a4000bcc6b9f9405ba673aca5035eedb8acfe;hb=dfcc0bf9d3b56c06daa1c4eec923ad21bf13dcd3;hp=1079bc3edfebf95191b9d96532479f0526cc5951;hpb=7d6588743503514c9de5c4fc8a511e9b0bdad7e6;p=libsigrok.git diff --git a/device.c b/device.c index 1079bc3e..dd3a4000 100644 --- a/device.c +++ b/device.c @@ -25,7 +25,7 @@ extern struct sr_global *global; GSList *devices = NULL; -void device_scan(void) +void sr_device_scan(void) { GSList *plugins, *l; struct sr_device_plugin *plugin; @@ -39,12 +39,12 @@ void device_scan(void) */ for (l = plugins; l; l = l->next) { plugin = l->data; - device_plugin_init(plugin); + sr_device_plugin_init(plugin); } } -int device_plugin_init(struct sr_device_plugin *plugin) +int sr_device_plugin_init(struct sr_device_plugin *plugin) { int num_devices, num_probes, i; @@ -52,34 +52,34 @@ int device_plugin_init(struct sr_device_plugin *plugin) num_devices = plugin->init(NULL); for (i = 0; i < num_devices; i++) { num_probes = (int)plugin->get_device_info(i, SR_DI_NUM_PROBES); - device_new(plugin, i, num_probes); + sr_device_new(plugin, i, num_probes); } return num_devices; } -void device_close_all(void) +void sr_device_close_all(void) { struct sr_device *device; while (devices) { device = devices->data; - if (device->plugin) + if (device->plugin && device->plugin->close) device->plugin->close(device->plugin_index); - device_destroy(device); + sr_device_destroy(device); } } -GSList *device_list(void) +GSList *sr_device_list(void) { if (!devices) - device_scan(); + sr_device_scan(); return devices; } -struct sr_device *device_new(struct sr_device_plugin *plugin, int plugin_index, +struct sr_device *sr_device_new(struct sr_device_plugin *plugin, int plugin_index, int num_probes) { struct sr_device *device; @@ -91,12 +91,12 @@ struct sr_device *device_new(struct sr_device_plugin *plugin, int plugin_index, devices = g_slist_append(devices, device); for (i = 0; i < num_probes; i++) - device_probe_add(device, NULL); + sr_device_probe_add(device, NULL); return device; } -void device_clear(struct sr_device *device) +void sr_device_clear(struct sr_device *device) { unsigned int pnum; @@ -106,10 +106,10 @@ void device_clear(struct sr_device *device) return; for (pnum = 1; pnum <= g_slist_length(device->probes); pnum++) - device_probe_clear(device, pnum); + sr_device_probe_clear(device, pnum); } -void device_destroy(struct sr_device *device) +void sr_device_destroy(struct sr_device *device) { unsigned int pnum; @@ -121,15 +121,15 @@ void device_destroy(struct sr_device *device) devices = g_slist_remove(devices, device); if (device->probes) { for (pnum = 1; pnum <= g_slist_length(device->probes); pnum++) - device_probe_clear(device, pnum); + sr_device_probe_clear(device, pnum); g_slist_free(device->probes); } g_free(device); } -void device_probe_clear(struct sr_device *device, int probenum) +void sr_device_probe_clear(struct sr_device *device, int probenum) { - struct probe *p; + struct sr_probe *p; p = probe_find(device, probenum); if (!p) @@ -146,14 +146,14 @@ void device_probe_clear(struct sr_device *device, int probenum) } } -void device_probe_add(struct sr_device *device, char *name) +void sr_device_probe_add(struct sr_device *device, char *name) { - struct probe *p; + struct sr_probe *p; char probename[16]; int probenum; probenum = g_slist_length(device->probes) + 1; - p = g_malloc0(sizeof(struct probe)); + p = g_malloc0(sizeof(struct sr_probe)); p->index = probenum; p->enabled = TRUE; if (name) { @@ -162,15 +162,14 @@ void device_probe_add(struct sr_device *device, char *name) snprintf(probename, 16, "%d", probenum); p->name = g_strdup(probename); } - p->name = g_strdup(name); p->trigger = NULL; device->probes = g_slist_append(device->probes, p); } -struct probe *probe_find(struct sr_device *device, int probenum) +struct sr_probe *probe_find(struct sr_device *device, int probenum) { GSList *l; - struct probe *p, *found_probe; + struct sr_probe *p, *found_probe; found_probe = NULL; for (l = device->probes; l; l = l->next) { @@ -185,9 +184,9 @@ struct probe *probe_find(struct sr_device *device, int probenum) } /* TODO: return SIGROK_ERR if probenum not found */ -void device_probe_name(struct sr_device *device, int probenum, char *name) +void sr_device_probe_name(struct sr_device *device, int probenum, char *name) { - struct probe *p; + struct sr_probe *p; p = probe_find(device, probenum); if (!p) @@ -199,9 +198,9 @@ void device_probe_name(struct sr_device *device, int probenum, char *name) } /* TODO: return SIGROK_ERR if probenum not found */ -void device_trigger_clear(struct sr_device *device) +void sr_device_trigger_clear(struct sr_device *device) { - struct probe *p; + struct sr_probe *p; unsigned int pnum; if (!device->probes) @@ -217,9 +216,9 @@ void device_trigger_clear(struct sr_device *device) } /* TODO: return SIGROK_ERR if probenum not found */ -void device_trigger_set(struct sr_device *device, int probenum, char *trigger) +void sr_device_trigger_set(struct sr_device *device, int probenum, char *trigger) { - struct probe *p; + struct sr_probe *p; p = probe_find(device, probenum); if (!p) @@ -232,7 +231,7 @@ void device_trigger_set(struct sr_device *device, int probenum, char *trigger) } -gboolean device_has_hwcap(struct sr_device *device, int hwcap) +gboolean sr_device_has_hwcap(struct sr_device *device, int hwcap) { int *capabilities, i;