Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Cc: Tzung-Bi Shih <tzungbi@kernel.org>, Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH v2 2/5] hwmon: (max1668) Use BIT macro
Date: Fri, 26 Jul 2024 15:16:00 -0700	[thread overview]
Message-ID: <20240726221603.1190437-3-linux@roeck-us.net> (raw)
In-Reply-To: <20240726221603.1190437-1-linux@roeck-us.net>

Use bit macro to make the code easier to understand and reduce duplication.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: Added Reviewed-by: tag

 drivers/hwmon/max1668.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/max1668.c b/drivers/hwmon/max1668.c
index f5b5cc29da17..83085ed0ae7e 100644
--- a/drivers/hwmon/max1668.c
+++ b/drivers/hwmon/max1668.c
@@ -6,6 +6,7 @@
  * some credit to Christoph Scheurer, but largely a rewrite
  */
 
+#include <linux/bits.h>
 #include <linux/err.h>
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
@@ -172,7 +173,7 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
 	if (IS_ERR(data))
 		return PTR_ERR(data);
 
-	return sprintf(buf, "%u\n", (data->alarms >> index) & 0x1);
+	return sprintf(buf, "%u\n", !!(data->alarms & BIT(index)));
 }
 
 static ssize_t show_fault(struct device *dev,
@@ -185,7 +186,7 @@ static ssize_t show_fault(struct device *dev,
 		return PTR_ERR(data);
 
 	return sprintf(buf, "%u\n",
-		       (data->alarms & (1 << 12)) && data->temp[index] == 127);
+		       (data->alarms & BIT(12)) && data->temp[index] == 127);
 }
 
 static ssize_t set_temp_max(struct device *dev,
-- 
2.39.2


  parent reply	other threads:[~2024-07-26 22:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-26 22:15 [PATCH v2 0/5] hwmon: (max1668) Modernize driver Guenter Roeck
2024-07-26 22:15 ` [PATCH v2 1/5] hwmon: (max1668) Reorder include files to alphabetic order Guenter Roeck
2024-07-26 22:16 ` Guenter Roeck [this message]
2024-07-26 22:16 ` [PATCH v2 3/5] hwmon: (max1668) Convert to use regmap Guenter Roeck
2024-07-27  5:04   ` Tzung-Bi Shih
2024-07-27  9:46     ` Guenter Roeck
2024-07-26 22:16 ` [PATCH v2 4/5] hwmon: (max1668) Replace chip type with number of channels Guenter Roeck
2024-07-26 22:16 ` [PATCH v2 5/5] hwmon: (max1668) Convert to use with_info hwmon API 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=20240726221603.1190437-3-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=tzungbi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox