]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
interconnect: qcom: Simplify the vcd compare function
authorGeorgi Djakov <georgi.djakov@linaro.org>
Tue, 13 Oct 2020 17:19:23 +0000 (20:19 +0300)
committerGeorgi Djakov <georgi.djakov@linaro.org>
Mon, 30 Nov 2020 15:26:22 +0000 (17:26 +0200)
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>
drivers/interconnect/qcom/bcm-voter.c

index 887d13721e521e64f1b0d7ba3b58a8b5f2f133f0..1cc565bce2f4da956be6a358d04a7c18657d5996 100644 (file)
@@ -41,17 +41,10 @@ struct bcm_voter {
 
 static int cmp_vcd(void *priv, struct list_head *a, struct list_head *b)
 {
-       const struct qcom_icc_bcm *bcm_a =
-                       list_entry(a, struct qcom_icc_bcm, list);
-       const struct qcom_icc_bcm *bcm_b =
-                       list_entry(b, struct qcom_icc_bcm, list);
-
-       if (bcm_a->aux_data.vcd < bcm_b->aux_data.vcd)
-               return -1;
-       else if (bcm_a->aux_data.vcd == bcm_b->aux_data.vcd)
-               return 0;
-       else
-               return 1;
+       const struct qcom_icc_bcm *bcm_a = list_entry(a, struct qcom_icc_bcm, list);
+       const struct qcom_icc_bcm *bcm_b = list_entry(b, struct qcom_icc_bcm, list);
+
+       return bcm_a->aux_data.vcd - bcm_b->aux_data.vcd;
 }
 
 static u64 bcm_div(u64 num, u32 base)