diff mbox series

[2/5] hwmon: (max1668) Use BIT macro

Message ID 20240726004329.934763-3-linux@roeck-us.net (mailing list archive)
State Superseded
Headers show
Series hwmon: (max1668) Modernize driver | expand

Commit Message

Guenter Roeck July 26, 2024, 12:43 a.m. UTC
Use bit macro to make the code easier to understand and reduce duplication.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hwmon/max1668.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Tzung-Bi Shih July 26, 2024, 3:20 p.m. UTC | #1
On Thu, Jul 25, 2024 at 05:43:26PM -0700, Guenter Roeck wrote:
> Use bit macro to make the code easier to understand and reduce duplication.
> 
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
diff mbox series

Patch

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,