All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lizhe <sensor1010@163.com>
To: ray.huang@amd.com, rafael@kernel.org, viresh.kumar@linaro.org,
	srinivas.pandruvada@linux.intel.com, lenb@kernel.org,
	andersson@kernel.org, konrad.dybcio@linaro.org,
	thierry.reding@gmail.com, jonathanh@nvidia.com
Cc: linux-pm@vger.kernel.org, inux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org,
	Lizhe <sensor1010@163.com>
Subject: [PATCH] cpufreq: Covert to offline callback returning void
Date: Thu, 11 Apr 2024 08:06:20 -0700	[thread overview]
Message-ID: <20240411150620.19262-1-sensor1010@163.com> (raw)

For the offline() callback function returning an int type value,
this leads many driver authors mistakenly believing that error
handling can be performed by returning an error code, However
the returned value is ignored, and to improve this situation,
it is proposed to modify the return type of the offline() callback
function to void.

Signed-off-by: Lizhe <sensor1010@163.com>
---
 drivers/cpufreq/amd-pstate.c       |  4 +---
 drivers/cpufreq/cpufreq.c          |  3 +--
 drivers/cpufreq/intel_pstate.c     | 10 ++++------
 drivers/cpufreq/qcom-cpufreq-hw.c  |  6 ++----
 drivers/cpufreq/tegra194-cpufreq.c | 11 -----------
 include/linux/cpufreq.h            |  2 +-
 6 files changed, 9 insertions(+), 27 deletions(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 2015c9fcc3c9..036608935aaa 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -1530,7 +1530,7 @@ static void amd_pstate_epp_offline(struct cpufreq_policy *policy)
 	mutex_unlock(&amd_pstate_limits_lock);
 }
 
-static int amd_pstate_epp_cpu_offline(struct cpufreq_policy *policy)
+static void amd_pstate_epp_cpu_offline(struct cpufreq_policy *policy)
 {
 	struct amd_cpudata *cpudata = policy->driver_data;
 
@@ -1541,8 +1541,6 @@ static int amd_pstate_epp_cpu_offline(struct cpufreq_policy *policy)
 
 	if (cppc_state == AMD_PSTATE_ACTIVE)
 		amd_pstate_epp_offline(policy);
-
-	return 0;
 }
 
 static int amd_pstate_epp_verify_policy(struct cpufreq_policy_data *policy)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 66e10a19d76a..04d349372de3 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1685,7 +1685,7 @@ static void __cpufreq_offline(unsigned int cpu, struct cpufreq_policy *policy)
 	}
 }
 
