Skip to contentSkip to conversation

PM / devfreq: tegra30: use min to simplify actmon_cpu_to_emc_rate

PATCH RESEND Superseded Thorsten Blum 2 participants 2 messages Oct 13, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 PM / devfreq: tegra30: use min to simplify actmon_cpu_to_emc_rate

Use min() to improve the readability of actmon_cpu_to_emc_rate() and remove any unnecessary curly braces.

---
 drivers/devfreq/tegra30-devfreq.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/devfreq/tegra30-devfreq.c +4 -8
index 4a4f0106ab9d..2c9813bd697e 100644
@@ -12,6 +12,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/irq.h>
+#include <linux/minmax.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
@@ -326,14 +327,9 @@ static unsigned long actmon_cpu_to_emc_rate(struct tegra_devfreq *tegra,
 	unsigned int i;
 	const struct tegra_actmon_emc_ratio *ratio = actmon_emc_ratios;
 
-	for (i = 0; i < ARRAY_SIZE(actmon_emc_ratios); i++, ratio++) {
-		if (cpu_freq >= ratio->cpu_freq) {
-			if (ratio->emc_freq >= tegra->max_freq)
-				return tegra->max_freq;
-			else
-				return ratio->emc_freq;
-		}
-	}
+	for (i = 0; i < ARRAY_SIZE(actmon_emc_ratios); i++, ratio++)
+		if (cpu_freq >= ratio->cpu_freq)
+			return min(ratio->emc_freq, tegra->max_freq);
 
 	return 0;
 }
Signature · 1 line
2.51.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

13.10.2025 16:18, Thorsten Blum пишет:

Quoted 28 lines

Use min() to improve the readability of actmon_cpu_to_emc_rate() and remove any unnecessary curly braces.

---
 drivers/devfreq/tegra30-devfreq.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/devfreq/tegra30-devfreq.c +1 -4
index 4a4f0106ab9d..2c9813bd697e 100644
@@ -12,6 +12,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/irq.h>
+#include <linux/minmax.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
@@ -326,14 +327,9 @@ static unsigned long actmon_cpu_to_emc_rate(struct tegra_devfreq *tegra,
 	unsigned int i;
 	const struct tegra_actmon_emc_ratio *ratio = actmon_emc_ratios;
 
-	for (i = 0; i < ARRAY_SIZE(actmon_emc_ratios); i++, ratio++) {
-		if (cpu_freq >= ratio->cpu_freq) {
-			if (ratio->emc_freq >= tegra->max_freq)
-				return tegra->max_freq;

drivers/devfreq/tegra30-devfreq.c static unsigned long actmon_cpu_to_emc_rate(struct tegra_devfreq *tegra, · line 335

Quoted 10 lines
drivers/devfreq/tegra30-devfreq.c +3 -4
-			else
-				return ratio->emc_freq;
-		}
-	}
+	for (i = 0; i < ARRAY_SIZE(actmon_emc_ratios); i++, ratio++)
+		if (cpu_freq >= ratio->cpu_freq)
+			return min(ratio->emc_freq, tegra->max_freq);
 
 	return 0;
 }