* [PATCH] interconnect: qcom: Simplify the vcd compare function
@ 2020-10-13 17:19 Georgi Djakov
2020-10-14 1:39 ` Mike Tipton
0 siblings, 1 reply; 2+ messages in thread
From: Georgi Djakov @ 2020-10-13 17:19 UTC (permalink / raw)
To: linux-pm
Cc: mdtipton, okukatla, sibis, bjorn.andersson, linux-kernel, Georgi Djakov
Let's simplify the cmp_vcd() function and replace the conditionals
with just a single statement, which also improves readability.
Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
---
drivers/interconnect/qcom/bcm-voter.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/drivers/interconnect/qcom/bcm-voter.c b/drivers/interconnect/qcom/bcm-voter.c
index 887d13721e52..1cc565bce2f4 100644
--- a/drivers/interconnect/qcom/bcm-voter.c
+++ b/drivers/interconnect/qcom/bcm-voter.c
@@ -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)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] interconnect: qcom: Simplify the vcd compare function
2020-10-13 17:19 [PATCH] interconnect: qcom: Simplify the vcd compare function Georgi Djakov
@ 2020-10-14 1:39 ` Mike Tipton
0 siblings, 0 replies; 2+ messages in thread
From: Mike Tipton @ 2020-10-14 1:39 UTC (permalink / raw)
To: Georgi Djakov, linux-pm; +Cc: okukatla, sibis, bjorn.andersson, linux-kernel
On 10/13/2020 10:19 AM, Georgi Djakov wrote:
> Let's simplify the cmp_vcd() function and replace the conditionals
> with just a single statement, which also improves readability.
>
> Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
> ---
> drivers/interconnect/qcom/bcm-voter.c | 15 ++++-----------
> 1 file changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/interconnect/qcom/bcm-voter.c b/drivers/interconnect/qcom/bcm-voter.c
> index 887d13721e52..1cc565bce2f4 100644
> --- a/drivers/interconnect/qcom/bcm-voter.c
> +++ b/drivers/interconnect/qcom/bcm-voter.c
> @@ -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)
>
Reviewed-by: Mike Tipton <mdtipton@codeaurora.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-14 1:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-13 17:19 [PATCH] interconnect: qcom: Simplify the vcd compare function Georgi Djakov
2020-10-14 1:39 ` Mike Tipton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).