Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7828667ybl; Thu, 16 Jan 2020 06:19:28 -0800 (PST) X-Google-Smtp-Source: APXvYqwsAPjIISSc6EzIqtbgWKlub9Gh8rK+oHJgU/eGDCjjRTHHPnsv612nBiLJrOBqojf3iJt8 X-Received: by 2002:a05:6830:16d1:: with SMTP id l17mr2031914otr.21.1579184367895; Thu, 16 Jan 2020 06:19:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579184367; cv=none; d=google.com; s=arc-20160816; b=bawbG0bEI5hGRDd81jY1nnw93KM0hSTHuseGgtaeSfo83iVP0BZ2K8DNzzqewq/8K8 KQccBnPisa61ejzXtY6nUHukmdKvWJ95qSTA+uc3IkUo7CRApKMpHfUGUmaIbhplIBBh l0ib0u5esblmgRQb2ntzI5pfVNX32qRasQ0wJayiIDs712ThYppIeWE4Cxe7W6zHsey/ 1gHet7f2nJ6pTecHznyGhptrS212XphqqP+jL/xhy9oRuHO8UYYZ/BvGbouRXEJkFQLc R6cBBh5shJLtPTkqoRvoTvXLB/PoLUhUbj9WuLDKpQ93shcENmSY7hP9JOB2Nbxt5BPU a4Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=SqNU8BEvRrh7CzCA9+xl9QuecJJq2yOX0LpeNCA/PXU=; b=PM6oZRKFQK2a7k28EHzR7UIsN/f6JIuLKCsyUrXrCVXJGIh1m8rvcpfxqcmxKdIiKB 2F/xEoPvQV8Kasn7ueyyIgPmIXhLpo9rPB264vH8FY+dHsJ/wBWM9AU2ox/tOdUEmbB3 AhttFSGR5F0DTlNhvi3P8pbrNOliObLEhoVaRCoYBJyx+c9RBFN1ttqWjL+wl0NWwdaz q4L0QsAeENjl2EGechq8sPSaVoJaiBpELpXCJ/8AgEGhr6HxqVYNHQTzOCH72d9fp1c/ 4W2JJPfy2glTlVoXV3VZiI4WHDPJJWWXVcdCwJXHVJ0BMmOqrx2isjHnwYfVgTHiM2C1 OaUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="X8hO/Mgb"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v124si11390649oib.173.2020.01.16.06.19.15; Thu, 16 Jan 2020 06:19:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="X8hO/Mgb"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726903AbgAPOSN (ORCPT + 99 others); Thu, 16 Jan 2020 09:18:13 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:34877 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726084AbgAPOSM (ORCPT ); Thu, 16 Jan 2020 09:18:12 -0500 Received: by mail-pj1-f68.google.com with SMTP id s7so1658662pjc.0; Thu, 16 Jan 2020 06:18:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=SqNU8BEvRrh7CzCA9+xl9QuecJJq2yOX0LpeNCA/PXU=; b=X8hO/Mgb+y4D9pAMDjiETjqRKyud+waS+FpHvHdSjok/cIJkRK6PQ6kD/in+MjIsjX /9SWNF9oESyzACPDOPx4wNP9UiJFQ8VBQtzcIf0yjPV9/JN73utSZaKa4CPdDiXnILkn K94ohtZZduWays/+X9nDp5X07lo2YbZ8HLnlJqaM2rJ2G7FLpyEg7o4fUSxlfr4t2IoR fnxznViAfEG7O90bJJLyiyIcbxenFPOurx7baKLaSxIhbI/z5YHkw26x4fPld2hGYcu5 +4mXSlUUTNazjz6SahWeNuJn6c/BGRwJa0RNN4Kgvt7DUQXz6eeWF+ywP9Yt/PwxeMYs Hjsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=SqNU8BEvRrh7CzCA9+xl9QuecJJq2yOX0LpeNCA/PXU=; b=j9yNiFVo2MyVCA1uwkjnNGapk74u/6s1AP0dgtSIVHEo2QPrZJ6QqmdNr7SoiCEHRL aC2YiQilGIBP+P0W9E8cqdKkkuf7/DqJt5i/N46OtjeGb75EyE0MTboL60Sf0/JioCxO D0G6fL0WyP3XPZs5ocvX1UXor8Ex/9k0rMzVZf58Dgze0U8+FwphoJ+131tLxKq5C2ED NlgVt9y5JU+XOxKZcIXMIJDIuFDemmiPTwFL3BR4nhKyqLq1iraMB5060FVItF5X0Q/S GXenUA/82Xj0ItNTRfG9+Ohkrtp2kQAjFF1XkHc/ESdMCQQfJB6V6G5pMe/zUj87JAiU 4Apw== X-Gm-Message-State: APjAAAWH4KSltyAkqIa6Pgf0SPUoCia6+ofpyAVr3ic+IFiGts1kPULq jCIda6AnJkEw0YA5h+CXDXE10YJ/ X-Received: by 2002:a17:902:9a08:: with SMTP id v8mr32760182plp.134.1579184291553; Thu, 16 Jan 2020 06:18:11 -0800 (PST) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id a10sm25244078pgm.81.2020.01.16.06.18.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Jan 2020 06:18:11 -0800 (PST) From: Guenter Roeck To: linux-hwmon@vger.kernel.org Cc: Clemens Ladisch , Jean Delvare , linux-kernel@vger.kernel.org, Guenter Roeck Subject: [RFT PATCH 1/4] hwmon: (k10temp) Use bitops Date: Thu, 16 Jan 2020 06:17:57 -0800 Message-Id: <20200116141800.9828-2-linux@roeck-us.net> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200116141800.9828-1-linux@roeck-us.net> References: <20200116141800.9828-1-linux@roeck-us.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using bitops makes bit masks and shifts easier to read. Signed-off-by: Guenter Roeck --- drivers/hwmon/k10temp.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c index 5c1dddde193c..8807d7da68db 100644 --- a/drivers/hwmon/k10temp.c +++ b/drivers/hwmon/k10temp.c @@ -5,6 +5,7 @@ * Copyright (c) 2009 Clemens Ladisch */ +#include #include #include #include @@ -31,22 +32,22 @@ static DEFINE_MUTEX(nb_smu_ind_mutex); #endif /* CPUID function 0x80000001, ebx */ -#define CPUID_PKGTYPE_MASK 0xf0000000 +#define CPUID_PKGTYPE_MASK GENMASK(31, 28) #define CPUID_PKGTYPE_F 0x00000000 #define CPUID_PKGTYPE_AM2R2_AM3 0x10000000 /* DRAM controller (PCI function 2) */ #define REG_DCT0_CONFIG_HIGH 0x094 -#define DDR3_MODE 0x00000100 +#define DDR3_MODE BIT(8) /* miscellaneous (PCI function 3) */ #define REG_HARDWARE_THERMAL_CONTROL 0x64 -#define HTC_ENABLE 0x00000001 +#define HTC_ENABLE BIT(0) #define REG_REPORTED_TEMPERATURE 0xa4 #define REG_NORTHBRIDGE_CAPABILITIES 0xe8 -#define NB_CAP_HTC 0x00000400 +#define NB_CAP_HTC BIT(10) /* * For F15h M60h and M70h, REG_HARDWARE_THERMAL_CONTROL @@ -60,6 +61,9 @@ static DEFINE_MUTEX(nb_smu_ind_mutex); /* F17h M01h Access througn SMN */ #define F17H_M01H_REPORTED_TEMP_CTRL_OFFSET 0x00059800 +#define CUR_TEMP_SHIFT 21 +#define CUR_TEMP_RANGE_SEL_MASK BIT(19) + struct k10temp_data { struct pci_dev *pdev; void (*read_htcreg)(struct pci_dev *pdev, u32 *regval); @@ -129,7 +133,7 @@ static unsigned int get_raw_temp(struct k10temp_data *data) u32 regval; data->read_tempreg(data->pdev, ®val); - temp = (regval >> 21) * 125; + temp = (regval >> CUR_TEMP_SHIFT) * 125; if (regval & data->temp_adjust_mask) temp -= 49000; return temp; @@ -312,7 +316,7 @@ static int k10temp_probe(struct pci_dev *pdev, data->read_htcreg = read_htcreg_nb_f15; data->read_tempreg = read_tempreg_nb_f15; } else if (boot_cpu_data.x86 == 0x17 || boot_cpu_data.x86 == 0x18) { - data->temp_adjust_mask = 0x80000; + data->temp_adjust_mask = CUR_TEMP_RANGE_SEL_MASK; data->read_tempreg = read_tempreg_nb_f17; data->show_tdie = true; } else { -- 2.17.1