Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

interconnect: qcom: Simplify the vcd compare function

Let's simplify the cmp_vcd() function and replace the conditionals
with just a single statement, which also improves readability.

Reviewed-by: Mike Tipton <mdtipton@codeaurora.org>
Link: https://lore.kernel.org/r/20201013171923.7351-1-georgi.djakov@linaro.org
Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>

+3 -10
+3 -10
drivers/interconnect/qcom/bcm-voter.c
··· 41 41 42 42 static int cmp_vcd(void *priv, struct list_head *a, struct list_head *b) 43 43 { 44 - const struct qcom_icc_bcm *bcm_a = 45 - list_entry(a, struct qcom_icc_bcm, list); 46 - const struct qcom_icc_bcm *bcm_b = 47 - list_entry(b, struct qcom_icc_bcm, list); 44 + const struct qcom_icc_bcm *bcm_a = list_entry(a, struct qcom_icc_bcm, list); 45 + const struct qcom_icc_bcm *bcm_b = list_entry(b, struct qcom_icc_bcm, list); 48 46 49 - if (bcm_a->aux_data.vcd < bcm_b->aux_data.vcd) 50 - return -1; 51 - else if (bcm_a->aux_data.vcd == bcm_b->aux_data.vcd) 52 - return 0; 53 - else 54 - return 1; 47 + return bcm_a->aux_data.vcd - bcm_b->aux_data.vcd; 55 48 } 56 49 57 50 static u64 bcm_div(u64 num, u32 base)