]> git.sur5r.net Git - groeck-k10temp/blobdiff - k10temp.c
Improve compatibility with different kernel versions
[groeck-k10temp] / k10temp.c
index 46a54ed234105040ecda4644cadeb48d6639aca2..6f8ffb9f945f22bfa3c5d5f7f64f9d4b0d9219c2 100644 (file)
--- a/k10temp.c
+++ b/k10temp.c
@@ -24,6 +24,7 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <asm/processor.h>
+#include "compat.h"
 
 MODULE_DESCRIPTION("AMD Family 10h+ CPU core temperature monitor");
 MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
@@ -81,11 +82,13 @@ struct tctl_offset {
 };
 
 static const struct tctl_offset tctl_offset_table[] = {
-       { 0x17, "AMD Ryzen 7 1600X", 20000 },
+       { 0x17, "AMD Ryzen 5 1600X", 20000 },
        { 0x17, "AMD Ryzen 7 1700X", 20000 },
        { 0x17, "AMD Ryzen 7 1800X", 20000 },
+       { 0x17, "AMD Ryzen 7 2700X", 10000 },
        { 0x17, "AMD Ryzen Threadripper 1950X", 27000 },
        { 0x17, "AMD Ryzen Threadripper 1920X", 27000 },
+       { 0x17, "AMD Ryzen Threadripper 1900X", 27000 },
        { 0x17, "AMD Ryzen Threadripper 1950", 10000 },
        { 0x17, "AMD Ryzen Threadripper 1920", 10000 },
        { 0x17, "AMD Ryzen Threadripper 1910", 10000 },
@@ -128,7 +131,13 @@ static ssize_t temp1_input_show(struct device *dev,
 
        data->read_tempreg(data->pdev, &regval);
        temp = (regval >> 21) * 125;
-       temp -= data->temp_offset;
+       /* bit 20 indicates an additional temp offset of 49 degrees C */
+       if (regval & 0x80000)
+               temp -= 49000;
+       if (temp > data->temp_offset)
+               temp -= data->temp_offset;
+       else
+               temp = 0;
 
        return sprintf(buf, "%u\n", temp);
 }
@@ -226,7 +235,7 @@ static bool has_erratum_319(struct pci_dev *pdev)
         * and AM3 formats, but that's the best we can do.
         */
        return boot_cpu_data.x86_model < 4 ||
-              (boot_cpu_data.x86_model == 4 && boot_cpu_data.x86_mask <= 2);
+              (boot_cpu_data.x86_model == 4 && boot_cpu_data.x86_stepping <= 2);
 }
 
 static int k10temp_probe(struct pci_dev *pdev,