linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] PM / devfreq: tegra30: use min to simplify actmon_cpu_to_emc_rate
@ 2025-10-13 13:18 Thorsten Blum
  2025-10-13 16:58 ` Dmitry Osipenko
  0 siblings, 1 reply; 5+ messages in thread
From: Thorsten Blum @ 2025-10-13 13:18 UTC (permalink / raw)
  To: Dmitry Osipenko, MyungJoo Ham, Kyungmin Park, Chanwoo Choi,
	Thierry Reding, Jonathan Hunter
  Cc: Thorsten Blum, linux-pm, linux-tegra, linux-kernel

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

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/devfreq/tegra30-devfreq.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/devfreq/tegra30-devfreq.c b/drivers/devfreq/tegra30-devfreq.c
index 4a4f0106ab9d..2c9813bd697e 100644
--- a/drivers/devfreq/tegra30-devfreq.c
+++ b/drivers/devfreq/tegra30-devfreq.c
@@ -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;
 }
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH RESEND] PM / devfreq: tegra30: use min to simplify actmon_cpu_to_emc_rate
  2025-10-13 13:18 Thorsten Blum
@ 2025-10-13 16:58 ` Dmitry Osipenko
  0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Osipenko @ 2025-10-13 16:58 UTC (permalink / raw)
  To: Thorsten Blum, MyungJoo Ham, Kyungmin Park, Chanwoo Choi,
	Thierry Reding, Jonathan Hunter
  Cc: linux-pm, linux-tegra, linux-kernel

13.10.2025 16:18, Thorsten Blum пишет:
> Use min() to improve the readability of actmon_cpu_to_emc_rate() and
> remove any unnecessary curly braces.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  drivers/devfreq/tegra30-devfreq.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/devfreq/tegra30-devfreq.c b/drivers/devfreq/tegra30-devfreq.c
> index 4a4f0106ab9d..2c9813bd697e 100644
> --- a/drivers/devfreq/tegra30-devfreq.c
> +++ b/drivers/devfreq/tegra30-devfreq.c
> @@ -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;
>  }

Reviewed-by: Dmitry Osipenko <digetx@gmail.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH RESEND] PM / devfreq: tegra30: use min to simplify actmon_cpu_to_emc_rate
@ 2025-11-12 17:21 Thorsten Blum
  2025-11-14 13:12 ` Thierry Reding
  2025-11-23 15:04 ` Chanwoo Choi
  0 siblings, 2 replies; 5+ messages in thread
From: Thorsten Blum @ 2025-11-12 17:21 UTC (permalink / raw)
  To: Dmitry Osipenko, MyungJoo Ham, Kyungmin Park, Chanwoo Choi,
	Thierry Reding, Jonathan Hunter
  Cc: Thorsten Blum, linux-pm, linux-tegra, linux-kernel

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

Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/devfreq/tegra30-devfreq.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/devfreq/tegra30-devfreq.c b/drivers/devfreq/tegra30-devfreq.c
index 4a4f0106ab9d..2c9813bd697e 100644
--- a/drivers/devfreq/tegra30-devfreq.c
+++ b/drivers/devfreq/tegra30-devfreq.c
@@ -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;
 }
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH RESEND] PM / devfreq: tegra30: use min to simplify actmon_cpu_to_emc_rate
  2025-11-12 17:21 [PATCH RESEND] PM / devfreq: tegra30: use min to simplify actmon_cpu_to_emc_rate Thorsten Blum
@ 2025-11-14 13:12 ` Thierry Reding
  2025-11-23 15:04 ` Chanwoo Choi
  1 sibling, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2025-11-14 13:12 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Dmitry Osipenko, MyungJoo Ham, Kyungmin Park, Chanwoo Choi,
	Jonathan Hunter, linux-pm, linux-tegra, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 453 bytes --]

On Wed, Nov 12, 2025 at 06:21:21PM +0100, Thorsten Blum wrote:
> Use min() to improve the readability of actmon_cpu_to_emc_rate() and
> remove any unnecessary curly braces.
> 
> Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  drivers/devfreq/tegra30-devfreq.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)

Acked-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH RESEND] PM / devfreq: tegra30: use min to simplify actmon_cpu_to_emc_rate
  2025-11-12 17:21 [PATCH RESEND] PM / devfreq: tegra30: use min to simplify actmon_cpu_to_emc_rate Thorsten Blum
  2025-11-14 13:12 ` Thierry Reding
@ 2025-11-23 15:04 ` Chanwoo Choi
  1 sibling, 0 replies; 5+ messages in thread
From: Chanwoo Choi @ 2025-11-23 15:04 UTC (permalink / raw)
  To: Thorsten Blum, Dmitry Osipenko, MyungJoo Ham, Kyungmin Park,
	Chanwoo Choi, Thierry Reding, Jonathan Hunter
  Cc: linux-pm, linux-tegra, linux-kernel

Hi,

Applied it. Thanks,

25. 11. 13. 02:21에 Thorsten Blum 이(가) 쓴 글:
> Use min() to improve the readability of actmon_cpu_to_emc_rate() and
> remove any unnecessary curly braces.
> 
> Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  drivers/devfreq/tegra30-devfreq.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/devfreq/tegra30-devfreq.c b/drivers/devfreq/tegra30-devfreq.c
> index 4a4f0106ab9d..2c9813bd697e 100644
> --- a/drivers/devfreq/tegra30-devfreq.c
> +++ b/drivers/devfreq/tegra30-devfreq.c
> @@ -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;
>  }

-- 
Best Regards,
Samsung Electronics
Chanwoo Choi


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-11-23 15:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-12 17:21 [PATCH RESEND] PM / devfreq: tegra30: use min to simplify actmon_cpu_to_emc_rate Thorsten Blum
2025-11-14 13:12 ` Thierry Reding
2025-11-23 15:04 ` Chanwoo Choi
  -- strict thread matches above, loose matches on Subject: below --
2025-10-13 13:18 Thorsten Blum
2025-10-13 16:58 ` Dmitry Osipenko

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).