All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-pm@vger.kernel.org,
	Vincent Guittot <vincent.guittot@linaro.org>,
	sensor1010@163.com, linux-kernel@vger.kernel.org
Subject: [PATCH] cpufreq: exit() callback is optional
Date: Fri, 12 Apr 2024 11:19:20 +0530	[thread overview]
Message-ID: <b97964653d02225f061e0c2a650b365c354b98c8.1712900945.git.viresh.kumar@linaro.org> (raw)

The exit() callback is optional and shouldn't be called without checking
a valid pointer first.

Also, we must clear freq_table pointer even if the exit() callback isn't
present.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 66e10a19d76a..fd9c3ed21f49 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1679,10 +1679,13 @@ static void __cpufreq_offline(unsigned int cpu, struct cpufreq_policy *policy)
 	 */
 	if (cpufreq_driver->offline) {
 		cpufreq_driver->offline(policy);
-	} else if (cpufreq_driver->exit) {
-		cpufreq_driver->exit(policy);
-		policy->freq_table = NULL;
+		return;
 	}
+
+	if (cpufreq_driver->exit)
+		cpufreq_driver->exit(policy);
+
+	policy->freq_table = NULL;
 }
 
 static int cpufreq_offline(unsigned int cpu)
@@ -1740,7 +1743,7 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
 	}
 
 	/* We did light-weight exit earlier, do full tear down now */
-	if (cpufreq_driver->offline)
+	if (cpufreq_driver->offline && cpufreq_driver->exit)
 		cpufreq_driver->exit(policy);
 
 	up_write(&policy->rwsem);
-- 
2.31.1.272.g89b43f80a514


             reply	other threads:[~2024-04-12  5:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-12  5:49 Viresh Kumar [this message]
     [not found] ` <5759bc29.32d04.18ed0ef5037.Coremail.sensor1010@163.com>
2024-04-12  6:24   ` [PATCH] cpufreq: exit() callback is optional Viresh Kumar
     [not found]     ` <1b53a162.32e95.18ed0fdb13e.Coremail.sensor1010@163.com>
2024-04-12  6:32       ` Viresh Kumar
     [not found]         ` <2117690204.533771.1712904398042.JavaMail.root@mail-tracker-145-3ep34-c9h23-5f64cf7787-82gdh>
2024-04-12  7:57           ` Greg KH
     [not found]             ` <663acff5.349d4.18ed18da6ff.Coremail.sensor1010@163.com>
2024-04-12  9:14               ` Greg KH
2024-04-12  9:23                 ` Viresh Kumar
2024-04-12  9:21               ` Viresh Kumar
2024-04-12 10:28                 ` Greg KH
     [not found]                   ` <28e13fe5.bc4.18ed2962985.Coremail.sensor1010@163.com>
2024-04-12 14:31                     ` lizhe
2024-04-12 14:41                     ` lizhe
2024-04-22 11:21                       ` shuah
     [not found]                         ` <5c601757.54f80.18f05956113.Coremail.sensor1010@163.com>
2024-05-03 21:30                           ` Shuah Khan
     [not found] ` <7bd5d6c1.32db8.18ed0f5e6c3.Coremail.sensor1010@163.com>
2024-04-12  6:27   ` Viresh Kumar
2024-04-12 11:08 ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b97964653d02225f061e0c2a650b365c354b98c8.1712900945.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=sensor1010@163.com \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.