[PATCH 1/3] cpufreq: Allow passing NULL as the argument for unregistering a driver

From: Mario Limonciello
Date: Fri Mar 25 2022 - 01:42:15 EST


Currently the arguments passed to `cpufreq_unregister_driver` are matched
against the currently registered driver.

This means that the only way for a driver to be unregistered is if it's
module is unloaded. Loosen that restriction to allow other kernel modules
to unregister a registered driver.

Signed-off-by: Mario Limonciello <mario.limonciello@xxxxxxx>
---
drivers/cpufreq/cpufreq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 80f535cc8a75..4711c17a89bb 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2885,10 +2885,10 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)
{
unsigned long flags;

- if (!cpufreq_driver || (driver != cpufreq_driver))
+ if (!cpufreq_driver)
return -EINVAL;

- pr_debug("unregistering driver %s\n", driver->name);
+ pr_debug("unregistering driver %s\n", cpufreq_driver->name);

/* Protect against concurrent cpu hotplug */
cpus_read_lock();
--
2.34.1