All of lore.kernel.org
 help / color / mirror / 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 05/13] hwmon: (nct6775) Use logical or instead of if statements where possible
Date: Thu, 20 Sep 2018 06:45:33 -0700	[thread overview]
Message-ID: <1537451141-27242-5-git-send-email-linux@roeck-us.net> (raw)
In-Reply-To: <1537451141-27242-1-git-send-email-linux@roeck-us.net>

Use
	boolean |= <expression>;
instead of
	if (!boolean)
		boolean = <expression>;
to assign values to boolean variables.

No functional change.

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

diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
index 984b22d4999a..0f20f7c2a96b 100644
--- a/drivers/hwmon/nct6775.c
+++ b/drivers/hwmon/nct6775.c
@@ -3529,36 +3529,24 @@ nct6775_check_fan_inputs(struct nct6775_data *data)
 		case nct6793:
 		case nct6795:
 		case nct6796:
-			if (!pwm5pin)
-				pwm5pin = cr2d & BIT(7);
+			pwm5pin |= cr2d & BIT(7);
 
-			if (!fan5pin)
-				fan5pin = cr1b & BIT(5);
+			fan5pin |= cr1b & BIT(5);
 
 			if (data->kind != nct6796) {
-				if (!dsw_en) {
-					fan6pin = cr2d & BIT(1);
-					pwm6pin = cr2d & BIT(0);
-				}
+				fan6pin = !dsw_en && (cr2d & BIT(1));
+				pwm6pin = !dsw_en && (cr2d & BIT(0));
 
-				if (!fan5pin)
-					fan5pin = creb & BIT(5);
-				if (!pwm5pin)
-					pwm5pin = (creb & BIT(4)) &&
-						!(cr2a & BIT(0));
-				if (!fan6pin)
-					fan6pin = creb & BIT(3);
-				if (!pwm6pin)
-					pwm6pin = creb & BIT(2);
+				fan5pin |= creb & BIT(5);
+				pwm5pin |= (creb & BIT(4)) && !(cr2a & BIT(0));
+				fan6pin |= creb & BIT(3);
+				pwm6pin |= creb & BIT(2);
 			}
 
 			if (data->kind == nct6795 || data->kind == nct6796) {
-				if (!fan6pin)
-					fan6pin = (cr2a & BIT(4)) &&
-					  (!dsw_en || (cred & BIT(4)));
-				if (!pwm6pin)
-					pwm6pin = (cr2a & BIT(3)) &&
-					  (cred & BIT(2));
+				fan6pin |= (cr2a & BIT(4)) &&
+						(!dsw_en || (cred & BIT(4)));
+				pwm6pin |= (cr2a & BIT(3)) && (cred & BIT(2));
 			}
 
 			if (data->kind == nct6796) {
-- 
2.7.4

  parent reply	other threads:[~2018-09-20 19:29 UTC|newest]

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 ` [PATCH 02/13] hwmon: (nct6775) Replace 'regval' with variables named after config registers Guenter Roeck
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 ` Guenter Roeck [this message]
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-5-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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.