Skip to content

Commit a6d210d

Browse files
committed
hwmon: (k10temp) Use bitops
Using bitops makes bit masks and shifts easier to read. Tested-by: Brad Campbell <[email protected]> Tested-by: Bernhard Gebetsberger <[email protected]> Tested-by: Holger Kiehl <[email protected]> Tested-by: Michael Larabel <[email protected]> Tested-by: Jonathan McDowell <[email protected]> Tested-by: Ken Moffat <[email protected]> Tested-by: Darren Salt <[email protected]> Signed-off-by: Guenter Roeck <[email protected]>
1 parent 7992db7 commit a6d210d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

drivers/hwmon/k10temp.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Copyright (c) 2009 Clemens Ladisch <[email protected]>
66
*/
77

8+
#include <linux/bitops.h>
89
#include <linux/err.h>
910
#include <linux/hwmon.h>
1011
#include <linux/hwmon-sysfs.h>
@@ -31,22 +32,22 @@ static DEFINE_MUTEX(nb_smu_ind_mutex);
3132
#endif
3233

3334
/* CPUID function 0x80000001, ebx */
34-
#define CPUID_PKGTYPE_MASK 0xf0000000
35+
#define CPUID_PKGTYPE_MASK GENMASK(31, 28)
3536
#define CPUID_PKGTYPE_F 0x00000000
3637
#define CPUID_PKGTYPE_AM2R2_AM3 0x10000000
3738

3839
/* DRAM controller (PCI function 2) */
3940
#define REG_DCT0_CONFIG_HIGH 0x094
40-
#define DDR3_MODE 0x00000100
41+
#define DDR3_MODE BIT(8)
4142

4243
/* miscellaneous (PCI function 3) */
4344
#define REG_HARDWARE_THERMAL_CONTROL 0x64
44-
#define HTC_ENABLE 0x00000001
45+
#define HTC_ENABLE BIT(0)
4546

4647
#define REG_REPORTED_TEMPERATURE 0xa4
4748

4849
#define REG_NORTHBRIDGE_CAPABILITIES 0xe8
49-
#define NB_CAP_HTC 0x00000400
50+
#define NB_CAP_HTC BIT(10)
5051

5152
/*
5253
* For F15h M60h and M70h, REG_HARDWARE_THERMAL_CONTROL
@@ -60,6 +61,9 @@ static DEFINE_MUTEX(nb_smu_ind_mutex);
6061
/* F17h M01h Access througn SMN */
6162
#define F17H_M01H_REPORTED_TEMP_CTRL_OFFSET 0x00059800
6263

64+
#define CUR_TEMP_SHIFT 21
65+
#define CUR_TEMP_RANGE_SEL_MASK BIT(19)
66+
6367
struct k10temp_data {
6468
struct pci_dev *pdev;
6569
void (*read_htcreg)(struct pci_dev *pdev, u32 *regval);
@@ -129,7 +133,7 @@ static unsigned int get_raw_temp(struct k10temp_data *data)
129133
u32 regval;
130134

131135
data->read_tempreg(data->pdev, &regval);
132-
temp = (regval >> 21) * 125;
136+
temp = (regval >> CUR_TEMP_SHIFT) * 125;
133137
if (regval & data->temp_adjust_mask)
134138
temp -= 49000;
135139
return temp;
@@ -312,7 +316,7 @@ static int k10temp_probe(struct pci_dev *pdev,
312316
data->read_htcreg = read_htcreg_nb_f15;
313317
data->read_tempreg = read_tempreg_nb_f15;
314318
} else if (boot_cpu_data.x86 == 0x17 || boot_cpu_data.x86 == 0x18) {
315-
data->temp_adjust_mask = 0x80000;
319+
data->temp_adjust_mask = CUR_TEMP_RANGE_SEL_MASK;
316320
data->read_tempreg = read_tempreg_nb_f17;
317321
data->show_tdie = true;
318322
} else {

0 commit comments

Comments
 (0)