cpufreq (6/7): allow cpufreq drivers to export sysfs files
PATCH 1/1 cpufreq (6/7): allow cpufreq drivers to export sysfs files
----- Forwarded message from Dominik Brodowski <[email protected]> -----
From: Dominik Brodowski <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH] cpufreq (6/7): allow cpufreq drivers to export sysfs files
Date: Fri, 7 Mar 2003 11:09:22 +0100
This patch lets cpufreq drivers export per-CPU files in the cpufreq and cpu-specific sysfs directory. As an example, a file "scaling_available_frequencies" is added to the p4-clockmod.c driver.
Please apply,
Dominik
arch/i386/kernel/cpu/cpufreq/p4-clockmod.c | 7 ++++ drivers/cpufreq/freq_table.c | 50 +++++++++++++++++++++++++++++ include/linux/cpufreq.h | 12 ++++++ kernel/cpufreq.c | 9 ++++- 4 files changed, 77 insertions(+), 1 deletion(-)
arch/i386/kernel/cpu/cpufreq/p4-clockmod.c +7 -0
@@ -214,6 +214,7 @@else p4clockmod_table[i].frequency = (stock_freq * i)/8 ; } +cpufreq_frequency_table_get_attr (p4clockmod_table, policy->cpu);/* cpuinfo and default policy values */ policy->policy =CPUFREQ_POLICY_PERFORMANCE ;
@@ -226,9 +227,14 @@static int cpufreq_p4_cpu_exit (struct cpufreq_policy *policy) { +cpufreq_frequency_table_put_attr (policy->cpu);return cpufreq_p4_setdc (policy->cpu,DC_DISABLE ); } +static struct freq_attr * p4clockmod_attr[] = { + &cpufreq_freq_attr_scaling_available_freqs, +NULL , +};static struct cpufreq_driver p4clockmod_driver = { .verify = cpufreq_p4_verify,
@@ -237,6 +243,7 @@ .exit = cpufreq_p4_cpu_exit, .name = "p4-clockmod", .owner = THIS_MODULE, + .attr = p4clockmod_attr, };
drivers/cpufreq/freq_table.c +50 -0
56 lines not on this page · raw message
include/linux/cpufreq.h +12 -0
@@ -152,6 +152,8 @@#define CPUFREQ_RELATION_L 0/* lowest frequency at or above target */ #define CPUFREQ_RELATION_H 1/* highest frequency below or at target */ +struct freq_attr ; +struct cpufreq_driver {/* needed by all drivers */ int (*verify) (struct cpufreq_policy *policy);
@@ -166,6 +168,7 @@/* optional, for the moment */ int (*init) (struct cpufreq_policy *policy);int (*exit) (struct cpufreq_policy *policy); +struct freq_attr **attr; };int cpufreq_register_driver (struct cpufreq_driver *driver_data);
@@ -298,6 +301,15 @@unsigned int relation, unsigned int *index); +/* the following are really really optional */ +extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; + +void cpufreq_frequency_table_get_attr (struct cpufreq_frequency_table *table, +unsigned int cpu); + +void cpufreq_frequency_table_put_attr (unsigned int cpu); + +#endif /* CONFIG_CPU_FREQ_TABLE */ #endif /* _LINUX_CPUFREQ_H */
kernel/cpufreq.c +8 -1
@@ -340,6 +340,7 @@int ret =0 ;struct cpufreq_policy new_policy;struct cpufreq_policy *policy; +struct freq_attr **drv_attr;if (!kset_get (&cpufreq_interface.kset))return -EINVAL ;
@@ -378,7 +379,13 @@ ret =kobject_register (&policy->kobj);if (ret) goto out; - + + drv_attr = cpufreq_driver->attr; +while ((drv_attr) && (*drv_attr)) { +sysfs_create_file (&policy->kobj, &((*drv_attr)->attr)); + drv_attr++; + } +/* set default policy */ ret =cpufreq_set_policy (&new_policy);if (ret)
_______________________________________________
Cpufreq mailing list
[email protected]
http://www.linux.org.uk/mailman/listinfo/cpufreq
----- End forwarded message -----
Signature · 2 lines
Russell King ([email protected]) The developer of ARM Linux http://www.arm.linux.org.uk/personal/aboutme.html