cpufreq: acpi_cpufreq: base frequency attribute support

Message ID 20160302023822.GM16437@vireshk-i7
State New
Headers show

Commit Message

Viresh Kumar March 2, 2016, 2:38 a.m.
On 01-03-16, 10:10, Srinivas Pandruvada wrote:
> > What about:

> > 

> >                                 acpi_cpufreq_attr[ARRAY_SIZE(acpi_cpu

> > freq_attr) - 2] = &base_frequency;

> > 

> >                                 and a comment to describe that ?

> > 

> Will it work in this case?

> "

> Even if CONFIG_X86_ACPI_CPUFREQ_CPB is defined, 

> acpi_cpufreq_attr[2] will be set to NULL in the init callback when

> some condition fails. So we will have a NULL in the acpi_cpufreq_attr[]

> before &base_frequency if we add at fixed place. 

> "


Oh dude, you already have this hack in place in a different way. Though its
doable this way:


And then the above statement:

acpi_cpufreq_attr[ARRAY_SIZE(acpi_cpufreq_attr) - 2 - cpb_removed] = &base_frequency;

But I would rather add another patch first to set the CPB thing in the array to
NULL and remove the ifdef from within the array. And then set it to a valid
attribute only if we are making an addition. And then you can easily keep a
count of the next NULL entry you can update.

-- 
viresh
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index 51eef87bbc37..26c026a34e1e 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -937,7 +937,7 @@  static void acpi_cpufreq_boost_exit(void)
 
 static int __init acpi_cpufreq_init(void)
 {
-       int ret;
+       int ret, cpb_removed = 0;
 
        if (acpi_disabled)
                return -ENODEV;
@@ -967,6 +967,7 @@  static int __init acpi_cpufreq_init(void)
                for (attr = acpi_cpufreq_attr; *attr; attr++)
                        if (*attr == &cpb) {
                                *attr = NULL;
+                               cpb_removed = 1;
                                break;
                        }
        }