From d5ffed635b7181caba66886a213e2753bd3a9fbf Mon Sep 17 00:00:00 2001 From: wangjianyu3 Date: Mon, 25 Dec 2023 16:15:51 +0800 Subject: [PATCH] Thermal/dummy: Get cpufreq_driver from cpufreq_policy. Signed-off-by: wangjianyu3 --- drivers/thermal/thermal_dummy.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/thermal/thermal_dummy.c b/drivers/thermal/thermal_dummy.c index c8d40d3319..1cda6ccf0a 100644 --- a/drivers/thermal/thermal_dummy.c +++ b/drivers/thermal/thermal_dummy.c @@ -55,7 +55,7 @@ struct dummy_cpufreq_driver_s struct cpufreq_driver driver; const struct cpufreq_frequency_table *table; size_t table_len; - int current; + struct cpufreq_frequency_table current; }; /**************************************************************************** @@ -268,31 +268,32 @@ static int dummy_zdev_set_trips(FAR struct thermal_zone_device_s *zdev, #ifdef CONFIG_THERMAL_DUMMY_CPUFREQ static FAR const struct cpufreq_frequency_table *dummy_cpufreq_get_table( - FAR struct cpufreq_policy *driver) + FAR struct cpufreq_policy *policy) { - FAR struct dummy_cpufreq_driver_s **dummy = - (FAR struct dummy_cpufreq_driver_s **)driver; - return (*dummy)->table; + FAR struct dummy_cpufreq_driver_s *driver = + (FAR struct dummy_cpufreq_driver_s *)policy->driver; + + return driver->table; } -static int dummy_cpufreq_target_index(FAR struct cpufreq_policy *driver, +static int dummy_cpufreq_target_index(FAR struct cpufreq_policy *policy, unsigned int index) { - FAR struct dummy_cpufreq_driver_s **dummy = - (FAR struct dummy_cpufreq_driver_s **)driver; + FAR struct dummy_cpufreq_driver_s *driver = + (FAR struct dummy_cpufreq_driver_s *)policy->driver; - DEBUGASSERT(index < (*dummy)->table_len); + DEBUGASSERT(index < driver->table_len); - (*dummy)->current = (*dummy)->table[index].frequency; + driver->current.frequency = driver->table[index].frequency; return 0; } -static int dummy_cpufreq_get_frequency(FAR struct cpufreq_policy *driver) +static int dummy_cpufreq_get_frequency(FAR struct cpufreq_policy *policy) { - FAR struct dummy_cpufreq_driver_s **dummy = - (FAR struct dummy_cpufreq_driver_s **)driver; + FAR struct dummy_cpufreq_driver_s *driver = + (FAR struct dummy_cpufreq_driver_s *)policy->driver; - return (*dummy)->current; + return driver->current.frequency; } static int dummy_cpufreq_suspend(FAR struct cpufreq_policy *driver)