-static int cpufreq_offline(unsigned int cpu)
+static void cpufreq_offline(unsigned int cpu)
 {
 	struct cpufreq_policy *policy;
 
@@ -1702,7 +1702,6 @@ static int cpufreq_offline(unsigned int cpu)
 	__cpufreq_offline(cpu, policy);
 
 	up_write(&policy->rwsem);
-	return 0;
 }
 
 /*
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index dbbf299f4219..80dfe1c20210 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -2679,14 +2679,14 @@ static int intel_pstate_verify_policy(struct cpufreq_policy_data *policy)
 	return 0;
 }
 
-static int intel_cpufreq_cpu_offline(struct cpufreq_policy *policy)
+static void intel_cpufreq_cpu_offline(struct cpufreq_policy *policy)
 {
 	struct cpudata *cpu = all_cpu_data[policy->cpu];
 
 	pr_debug("CPU %d going offline\n", cpu->cpu);
 
 	if (cpu->suspended)
-		return 0;
+		return;
 
 	/*
 	 * If the CPU is an SMT thread and it goes offline with the performance
@@ -2700,8 +2700,6 @@ static int intel_cpufreq_cpu_offline(struct cpufreq_policy *policy)
 		intel_pstate_set_min_pstate(cpu);
 
 	intel_pstate_exit_perf_limits(policy);
-
-	return 0;
 }
 
 static int intel_pstate_cpu_online(struct cpufreq_policy *policy)
@@ -2724,11 +2722,11 @@ static int intel_pstate_cpu_online(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static int intel_pstate_cpu_offline(struct cpufreq_policy *policy)
+static void intel_pstate_cpu_offline(struct cpufreq_policy *policy)
 {
 	intel_pstate_clear_update_util_hook(policy->cpu);
 
-	return intel_cpufreq_cpu_offline(policy);
+	intel_cpufreq_cpu_offline(policy);
 }
 
 static int intel_pstate_cpu_exit(struct cpufreq_policy *policy)
diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c
index 70b0f21968a0..dc35fa3cc3ce 100644
--- a/drivers/cpufreq/qcom-cpufreq-hw.c
+++ b/drivers/cpufreq/qcom-cpufreq-hw.c
@@ -482,12 +482,12 @@ static int qcom_cpufreq_hw_cpu_online(struct cpufreq_policy *policy)
 	return ret;
 }
 
-static int qcom_cpufreq_hw_cpu_offline(struct cpufreq_policy *policy)
+static void qcom_cpufreq_hw_cpu_offline(struct cpufreq_policy *policy)
 {
 	struct qcom_cpufreq_data *data = policy->driver_data;
 
 	if (data->throttle_irq <= 0)
-		return 0;
+		return;
 
 	mutex_lock(&data->throttle_lock);
 	data->cancel_throttle = true;
@@ -496,8 +496,6 @@ static int qcom_cpufreq_hw_cpu_offline(struct cpufreq_policy *policy)
 	cancel_delayed_work_sync(&data->throttle_work);
 	irq_set_affinity_and_hint(data->throttle_irq, NULL);
 	disable_irq_nosync(data->throttle_irq);
-
-	return 0;
 }
 
 static void qcom_cpufreq_hw_lmh_exit(struct qcom_cpufreq_data *data)
diff --git a/drivers/cpufreq/tegra194-cpufreq.c b/drivers/cpufreq/tegra194-cpufreq.c
index 59865ea455a8..8b57dcd43d54 100644
--- a/drivers/cpufreq/tegra194-cpufreq.c
+++ b/drivers/cpufreq/tegra194-cpufreq.c
@@ -541,16 +541,6 @@ static int tegra194_cpufreq_online(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static int tegra194_cpufreq_offline(struct cpufreq_policy *policy)
-{
-	/*
-	 * Preserve policy->driver_data and don't free resources on light-weight
-	 * tear down.
-	 */
-
-	return 0;
-}
-
 static int tegra194_cpufreq_exit(struct cpufreq_policy *policy)
 {
 	struct device *cpu_dev = get_cpu_device(policy->cpu);
@@ -590,7 +580,6 @@ static struct cpufreq_driver tegra194_cpufreq_driver = {
 	.init = tegra194_cpufreq_init,
 	.exit = tegra194_cpufreq_exit,
 	.online = tegra194_cpufreq_online,
-	.offline = tegra194_cpufreq_offline,
 	.attr = cpufreq_generic_attr,
 };
 
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 9956afb9acc2..2472e9fd2df9 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -385,7 +385,7 @@ struct cpufreq_driver {
 	int		(*bios_limit)(int cpu, unsigned int *limit);
 
 	int		(*online)(struct cpufreq_policy *policy);
-	int		(*offline)(struct cpufreq_policy *policy);
+	void		(*offline)(struct cpufreq_policy *policy);
 	int		(*exit)(struct cpufreq_policy *policy);
 	int		(*suspend)(struct cpufreq_policy *policy);
 	int		(*resume)(struct cpufreq_policy *policy);
-- 
2.25.1


             reply	other threads:[~2024-04-11 15:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11 15:06 Lizhe [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-04-11 15:05 [PATCH] cpufreq: Covert to offline callback returning void Lizhe

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=20240411150620.19262-1-sensor1010@163.com \
    --to=sensor1010@163.com \
    --cc=andersson@kernel.org \
    --cc=inux-kernel@vger.kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=konrad.dybcio@linaro.org \
    --cc=lenb@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=ray.huang@amd.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=thierry.reding@gmail.com \
    --cc=viresh.kumar@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.