[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c0db0c87b76a8ef08c3ab33b3341cf73c9fa8d20.1553285718.git.Janakarajan.Natarajan@amd.com>
Date: Fri, 22 Mar 2019 20:26:10 +0000
From: "Natarajan, Janakarajan" <Janakarajan.Natarajan@....com>
To: "linux-acpi@...r.kernel.org" <linux-acpi@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
"devel@...ica.org" <devel@...ica.org>
CC: "Rafael J . Wysocki" <rjw@...ysocki.net>,
Len Brown <lenb@...nel.org>,
Viresh Kumar <viresh.kumar@...aro.org>,
Robert Moore <robert.moore@...el.com>,
Erik Schmauss <erik.schmauss@...el.com>,
"Ghannam, Yazen" <Yazen.Ghannam@....com>,
"Natarajan, Janakarajan" <Janakarajan.Natarajan@....com>
Subject: [PATCH 4/6] acpi/cppc: Add macros to define a R/W sysfs entry for
CPPC registers
From: Yazen Ghannam <Yazen.Ghannam@....com>
Some CPPC registers can be used to configure the platform. To enable this,
create macros to define the show, store routines and create sysfs entries
with R/W permission.
Signed-off-by: Yazen Ghannam <Yazen.Ghannam@....com>
[ carved into a patch, cleaned up, productized ]
Signed-off-by: Janakarajan Natarajan <Janakarajan.Natarajan@....com>
---
drivers/acpi/cppc_acpi.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index e81c19316628..7cb23b369fc7 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -134,6 +134,10 @@ struct cppc_attr {
static struct cppc_attr _name = \
__ATTR(_name, 0444, show_##_name, NULL)
+#define define_one_cppc_rw(_name) \
+static struct cppc_attr _name = \
+__ATTR(_name, 0644, show_##_name, store_##_name)
+
#define to_cpc_desc(a) container_of(a, struct cpc_desc, kobj)
#define show_cppc_data(access_fn, struct_name, member_name) \
@@ -156,6 +160,33 @@ __ATTR(_name, 0444, show_##_name, NULL)
show_cppc_data(access_fn, struct_name, member_name) \
define_one_cppc_ro(member_name)
+#define store_cppc_data(struct_name, member_name, reg_idx) \
+ static ssize_t store_##member_name(struct kobject *kobj, \
+ struct attribute *attr, \
+ const char *c, ssize_t count)\
+ { \
+ struct cpc_desc *cpc_ptr = to_cpc_desc(kobj); \
+ struct struct_name st_name = {0}; \
+ u32 val; \
+ int ret; \
+ \
+ ret = kstrtou32(c, 0, &val); \
+ if (ret) \
+ return ret; \
+ \
+ st_name.member_name = val; \
+ \
+ ret = cppc_set_reg(cpc_ptr->cpu_id, &st_name, reg_idx); \
+ if (ret) \
+ return ret; \
+ \
+ return count; \
+ } \
+
+#define store_cppc_data_rw(struct_name, member_name, reg_idx) \
+ store_cppc_data(struct_name, member_name, reg_idx) \
+ define_one_cppc_rw(member_name)
+
show_cppc_data_ro(cppc_get_perf_caps, cppc_perf_caps, highest_perf);
show_cppc_data_ro(cppc_get_perf_caps, cppc_perf_caps, lowest_perf);
show_cppc_data_ro(cppc_get_perf_caps, cppc_perf_caps, nominal_perf);
--
2.17.1
Powered by blists - more mailing lists