linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Resend][PATCH] drivers/thermal: optimize the for circle to run a bit fast
@ 2020-10-26  1:49 Bernard
  2020-10-26 18:35 ` Daniel Lezcano
  0 siblings, 1 reply; 4+ messages in thread
From: Bernard @ 2020-10-26  1:49 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>
---
 drivers/thermal/thermal_core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index c6d74bc1c90b..03577794eea3 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1446,10 +1446,14 @@ 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))
+		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))
+			continue;
+		}
+		if (tz->ops->get_trip_temp(tz, count, &trip_temp)) {
 			set_bit(count, &tz->trips_disabled);
+			continue;
+		}
 		/* Check for bogus trip points */
 		if (trip_temp == 0)
 			set_bit(count, &tz->trips_disabled);
-- 
2.28.0




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

* Re: [Resend][PATCH] drivers/thermal: optimize the for circle to run a bit fast
  2020-10-26  1:49 [Resend][PATCH] drivers/thermal: optimize the for circle to run a bit fast Bernard
@ 2020-10-26 18:35 ` Daniel Lezcano
  2020-10-27  1:19   ` Bernard
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Lezcano @ 2020-10-26 18:35 UTC (permalink / raw)
  To: Bernard, Zhang Rui, Amit Kucheria, linux-pm, linux-kernel
  Cc: opensource.kernel

On 26/10/2020 02:49, Bernard 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>
> ---
>  drivers/thermal/thermal_core.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index c6d74bc1c90b..03577794eea3 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -1446,10 +1446,14 @@ 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))
> +		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))
> +			continue;
> +		}
> +		if (tz->ops->get_trip_temp(tz, count, &trip_temp)) {
>  			set_bit(count, &tz->trips_disabled);
> +			continue;
> +		}
>  		/* Check for bogus trip points */
>  		if (trip_temp == 0)
>  			set_bit(count, &tz->trips_disabled);


What about ?

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




-- 
<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] 4+ messages in thread

* Re:Re: [Resend][PATCH] drivers/thermal: optimize the for circle to run a bit fast
  2020-10-26 18:35 ` Daniel Lezcano
@ 2020-10-27  1:19   ` Bernard
  2020-10-27  8:47     ` Daniel Lezcano
  0 siblings, 1 reply; 4+ messages in thread
From: Bernard @ 2020-10-27  1:19 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Zhang Rui, Amit Kucheria, linux-pm, linux-kernel, opensource.kernel


From: Daniel Lezcano <daniel.lezcano@linaro.org>
Date: 2020-10-27 02:35:18
To:  Bernard <bernard@vivo.com>,Zhang Rui <rui.zhang@intel.com>,Amit Kucheria <amitk@kernel.org>,linux-pm@vger.kernel.org,linux-kernel@vger.kernel.org
Cc:  opensource.kernel@vivo.com
Subject: Re: [Resend][PATCH] drivers/thermal: optimize the for circle to run a bit fast>On 26/10/2020 02:49, Bernard 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>
>> ---
>>  drivers/thermal/thermal_core.c | 8 ++++++--
>>  1 file changed, 6 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
>> index c6d74bc1c90b..03577794eea3 100644
>> --- a/drivers/thermal/thermal_core.c
>> +++ b/drivers/thermal/thermal_core.c
>> @@ -1446,10 +1446,14 @@ 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))
>> +		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))
>> +			continue;
>> +		}
>> +		if (tz->ops->get_trip_temp(tz, count, &trip_temp)) {
>>  			set_bit(count, &tz->trips_disabled);
>> +			continue;
>> +		}
>>  		/* Check for bogus trip points */
>>  		if (trip_temp == 0)
>>  			set_bit(count, &tz->trips_disabled);
>
>
>What about ?
>	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);
>

Hi

  Sure, I will resubmit this patch, thanks!

BR//Bernard

>
>
>-- 
><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] 4+ messages in thread

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

On 27/10/2020 02:19, Bernard wrote:
> 
> From: Daniel Lezcano <daniel.lezcano@linaro.org>
> Date: 2020-10-27 02:35:18
> To:  Bernard <bernard@vivo.com>,Zhang Rui <rui.zhang@intel.com>,Amit Kucheria <amitk@kernel.org>,linux-pm@vger.kernel.org,linux-kernel@vger.kernel.org
> Cc:  opensource.kernel@vivo.com
> Subject: Re: [Resend][PATCH] drivers/thermal: optimize the for circle to run a bit fast>On 26/10/2020 02:49, Bernard 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>
>>> ---
>>>  drivers/thermal/thermal_core.c | 8 ++++++--
>>>  1 file changed, 6 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
>>> index c6d74bc1c90b..03577794eea3 100644
>>> --- a/drivers/thermal/thermal_core.c
>>> +++ b/drivers/thermal/thermal_core.c
>>> @@ -1446,10 +1446,14 @@ 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))
>>> +		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))
>>> +			continue;
>>> +		}
>>> +		if (tz->ops->get_trip_temp(tz, count, &trip_temp)) {
>>>  			set_bit(count, &tz->trips_disabled);
>>> +			continue;
>>> +		}
>>>  		/* Check for bogus trip points */
>>>  		if (trip_temp == 0)
>>>  			set_bit(count, &tz->trips_disabled);
>>
>>
>> What about ?
>> 	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);
>>
> 
> Hi
> 
>   Sure, I will resubmit this patch, thanks!

Please, take the opportunity to fix the author name to be the same as
the signed-off-by.

Thanks

  -- Daniel



-- 
<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] 4+ messages in thread

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26  1:49 [Resend][PATCH] drivers/thermal: optimize the for circle to run a bit fast Bernard
2020-10-26 18:35 ` Daniel Lezcano
2020-10-27  1:19   ` Bernard
2020-10-27  8:47     ` Daniel Lezcano

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