* [PATCH] drivers/thermal: remove unnecessary structure members allocated_tzp
@ 2020-10-17 2:44 Bernard Zhao
0 siblings, 0 replies; only message in thread
From: Bernard Zhao @ 2020-10-17 2:44 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 [flat|nested] only message in thread
only message in thread, other threads:[~2020-10-17 6:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-17 2:44 [PATCH] drivers/thermal: remove unnecessary structure members allocated_tzp Bernard Zhao
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®