From: Uwe Hermann Date: Wed, 6 Feb 2013 21:35:24 +0000 (+0100) Subject: Driver struct cleanups. X-Git-Tag: dsupstream~276 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6fab7b8f5365c7be69be4a755910945b6113dd8f;p=libsigrok.git Driver struct cleanups. - Explicitly list .config_get in all drivers for consistency, and set it to NULL if unused (whether or not a driver implements it is optional). - List all 'struct sr_dev_driver' entries in the same order in all drivers. - Move the check whether .config_set/.config_list exist (i.e., are non-NULL) into sanity_check_all_drivers(). --- diff --git a/backend.c b/backend.c index 0dab1eea..62a76517 100644 --- a/backend.c +++ b/backend.c @@ -165,6 +165,15 @@ static int sanity_check_all_drivers(void) sr_err("No dev_clear in driver %d ('%s').", i, d); errors++; } + /* Note: config_get() is optional. */ + if (!drivers[i]->config_set) { + sr_err("No config_set in driver %d ('%s').", i, d); + errors++; + } + if (!drivers[i]->config_list) { + sr_err("No config_list in driver %d ('%s').", i, d); + errors++; + } if (!drivers[i]->dev_open) { sr_err("No dev_open in driver %d ('%s').", i, d); errors++; diff --git a/hardware/agilent-dmm/api.c b/hardware/agilent-dmm/api.c index c0b10e07..6818bc8f 100644 --- a/hardware/agilent-dmm/api.c +++ b/hardware/agilent-dmm/api.c @@ -343,6 +343,7 @@ SR_PRIV struct sr_dev_driver agdmm_driver_info = { .scan = hw_scan, .dev_list = hw_dev_list, .dev_clear = clear_instances, + .config_get = NULL, .config_set = config_set, .config_list = config_list, .dev_open = hw_dev_open, diff --git a/hardware/brymen-dmm/api.c b/hardware/brymen-dmm/api.c index f3152e26..1bd3c2e0 100644 --- a/hardware/brymen-dmm/api.c +++ b/hardware/brymen-dmm/api.c @@ -233,8 +233,7 @@ static int config_list(int key, const void **data, return SR_OK; } -static int hw_dev_config_set(int id, const void *value, - const struct sr_dev_inst *sdi) +static int config_set(int id, const void *value, const struct sr_dev_inst *sdi) { struct dev_context *devc; int ret; @@ -332,10 +331,11 @@ SR_PRIV struct sr_dev_driver brymen_bm857_driver_info = { .scan = hw_scan, .dev_list = hw_dev_list, .dev_clear = clear_instances, + .config_get = NULL, + .config_set = config_set, + .config_list = config_list, .dev_open = hw_dev_open, .dev_close = hw_dev_close, - .config_list = config_list, - .config_set = hw_dev_config_set, .dev_acquisition_start = hw_dev_acquisition_start, .dev_acquisition_stop = hw_dev_acquisition_stop, .priv = NULL, diff --git a/hardware/colead-slm/api.c b/hardware/colead-slm/api.c index 33c3038d..7cb5140e 100644 --- a/hardware/colead-slm/api.c +++ b/hardware/colead-slm/api.c @@ -288,6 +288,7 @@ SR_PRIV struct sr_dev_driver colead_slm_driver_info = { .scan = hw_scan, .dev_list = hw_dev_list, .dev_clear = clear_instances, + .config_get = NULL, .config_set = config_set, .config_list = config_list, .dev_open = hw_dev_open, diff --git a/hardware/fluke-dmm/api.c b/hardware/fluke-dmm/api.c index 0b69010d..438918d1 100644 --- a/hardware/fluke-dmm/api.c +++ b/hardware/fluke-dmm/api.c @@ -383,6 +383,7 @@ SR_PRIV struct sr_dev_driver flukedmm_driver_info = { .scan = hw_scan, .dev_list = hw_dev_list, .dev_clear = clear_instances, + .config_get = NULL, .config_set = config_set, .config_list = config_list, .dev_open = hw_dev_open, diff --git a/hardware/hantek-dso/api.c b/hardware/hantek-dso/api.c index ebcc0f25..80bd0b49 100644 --- a/hardware/hantek-dso/api.c +++ b/hardware/hantek-dso/api.c @@ -888,6 +888,7 @@ SR_PRIV struct sr_dev_driver hantek_dso_driver_info = { .scan = hw_scan, .dev_list = hw_dev_list, .dev_clear = clear_instances, + .config_get = NULL, .config_set = config_set, .config_list = config_list, .dev_open = hw_dev_open, diff --git a/hardware/lascar-el-usb/api.c b/hardware/lascar-el-usb/api.c index 4cef9f96..d3ba405d 100644 --- a/hardware/lascar-el-usb/api.c +++ b/hardware/lascar-el-usb/api.c @@ -454,6 +454,7 @@ SR_PRIV struct sr_dev_driver lascar_el_usb_driver_info = { .scan = hw_scan, .dev_list = hw_dev_list, .dev_clear = clear_instances, + .config_get = NULL, .config_set = config_set, .config_list = config_list, .dev_open = hw_dev_open, diff --git a/hardware/nexus-osciprime/api.c b/hardware/nexus-osciprime/api.c index af90b753..a19ca733 100644 --- a/hardware/nexus-osciprime/api.c +++ b/hardware/nexus-osciprime/api.c @@ -317,6 +317,7 @@ SR_PRIV struct sr_dev_driver nexus_osciprime_driver_info = { .scan = hw_scan, .dev_list = hw_dev_list, .dev_clear = clear_instances, + .config_get = NULL, .config_set = config_set, .config_list = config_list, .dev_open = hw_dev_open, diff --git a/hardware/rigol-ds1xx2/api.c b/hardware/rigol-ds1xx2/api.c index 2fd375fb..299fe20c 100644 --- a/hardware/rigol-ds1xx2/api.c +++ b/hardware/rigol-ds1xx2/api.c @@ -489,6 +489,7 @@ SR_PRIV struct sr_dev_driver rigol_ds1xx2_driver_info = { .scan = hw_scan, .dev_list = hw_dev_list, .dev_clear = clear_instances, + .config_get = NULL, .config_set = config_set, .config_list = config_list, .dev_open = hw_dev_open, diff --git a/hardware/serial-dmm/api.c b/hardware/serial-dmm/api.c index b6920819..a3a44eb4 100644 --- a/hardware/serial-dmm/api.c +++ b/hardware/serial-dmm/api.c @@ -495,6 +495,7 @@ SR_PRIV struct sr_dev_driver ID##_driver_info = { \ .scan = hw_scan_##ID_UPPER, \ .dev_list = hw_dev_list_##ID_UPPER, \ .dev_clear = clear_instances_##ID_UPPER, \ + .config_get = NULL, \ .config_set = config_set, \ .config_list = config_list, \ .dev_open = hw_dev_open, \ diff --git a/hardware/tondaj-sl-814/api.c b/hardware/tondaj-sl-814/api.c index b6d38cd1..e282f4c7 100644 --- a/hardware/tondaj-sl-814/api.c +++ b/hardware/tondaj-sl-814/api.c @@ -286,6 +286,7 @@ SR_PRIV struct sr_dev_driver tondaj_sl_814_driver_info = { .scan = hw_scan, .dev_list = hw_dev_list, .dev_clear = clear_instances, + .config_get = NULL, .config_set = config_set, .config_list = config_list, .dev_open = hw_dev_open, diff --git a/hardware/uni-t-dmm/api.c b/hardware/uni-t-dmm/api.c index 7662fb07..0e96355f 100644 --- a/hardware/uni-t-dmm/api.c +++ b/hardware/uni-t-dmm/api.c @@ -277,6 +277,7 @@ SR_PRIV struct sr_dev_driver uni_t_ut61d_driver_info = { .scan = hw_scan, .dev_list = hw_dev_list, .dev_clear = clear_instances, + .config_get = NULL, .config_set = config_set, .config_list = config_list, .dev_open = hw_dev_open, @@ -295,6 +296,7 @@ SR_PRIV struct sr_dev_driver voltcraft_vc820_driver_info = { .scan = hw_scan, .dev_list = hw_dev_list, .dev_clear = clear_instances, + .config_get = NULL, .config_set = config_set, .config_list = config_list, .dev_open = hw_dev_open, diff --git a/hardware/victor-dmm/api.c b/hardware/victor-dmm/api.c index 871c5de0..8b57f258 100644 --- a/hardware/victor-dmm/api.c +++ b/hardware/victor-dmm/api.c @@ -438,6 +438,7 @@ SR_PRIV struct sr_dev_driver victor_dmm_driver_info = { .scan = hw_scan, .dev_list = hw_dev_list, .dev_clear = clear_instances, + .config_get = NULL, .config_set = config_set, .config_list = config_list, .dev_open = hw_dev_open, diff --git a/hwdriver.c b/hwdriver.c index 026c4824..5bfd49fb 100644 --- a/hwdriver.c +++ b/hwdriver.c @@ -383,9 +383,6 @@ SR_API int sr_config_get(const struct sr_dev_driver *driver, int key, if (!driver || !data) return SR_ERR; - if (!driver->config_get) - return SR_ERR_ARG; - ret = driver->config_get(key, data, sdi); return ret; @@ -443,9 +440,6 @@ SR_API int sr_config_list(const struct sr_dev_driver *driver, int key, if (!driver || !data) return SR_ERR; - if (!driver->config_list) - return SR_ERR_ARG; - ret = driver->config_list(key, data, sdi); return ret;