linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Resend][PATCH] drivers/thermal: remove unnecessary structure members allocated_tzp
@ 2020-10-26  1:50 Bernard
  2020-10-26 18:48 ` Daniel Lezcano
  0 siblings, 1 reply; 2+ messages in thread
From: Bernard @ 2020-10-26  1:50 UTC (permalink / raw)
  To: Lukasz Luba, Zhang Rui, Daniel Lezcano, Amit Kucheria, linux-pm,
	linux-kernel
  Cc: opensource.kernel, Bernard Zhao

Struct power_allocator_params element allocated_tzp is only used
in unbind to kfree the kzalloc space.
Maybe we don’t have to need this member to mark, also, kfree will
handle NULL point, there is no risk.
This change is to make the code run a bit fast.

Signed-off-by: Bernard Zhao <bernard@vivo.com>
---
 drivers/thermal/gov_power_allocator.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
index 5cb518d8f156..e4672a94e6b1 100644
--- a/drivers/thermal/gov_power_allocator.c
+++ b/drivers/thermal/gov_power_allocator.c
@@ -51,8 +51,6 @@ static inline s64 div_frac(s64 x, s64 y)
 
 /**
  * struct power_allocator_params - parameters for the power allocator governor
- * @allocated_tzp:	whether we have allocated tzp for this thermal zone and
- *			it needs to be freed on unbind
  * @err_integral:	accumulated error in the PID controller.
  * @prev_err:	error in the previous iteration of the PID controller.
  *		Used to calculate the derivative term.
@@ -65,7 +63,6 @@ static inline s64 div_frac(s64 x, s64 y)
  *					controlling for.
  */
 struct power_allocator_params {
-	bool allocated_tzp;
 	s64 err_integral;
 	s32 prev_err;
 	int trip_switch_on;
@@ -556,8 +553,6 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
 			ret = -ENOMEM;
 			goto free_params;
 		}
-
-		params->allocated_tzp = true;
 	}
 
 	if (!tz->tzp->sustainable_power)
@@ -593,10 +588,8 @@ static void power_allocator_unbind(struct thermal_zone_device *tz)
 
 	dev_dbg(&tz->device, "Unbinding from thermal zone %d\n", tz->id);
 
-	if (params->allocated_tzp) {
-		kfree(tz->tzp);
-		tz->tzp = NULL;
-	}
+	kfree(tz->tzp);
+	tz->tzp = NULL;
 
 	kfree(tz->governor_data);
 	tz->governor_data = NULL;
-- 
2.28.0




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

* Re: [Resend][PATCH] drivers/thermal: remove unnecessary structure members allocated_tzp
  2020-10-26  1:50 [Resend][PATCH] drivers/thermal: remove unnecessary structure members allocated_tzp Bernard
@ 2020-10-26 18:48 ` Daniel Lezcano
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Lezcano @ 2020-10-26 18:48 UTC (permalink / raw)
  To: Bernard, Lukasz Luba, Zhang Rui, Amit Kucheria, linux-pm, linux-kernel
  Cc: opensource.kernel

On 26/10/2020 02:50, Bernard wrote:
> Struct power_allocator_params element allocated_tzp is only used
> in unbind to kfree the kzalloc space.
> Maybe we don’t have to need this member to mark, also, kfree will
> handle NULL point, there is no risk.
> This change is to make the code run a bit fast.
> 
> Signed-off-by: Bernard Zhao <bernard@vivo.com>

Applied, thanks

[ ... ]

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

end of thread, other threads:[~2020-10-26 18:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26  1:50 [Resend][PATCH] drivers/thermal: remove unnecessary structure members allocated_tzp Bernard
2020-10-26 18:48 ` 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).