From: Huang Rui <ray.huang@amd.com>
To: Guenter Roeck <linux@roeck-us.net>, Jean Delvare <jdelvare@suse.de>
Cc: <linux-hwmon@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
"Borislav Petkov" <bp@alien8.de>,
Sherry Hurwitz <sherry.hurwitz@amd.com>,
Huang Rui <ray.huang@amd.com>
Subject: [PATCH v6 6/6] hwmon: (fam15h_power) Add platform check function
Date: Wed, 6 Apr 2016 15:44:15 +0800 [thread overview]
Message-ID: <1459928655-6071-7-git-send-email-ray.huang@amd.com> (raw)
In-Reply-To: <1459928655-6071-1-git-send-email-ray.huang@amd.com>
This patch adds a platform check function to make code more readable.
Signed-off-by: Huang Rui <ray.huang@amd.com>
---
drivers/hwmon/fam15h_power.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
index 7d9d697..eb97a92 100644
--- a/drivers/hwmon/fam15h_power.c
+++ b/drivers/hwmon/fam15h_power.c
@@ -78,6 +78,11 @@ struct fam15h_power_data {
unsigned long power_period;
};
+static bool is_carrizo_or_later(void)
+{
+ return boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model >= 0x60;
+}
+
static ssize_t show_power(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -94,7 +99,7 @@ static ssize_t show_power(struct device *dev,
* On Carrizo and later platforms, TdpRunAvgAccCap bit field
* is extended to 4:31 from 4:25.
*/
- if (boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model >= 0x60) {
+ if (is_carrizo_or_later()) {
running_avg_capture = val >> 4;
running_avg_capture = sign_extend32(running_avg_capture, 27);
} else {
@@ -111,7 +116,7 @@ static ssize_t show_power(struct device *dev,
* On Carrizo and later platforms, ApmTdpLimit bit field
* is extended to 16:31 from 16:28.
*/
- if (boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model >= 0x60)
+ if (is_carrizo_or_later())
tdp_limit = val >> 16;
else
tdp_limit = (val >> 16) & 0x1fff;
--
1.9.1
prev parent reply other threads:[~2016-04-06 7:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-06 7:44 [PATCH v6 0/6] hwmon: (fam15h_power) Introduce an accumulated power reporting algorithm Huang Rui
2016-04-06 7:44 ` [PATCH v6 1/6] hwmon: (fam15h_power) Add CPU_SUP_AMD as the dependence Huang Rui
2016-04-19 13:35 ` [v6,1/6] " Guenter Roeck
2016-04-06 7:44 ` [PATCH v6 2/6] hwmon: (fam15h_power) Add compute unit accumulated power Huang Rui
2016-04-06 15:30 ` Guenter Roeck
2016-04-07 5:05 ` Huang Rui
2016-04-07 5:25 ` Guenter Roeck
2016-04-06 7:44 ` [PATCH v6 3/6] hwmon: (fam15h_power) Add ptsc counter value for " Huang Rui
2016-04-06 7:44 ` [PATCH v6 4/6] hwmon: (fam15h_power) Introduce a cpu accumulated power reporting algorithm Huang Rui
2016-04-06 7:44 ` [PATCH v6 5/6] hwmon: (fam15h_power) Add documentation for TDP and accumulated power algorithm Huang Rui
2016-04-06 7:44 ` Huang Rui [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1459928655-6071-7-git-send-email-ray.huang@amd.com \
--to=ray.huang@amd.com \
--cc=bp@alien8.de \
--cc=jdelvare@suse.de \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=sherry.hurwitz@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).