Skip to content

Commit

Permalink
cpufreq: Make cpufreq_unregister_driver() return void
Browse files Browse the repository at this point in the history
All but a few drivers ignore the return value of
cpufreq_unregister_driver(). Those few that don't only call it after
cpufreq_register_driver() succeeded, in which case the call doesn't
fail.

Make the function return no value and add a WARN_ON for the case that
the function is called in an invalid situation (i.e. without a previous
successful call to cpufreq_register_driver()).

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Florian Fainelli <f.fainelli@gmail.com> # brcmstb-avs-cpufreq.c
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Uwe Kleine-König authored and Rafael J. Wysocki committed Feb 9, 2023
1 parent ced3960 commit dd329e1
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 16 deletions.
4 changes: 2 additions & 2 deletions drivers/cpufreq/amd-pstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ static void amd_pstate_driver_cleanup(void)

static int amd_pstate_update_status(const char *buf, size_t size)
{
int ret;
int ret = 0;
int mode_idx;

if (size > 7 || size < 6)
Expand All @@ -844,7 +844,7 @@ static int amd_pstate_update_status(const char *buf, size_t size)
return -EINVAL;
if (cppc_state == AMD_PSTATE_ACTIVE)
return -EBUSY;
ret = cpufreq_unregister_driver(current_pstate_driver);
cpufreq_unregister_driver(current_pstate_driver);
amd_pstate_driver_cleanup();
break;
case AMD_PSTATE_PASSIVE:
Expand Down
5 changes: 1 addition & 4 deletions drivers/cpufreq/brcmstb-avs-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,10 +751,7 @@ static int brcm_avs_cpufreq_probe(struct platform_device *pdev)

static int brcm_avs_cpufreq_remove(struct platform_device *pdev)
{
int ret;

ret = cpufreq_unregister_driver(&brcm_avs_driver);
WARN_ON(ret);
cpufreq_unregister_driver(&brcm_avs_driver);

brcm_avs_prepare_uninit(pdev);

Expand Down
8 changes: 3 additions & 5 deletions drivers/cpufreq/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -2904,12 +2904,12 @@ EXPORT_SYMBOL_GPL(cpufreq_register_driver);
* Returns zero if successful, and -EINVAL if the cpufreq_driver is
* currently not initialised.
*/
int cpufreq_unregister_driver(struct cpufreq_driver *driver)
void cpufreq_unregister_driver(struct cpufreq_driver *driver)
{
unsigned long flags;

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

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

Expand All @@ -2926,8 +2926,6 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)

write_unlock_irqrestore(&cpufreq_driver_lock, flags);
cpus_read_unlock();

return 0;
}
EXPORT_SYMBOL_GPL(cpufreq_unregister_driver);

Expand Down
4 changes: 3 additions & 1 deletion drivers/cpufreq/davinci-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ static int __exit davinci_cpufreq_remove(struct platform_device *pdev)
if (cpufreq.asyncclk)
clk_put(cpufreq.asyncclk);

return cpufreq_unregister_driver(&davinci_driver);
cpufreq_unregister_driver(&davinci_driver);

return 0;
}

static struct platform_driver davinci_cpufreq_driver = {
Expand Down
4 changes: 3 additions & 1 deletion drivers/cpufreq/mediatek-cpufreq-hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ static int mtk_cpufreq_hw_driver_probe(struct platform_device *pdev)

static int mtk_cpufreq_hw_driver_remove(struct platform_device *pdev)
{
return cpufreq_unregister_driver(&cpufreq_mtk_hw_driver);
cpufreq_unregister_driver(&cpufreq_mtk_hw_driver);

return 0;
}

static const struct of_device_id mtk_cpufreq_hw_match[] = {
Expand Down
4 changes: 3 additions & 1 deletion drivers/cpufreq/omap-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ static int omap_cpufreq_probe(struct platform_device *pdev)

static int omap_cpufreq_remove(struct platform_device *pdev)
{
return cpufreq_unregister_driver(&omap_driver);
cpufreq_unregister_driver(&omap_driver);

return 0;
}

static struct platform_driver omap_cpufreq_platdrv = {
Expand Down
4 changes: 3 additions & 1 deletion drivers/cpufreq/qcom-cpufreq-hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,9 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev)

static int qcom_cpufreq_hw_driver_remove(struct platform_device *pdev)
{
return cpufreq_unregister_driver(&cpufreq_qcom_hw_driver);
cpufreq_unregister_driver(&cpufreq_qcom_hw_driver);

return 0;
}

static struct platform_driver qcom_cpufreq_hw_driver = {
Expand Down
2 changes: 1 addition & 1 deletion include/linux/cpufreq.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ struct cpufreq_driver {
#define CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING BIT(6)

int cpufreq_register_driver(struct cpufreq_driver *driver_data);
int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
void cpufreq_unregister_driver(struct cpufreq_driver *driver_data);

bool cpufreq_driver_test_flags(u16 flags);
const char *cpufreq_get_current_driver(void);
Expand Down

0 comments on commit dd329e1

Please sign in to comment.