* [PATCH] PM / devfreq: mtk-cci: avoid redundant conditions
@ 2025-09-03 12:14 Liao Yuanhong
2025-09-04 15:32 ` Markus Elfring
2025-09-07 1:34 ` Chanwoo Choi
0 siblings, 2 replies; 3+ messages in thread
From: Liao Yuanhong @ 2025-09-03 12:14 UTC (permalink / raw)
To: MyungJoo Ham, Kyungmin Park, Chanwoo Choi, Matthias Brugger,
AngeloGioacchino Del Regno, open list:DEVICE FREQUENCY (DEVFREQ),
open list:ARM/Mediatek SoC support,
moderated list:ARM/Mediatek SoC support,
moderated list:ARM/Mediatek SoC support
Cc: Liao Yuanhong
While 'if (i <= 0) ... else if (i > 0) ...' is technically equivalent to
'if (i <= 0) ... else ...', the latter is vastly easier to read because
it avoids writing out a condition that is unnecessary. Let's drop such
unnecessary conditions.
Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
---
drivers/devfreq/mtk-cci-devfreq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/devfreq/mtk-cci-devfreq.c b/drivers/devfreq/mtk-cci-devfreq.c
index 22fe9e631f8a..693c59c8037a 100644
--- a/drivers/devfreq/mtk-cci-devfreq.c
+++ b/drivers/devfreq/mtk-cci-devfreq.c
@@ -86,7 +86,7 @@ static int mtk_ccifreq_set_voltage(struct mtk_ccifreq_drv *drv, int new_voltage)
soc_data->sram_max_volt);
return ret;
}
- } else if (pre_voltage > new_voltage) {
+ } else {
voltage = max(new_voltage,
pre_vsram - soc_data->max_volt_shift);
ret = regulator_set_voltage(drv->proc_reg, voltage,
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] PM / devfreq: mtk-cci: avoid redundant conditions
2025-09-03 12:14 [PATCH] PM / devfreq: mtk-cci: avoid redundant conditions Liao Yuanhong
@ 2025-09-04 15:32 ` Markus Elfring
2025-09-07 1:34 ` Chanwoo Choi
1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2025-09-04 15:32 UTC (permalink / raw)
To: Liao Yuanhong, linux-pm, linux-mediatek, linux-arm-kernel
Cc: LKML, Angelo Gioacchino Del Regno, Chanwoo Choi, Kyungmin Park,
Matthias Brugger, MyungJoo Ham
…
> it avoids writing out a condition that is unnecessary. Let's drop such
Thus?
> unnecessary conditions.
an unnecessary condition?
Would a summary phrase like “Avoid redundant condition in mtk_ccifreq_set_voltage()”
be nicer?
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] PM / devfreq: mtk-cci: avoid redundant conditions
2025-09-03 12:14 [PATCH] PM / devfreq: mtk-cci: avoid redundant conditions Liao Yuanhong
2025-09-04 15:32 ` Markus Elfring
@ 2025-09-07 1:34 ` Chanwoo Choi
1 sibling, 0 replies; 3+ messages in thread
From: Chanwoo Choi @ 2025-09-07 1:34 UTC (permalink / raw)
To: Liao Yuanhong
Cc: MyungJoo Ham, Kyungmin Park, Chanwoo Choi, Matthias Brugger,
AngeloGioacchino Del Regno, open list:DEVICE FREQUENCY (DEVFREQ),
open list:ARM/Mediatek SoC support,
moderated list:ARM/Mediatek SoC support,
moderated list:ARM/Mediatek SoC support
Hi,
Applied it.
Thanks.
On Wed, Sep 3, 2025 at 9:15 PM Liao Yuanhong <liaoyuanhong@vivo.com> wrote:
>
> While 'if (i <= 0) ... else if (i > 0) ...' is technically equivalent to
> 'if (i <= 0) ... else ...', the latter is vastly easier to read because
> it avoids writing out a condition that is unnecessary. Let's drop such
> unnecessary conditions.
>
> Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
> ---
> drivers/devfreq/mtk-cci-devfreq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/devfreq/mtk-cci-devfreq.c b/drivers/devfreq/mtk-cci-devfreq.c
> index 22fe9e631f8a..693c59c8037a 100644
> --- a/drivers/devfreq/mtk-cci-devfreq.c
> +++ b/drivers/devfreq/mtk-cci-devfreq.c
> @@ -86,7 +86,7 @@ static int mtk_ccifreq_set_voltage(struct mtk_ccifreq_drv *drv, int new_voltage)
> soc_data->sram_max_volt);
> return ret;
> }
> - } else if (pre_voltage > new_voltage) {
> + } else {
> voltage = max(new_voltage,
> pre_vsram - soc_data->max_volt_shift);
> ret = regulator_set_voltage(drv->proc_reg, voltage,
> --
> 2.34.1
>
>
--
Best Regards,
Chanwoo Choi
Samsung Electronics
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-07 1:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-03 12:14 [PATCH] PM / devfreq: mtk-cci: avoid redundant conditions Liao Yuanhong
2025-09-04 15:32 ` Markus Elfring
2025-09-07 1:34 ` Chanwoo Choi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox