]> sigrok.org Git - libsigrok.git/commitdiff
Driver struct cleanups.
authorUwe Hermann <redacted>
Wed, 6 Feb 2013 21:35:24 +0000 (22:35 +0100)
committerUwe Hermann <redacted>
Thu, 7 Feb 2013 09:58:35 +0000 (10:58 +0100)
 - 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().

14 files changed:
backend.c
hardware/agilent-dmm/api.c
hardware/brymen-dmm/api.c
hardware/colead-slm/api.c
hardware/fluke-dmm/api.c
hardware/hantek-dso/api.c
hardware/lascar-el-usb/api.c
hardware/nexus-osciprime/api.c
hardware/rigol-ds1xx2/api.c
hardware/serial-dmm/api.c
hardware/tondaj-sl-814/api.c
hardware/uni-t-dmm/api.c
hardware/victor-dmm/api.c
hwdriver.c

index 0dab1eeab93f42d938a1b5c0c9df94e9e7636d28..62a7651753986114e49e9711b2f236c1ddb49046 100644 (file)
--- 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++;
index c0b10e0701d131a414ce99e451fafcd31d43ed4f..6818bc8f902e269123c12172462b831319c24c42 100644 (file)
@@ -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,
index f3152e267761aaa8dfaa2b60c7936a3afa84e29c..1bd3c2e0f7b382014cfe861cea097784db53a237 100644 (file)
@@ -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,
index 33c3038d6f1cb64a40497279e71901b910360038..7cb5140eff500b4a70b2a613eabf95c3580f5429 100644 (file)
@@ -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,
index 0b69010d4dc0762523f4d54f0d185df7be0a0016..438918d1645541ff387255b2de021eb563f29960 100644 (file)
@@ -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,
index ebcc0f253fbc23016f70b506725fd30047c4d8e3..80bd0b497353a77f124b1d25994cedbb5b9715d6 100644 (file)
@@ -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,
index 4cef9f9698df9c0af2611166b457144ef77500a7..d3ba405d2932f454dc86e3b5a4bfee05d4b7f975 100644 (file)
@@ -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,
index af90b753e471439ab0172037f12597bae0ebff40..a19ca73335cd6273a17faa005642cde39eb36840 100644 (file)
@@ -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,
index 2fd375fbbdba9702abd489743469d8790d492452..299fe20c119e5bb8a0533c040db665eb53cd71d3 100644 (file)
@@ -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,
index b6920819870ab3830629d9a189c95b2464c34ee5..a3a44eb47c833378c034985238a492721390d279 100644 (file)
@@ -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, \
index b6d38cd160cbe9cb7c542866377ac805e5e91595..e282f4c7a4836c3787aff814164d1421d2176453 100644 (file)
@@ -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,
index 7662fb072fde63a85318b22f127f4c2478ecf733..0e96355fb6b9364008b457033b420a17811f98ad 100644 (file)
@@ -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,
index 871c5de0e7257c2b977c47e092d22a7f0d926fc8..8b57f2584bd3f71ccd4a1ebb9eff7170824270ab 100644 (file)
@@ -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,
index 026c4824d185dcea118e71d7dc3b459171f3f13b..5bfd49fbc70e6453f2cca03a4b605f874e7e5d6b 100644 (file)
@@ -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;