diff mbox series

[05/13] hwmon: (nct6775) Use logical or instead of if statements where possible

Message ID 1537451141-27242-5-git-send-email-linux@roeck-us.net (mailing list archive)
State Accepted
Headers show
Series [01/13] hwmon: (nct6775) Rename configuration register variables | expand

Commit Message

Guenter Roeck Sept. 20, 2018, 1:45 p.m. UTC
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 mbox series

Patch

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) {