Linux-Hwmon Archive on lore.kernel.org
 help / color / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Cc: Jean Delvare <jdelvare@suse.com>, Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 02/13] hwmon: (nct6775) Replace 'regval' with variables named after config registers
Date: Thu, 20 Sep 2018 06:45:30 -0700
Message-ID: <1537451141-27242-2-git-send-email-linux@roeck-us.net> (raw)
In-Reply-To: <1537451141-27242-1-git-send-email-linux@roeck-us.net>

Using variables named after configuration registers makes it more obvious
which configuration register value is used, especially if more than one
configuration register value is used to determine a configuration detail.

No functional change.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hwmon/nct6775.c | 43 +++++++++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
index 7a3a1d59553e..bd1c4772994a 100644
--- a/drivers/hwmon/nct6775.c
+++ b/drivers/hwmon/nct6775.c
@@ -3436,7 +3436,8 @@ nct6775_check_fan_inputs(struct nct6775_data *data)
 	bool pwm3pin = false, pwm4pin = false, pwm5pin = false;
 	bool pwm6pin = false, pwm7pin = false;
 	int sioreg = data->sioreg;
-	int regval;
+	int cr24;
+	int cr2c;
 
 	/* Store SIO_REG_ENABLE for use during resume */
 	superio_select(sioreg, NCT6775_LD_HWM);
@@ -3444,10 +3445,10 @@ nct6775_check_fan_inputs(struct nct6775_data *data)
 
 	/* fan4 and fan5 share some pins with the GPIO and serial flash */
 	if (data->kind == nct6775) {
-		regval = superio_inb(sioreg, 0x2c);
+		cr2c = superio_inb(sioreg, 0x2c);
 
-		fan3pin = regval & BIT(6);
-		pwm3pin = regval & BIT(7);
+		fan3pin = cr2c & BIT(6);
+		pwm3pin = cr2c & BIT(7);
 
 		/* On NCT6775, fan4 shares pins with the fdc interface */
 		fan4pin = !(superio_inb(sioreg, 0x2A) & 0x80);
@@ -3492,30 +3493,32 @@ nct6775_check_fan_inputs(struct nct6775_data *data)
 		fan4min = fan4pin;
 		pwm3pin = fan3pin;
 	} else if (data->kind == nct6106) {
-		regval = superio_inb(sioreg, 0x24);
-		fan3pin = !(regval & 0x80);
-		pwm3pin = regval & 0x08;
+		cr24 = superio_inb(sioreg, 0x24);
+		fan3pin = !(cr24 & 0x80);
+		pwm3pin = cr24 & 0x08;
 	} else {
 		/* NCT6779D, NCT6791D, NCT6792D, NCT6793D, NCT6795D, NCT6796D */
 		int cr1b, cr2a, cr2f;
+		int cr1c;
+		int cr2d;
 		bool dsw_en;
 
-		regval = superio_inb(sioreg, 0x1c);
+		cr1c = superio_inb(sioreg, 0x1c);
 
-		fan3pin = !(regval & BIT(5));
-		fan4pin = !(regval & BIT(6));
-		fan5pin = !(regval & BIT(7));
+		fan3pin = !(cr1c & BIT(5));
+		fan4pin = !(cr1c & BIT(6));
+		fan5pin = !(cr1c & BIT(7));
 
-		pwm3pin = !(regval & BIT(0));
-		pwm4pin = !(regval & BIT(1));
-		pwm5pin = !(regval & BIT(2));
+		pwm3pin = !(cr1c & BIT(0));
+		pwm4pin = !(cr1c & BIT(1));
+		pwm5pin = !(cr1c & BIT(2));
 
-		regval = superio_inb(sioreg, 0x2d);
+		cr2d = superio_inb(sioreg, 0x2d);
 		switch (data->kind) {
 		case nct6791:
 		case nct6792:
-			fan6pin = regval & BIT(1);
-			pwm6pin = regval & BIT(0);
+			fan6pin = cr2d & BIT(1);
+			pwm6pin = cr2d & BIT(0);
 			break;
 		case nct6793:
 		case nct6795:
@@ -3526,7 +3529,7 @@ nct6775_check_fan_inputs(struct nct6775_data *data)
 			dsw_en = cr2f & BIT(3);
 
 			if (!pwm5pin)
-				pwm5pin = regval & BIT(7);
+				pwm5pin = cr2d & BIT(7);
 
 			if (!fan5pin)
 				fan5pin = cr1b & BIT(5);
@@ -3536,8 +3539,8 @@ nct6775_check_fan_inputs(struct nct6775_data *data)
 				int creb = superio_inb(sioreg, 0xeb);
 
 				if (!dsw_en) {
-					fan6pin = regval & BIT(1);
-					pwm6pin = regval & BIT(0);
+					fan6pin = cr2d & BIT(1);
+					pwm6pin = cr2d & BIT(0);
 				}
 
 				if (!fan5pin)
-- 
2.7.4

  reply index

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-20 13:45 [PATCH 01/13] hwmon: (nct6775) Rename configuration register variables Guenter Roeck
2018-09-20 13:45 ` Guenter Roeck [this message]
2018-09-20 13:45 ` [PATCH 03/13] hwmon: (nct6775) Move config variable declarations and initializations Guenter Roeck
2018-09-20 13:45 ` [PATCH 04/13] hwmon: (nct6775) Declare and initialize LDN specific config variables earlier Guenter Roeck
2018-09-20 13:45 ` [PATCH 05/13] hwmon: (nct6775) Use logical or instead of if statements where possible Guenter Roeck
2018-09-20 13:45 ` [PATCH 06/13] hwmon: (nct6775) Improve instruction grouping Guenter Roeck
2018-09-20 13:45 ` [PATCH 07/13] hwmon: (nct6775) Fix fan6/pwm6 detection for NCT6792D Guenter Roeck
2018-09-20 13:45 ` [PATCH 08/13] hwmon: (nct6775) Separate fan/pwm configuration detection for NCT6793D Guenter Roeck
2018-09-20 13:45 ` [PATCH 09/13] hwmon: (nct6775) Separate fan/pwm configuration detection for NCT6795D Guenter Roeck
2018-09-20 13:45 ` [PATCH 10/13] hwmon: (nct6796) Clean up and amend fan/pwm configuration for NCT6796D Guenter Roeck
2018-09-20 13:45 ` [PATCH 11/13] hwmon: (nct6775) Fix names of DIMM temperature sources Guenter Roeck
2018-09-20 13:45 ` [PATCH 12/13] hwmon: (nct6775) Add support for NCT6797D Guenter Roeck
2018-09-20 13:45 ` [PATCH 13/13] hwmon: (nct6775) Add support for NCT6798D Guenter Roeck

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=1537451141-27242-2-git-send-email-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    /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

Linux-Hwmon Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-hwmon/0 linux-hwmon/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-hwmon linux-hwmon/ https://lore.kernel.org/linux-hwmon \
		linux-hwmon@vger.kernel.org
	public-inbox-index linux-hwmon

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-hwmon


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git