mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] drivers/thermal: optimize the for circle to run a bit fast
@ 2020-10-27  1:37 Bernard Zhao
  2020-10-27  8:50 ` Daniel Lezcano
  2020-10-27  8:54 ` Daniel Lezcano
  0 siblings, 2 replies; 3+ messages in thread
From: Bernard Zhao @ 2020-10-27  1:37 UTC (permalink / raw)
  To: Zhang Rui, Daniel Lezcano, Amit Kucheria, linux-pm, linux-kernel
  Cc: opensource.kernel, Bernard Zhao

Function thermal_zone_device_register, in the for circle, if the
first if branch set the count bit in tz->trips_disabled, there is
no need to set in the other if branch again.
This change is to make the code run a bit fast and readable.

Signed-off-by: Bernard Zhao <bernard@vivo.com>

Changes since V1:
*make the code more clear and readable

Link for V1:
*https://lore.kernel.org/patchwork/patch/1324507/
---
 drivers/thermal/thermal_core.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index c6d74bc1c90b..3d1e0033bf3e 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1446,12 +1446,9 @@ thermal_zone_device_register(const char *type, int trips, int mask,
 		goto release_device;
 
 	for (count = 0; count < trips; count++) {
-		if (tz->ops->get_trip_type(tz, count, &trip_type))
-			set_bit(count, &tz->trips_disabled);
-		if (tz->ops->get_trip_temp(tz, count, &trip_temp))
-			set_bit(count, &tz->trips_disabled);
-		/* Check for bogus trip points */
-		if (trip_temp == 0)
+		if (tz->ops->get_trip_type(tz, count, &trip_type) ||
+		    tz->ops->get_trip_temp(tz, count, &trip_temp) ||
+		    !trip_temp)
 			set_bit(count, &tz->trips_disabled);
 	}
 
-- 
2.28.0


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

* Re: [PATCH v2] drivers/thermal: optimize the for circle to run a bit fast
  2020-10-27  1:37 [PATCH v2] drivers/thermal: optimize the for circle to run a bit fast Bernard Zhao
@ 2020-10-27  8:50 ` Daniel Lezcano
  2020-10-27  8:54 ` Daniel Lezcano
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Lezcano @ 2020-10-27  8:50 UTC (permalink / raw)
  To: Bernard Zhao, Zhang Rui, Amit Kucheria, linux-pm, linux-kernel
  Cc: opensource.kernel

On 27/10/2020 02:37, Bernard Zhao wrote:
> Function thermal_zone_device_register, in the for circle, if the
> first if branch set the count bit in tz->trips_disabled, there is
> no need to set in the other if branch again.
> This change is to make the code run a bit fast and readable.
> 
> Signed-off-by: Bernard Zhao <bernard@vivo.com>
> 
> Changes since V1:
> *make the code more clear and readable
> 
> Link for V1:
> *https://lore.kernel.org/patchwork/patch/1324507/

When adding a changelog, add it after the signed off separated with a
'---' symbol. So when commiting the patch, the changelog is discarded.


-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

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

* Re: [PATCH v2] drivers/thermal: optimize the for circle to run a bit fast
  2020-10-27  1:37 [PATCH v2] drivers/thermal: optimize the for circle to run a bit fast Bernard Zhao
  2020-10-27  8:50 ` Daniel Lezcano
@ 2020-10-27  8:54 ` Daniel Lezcano
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Lezcano @ 2020-10-27  8:54 UTC (permalink / raw)
  To: Bernard Zhao, Zhang Rui, Amit Kucheria, linux-pm, linux-kernel
  Cc: opensource.kernel

On 27/10/2020 02:37, Bernard Zhao wrote:
> Function thermal_zone_device_register, in the for circle, if the
> first if branch set the count bit in tz->trips_disabled, there is
> no need to set in the other if branch again.
> This change is to make the code run a bit fast and readable.
> 
> Signed-off-by: Bernard Zhao <bernard@vivo.com>
> 
> Changes since V1:
> *make the code more clear and readable
> 
> Link for V1:
> *https://lore.kernel.org/patchwork/patch/1324507/
> ---

Applied with the patch description massaged.

https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git/commit/?h=testing&id=37b2539e63d6570c9ee51b1d48bdecb334df367d


-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

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

end of thread, other threads:[~2020-10-27  8:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-27  1:37 [PATCH v2] drivers/thermal: optimize the for circle to run a bit fast Bernard Zhao
2020-10-27  8:50 ` Daniel Lezcano
2020-10-27  8:54 ` Daniel Lezcano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®