]> sigrok.org Git - libsigrok.git/commitdiff
kingst-la2016: reduce a little if-deffery in logic threshold support
authorGerhard Sittig <redacted>
Mon, 31 Jan 2022 18:05:02 +0000 (19:05 +0100)
committerGerhard Sittig <redacted>
Sun, 6 Feb 2022 17:53:54 +0000 (18:53 +0100)
Move a logic threshold related switch case to the location where its
sibling config keys reside. Which eliminates a separate distant chunk
under an ifdef which should not have been there in the first place.

Make the presence of a device context member depend on the choice of
simple or complex threshold support. The simple approach exclusively
requires one index into the discrete set of a few voltages.

src/hardware/kingst-la2016/api.c
src/hardware/kingst-la2016/protocol.h

index 0e8f9fe03c6378e4b6bcd51bbaf7fb37a7e7e003..044b728fa5f6164213c34c4f7ccc2b96a8f087c8 100644 (file)
@@ -1093,16 +1093,14 @@ static int config_list(uint32_t key, GVariant **data,
                        LA2016_THR_VOLTAGE_MIN,
                        LA2016_THR_VOLTAGE_MAX, 0.1);
                break;
+       case SR_CONF_LOGIC_THRESHOLD:
+               *data = g_variant_new_strv(ARRAY_AND_SIZE(logic_threshold));
+               break;
 #endif /* WITH_THRESHOLD_SIMPLE */
 #endif /* WITH_THRESHOLD_DEVCFG */
        case SR_CONF_TRIGGER_MATCH:
                *data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches));
                break;
-#if WITH_THRESHOLD_DEVCFG && !WITH_THRESHOLD_SIMPLE
-       case SR_CONF_LOGIC_THRESHOLD:
-               *data = g_variant_new_strv(ARRAY_AND_SIZE(logic_threshold));
-               break;
-#endif
        default:
                return SR_ERR_NA;
        }
index 4e16b37227736110cc6b76467c19060d5d6147f1..30bf05782cb65b89cc7682da51abf4482882f4c0 100644 (file)
@@ -123,7 +123,9 @@ struct dev_context {
                float duty;
        } pwm_setting[LA2016_NUM_PWMCH_MAX];
        size_t threshold_voltage_idx;
+#if !WITH_THRESHOLD_SIMPLE
        float threshold_voltage;
+#endif
        uint64_t cur_samplerate;
        struct sr_sw_limits sw_limits;
        uint64_t capture_ratio;