From: Gerhard Sittig Date: Thu, 15 Sep 2022 20:12:28 +0000 (+0200) Subject: korad-kaxxxxp: eliminate model check in OVP enabled quirk handling X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=77e6749af13d79ad71fd3d7ddc209a1e6d5ee52a;p=libsigrok.git korad-kaxxxxp: eliminate model check in OVP enabled quirk handling Rephrase the check for the Velleman LABPS3005D quirk. Eliminate the check for individual supported models in the main loop. The condition gets detected at scan time already. Handling other affected models becomes transparent. --- diff --git a/src/hardware/korad-kaxxxxp/protocol.c b/src/hardware/korad-kaxxxxp/protocol.c index f98bf962..c52bd901 100644 --- a/src/hardware/korad-kaxxxxp/protocol.c +++ b/src/hardware/korad-kaxxxxp/protocol.c @@ -258,6 +258,7 @@ SR_PRIV int korad_kaxxxxp_get_value(struct sr_serial_dev_inst *serial, char reply[6]; float *value; char status_byte; + gboolean needs_ovp_quirk; gboolean prev_status; g_mutex_lock(&devc->rw_mutex); @@ -345,9 +346,8 @@ SR_PRIV int korad_kaxxxxp_get_value(struct sr_serial_dev_inst *serial, devc->output_enabled_changed = devc->output_enabled != prev_status; /* OVP enabled, special handling for Velleman LABPS3005 quirk. */ - if ((devc->model->model_id == VELLEMAN_LABPS3005D && devc->output_enabled) || - devc->model->model_id != VELLEMAN_LABPS3005D) { - + needs_ovp_quirk = devc->model->quirks & KORAD_QUIRK_LABPS_OVP_EN; + if (!needs_ovp_quirk || devc->output_enabled) { prev_status = devc->ovp_enabled; devc->ovp_enabled = status_byte & (1 << 7); devc->ovp_enabled_changed = devc->ovp_enabled != prev_status;