aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hwmon/fam15h_power.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
index 7d9d6976a575..eb97a9241d17 100644
--- a/drivers/hwmon/fam15h_power.c
+++ b/drivers/hwmon/fam15h_power.c
@@ -78,6 +78,11 @@ struct fam15h_power_data {
78 unsigned long power_period; 78 unsigned long power_period;
79}; 79};
80 80
81static bool is_carrizo_or_later(void)
82{
83 return boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model >= 0x60;
84}
85
81static ssize_t show_power(struct device *dev, 86static ssize_t show_power(struct device *dev,
82 struct device_attribute *attr, char *buf) 87 struct device_attribute *attr, char *buf)
83{ 88{
@@ -94,7 +99,7 @@ static ssize_t show_power(struct device *dev,
94 * On Carrizo and later platforms, TdpRunAvgAccCap bit field 99 * On Carrizo and later platforms, TdpRunAvgAccCap bit field
95 * is extended to 4:31 from 4:25. 100 * is extended to 4:31 from 4:25.
96 */ 101 */
97 if (boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model >= 0x60) { 102 if (is_carrizo_or_later()) {
98 running_avg_capture = val >> 4; 103 running_avg_capture = val >> 4;
99 running_avg_capture = sign_extend32(running_avg_capture, 27); 104 running_avg_capture = sign_extend32(running_avg_capture, 27);
100 } else { 105 } else {
@@ -111,7 +116,7 @@ static ssize_t show_power(struct device *dev,
111 * On Carrizo and later platforms, ApmTdpLimit bit field 116 * On Carrizo and later platforms, ApmTdpLimit bit field
112 * is extended to 16:31 from 16:28. 117 * is extended to 16:31 from 16:28.
113 */ 118 */
114 if (boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model >= 0x60) 119 if (is_carrizo_or_later())
115 tdp_limit = val >> 16; 120 tdp_limit = val >> 16;
116 else 121 else
117 tdp_limit = (val >> 16) & 0x1fff; 122 tdp_limit = (val >> 16) & 0x1fff;