From patchwork Mon Oct 26 01:50:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bernard Zhao X-Patchwork-Id: 11855623 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D01BD14B2 for ; Mon, 26 Oct 2020 01:58:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE77320857 for ; Mon, 26 Oct 2020 01:58:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1421299AbgJZB6F (ORCPT ); Sun, 25 Oct 2020 21:58:05 -0400 Received: from m176150.mail.qiye.163.com ([59.111.176.150]:37991 "EHLO m176150.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439840AbgJZB6F (ORCPT ); Sun, 25 Oct 2020 21:58:05 -0400 X-Greylist: delayed 483 seconds by postgrey-1.27 at vger.kernel.org; Sun, 25 Oct 2020 21:58:04 EDT Received: from vivo.com (wm-10.qy.internal [127.0.0.1]) by m176150.mail.qiye.163.com (Hmail) with ESMTP id 2331F1A132E; Mon, 26 Oct 2020 09:50:22 +0800 (CST) Message-ID: To: Lukasz Luba , Zhang Rui , Daniel Lezcano , Amit Kucheria , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Bernard Zhao Subject: =?utf-8?q?=5BResend=5D=5BPATCH=5D_drivers/thermal=3A_remove_unneces?= =?utf-8?q?sary_structure_members_allocated=5Ftzp?= X-Priority: 3 X-Mailer: HMail Webmail Server V2.0 Copyright (c) 2016-163.com X-Originating-IP: 157.0.31.124 MIME-Version: 1.0 Received: from bernard@vivo.com( [157.0.31.124) ] by ajax-webmail ( [127.0.0.1] ) ; Mon, 26 Oct 2020 09:50:21 +0800 (GMT+08:00) From: Bernard Date: Mon, 26 Oct 2020 09:50:21 +0800 (GMT+08:00) X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZSh9OSUpMHUlJHRpCVkpNS0hNTExLSUlJQ05VEwETFhoSFyQUDg9ZV1kWGg8SFR0UWU FZT0tIVUpKS0hKTFVLWQY+ X-HM-Sender-Digest: e1kMHhlZQQ8JDh5XWRIfHhUPWUFZRzorOjoxDDg8PywVKg0OMRYpDjpO CU8LDVVKVUpNS0hNTExLSUlDTUtVMxYaEhdVGR4JFRoJHzsNEg0UVRgUFkVZV1kSC1lBWUpOTFVL VUhKVUpJT1lXWQgBWUFPSk9PNwY+ X-HM-Tid: 0a75629967d393b4kuws2331f1a132e Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 --- 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;