]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: adc: mcp3422: rewrite mask macros with help of bits.h APIs
authorMarcelo Machado Lage <marcelomlage@usp.br>
Wed, 29 Apr 2026 22:44:00 +0000 (19:44 -0300)
committerJonathan Cameron <jic23@kernel.org>
Sun, 31 May 2026 09:59:35 +0000 (10:59 +0100)
Rewrite MCP3422_CHANNEL_MASK, MCP3422_SRATE_MASK, MCP3422_PGA_MASK
and MCP3422_CONT_SAMPLING using GENMASK() and BIT() macros from
bits.h.

The other macros MCP3422_SRATE_{240, 60, 15, 3} were not changed
because they are also used as array indices.

Signed-off-by: Marcelo Machado Lage <marcelomlage@usp.br>
Co-developed-by: Vinicius Lira <vinilira@usp.br>
Signed-off-by: Vinicius Lira <vinilira@usp.br>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/adc/mcp3422.c

index 50834fdcf7388f91ee0058d6c645cf20dac84225..0cd0e7d39e393cf88a6452fce5e4bca453bead7f 100644 (file)
@@ -13,6 +13,7 @@
  * voltage unit is nV.
  */
 
+#include <linux/bits.h>
 #include <linux/err.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 
-/* Masks */
-#define MCP3422_CHANNEL_MASK   0x60
-#define MCP3422_PGA_MASK       0x03
-#define MCP3422_SRATE_MASK     0x0C
+#define MCP3422_CHANNEL_MASK   GENMASK(6, 5)
+#define MCP3422_SRATE_MASK     GENMASK(3, 2)
+#define MCP3422_PGA_MASK       GENMASK(1, 0)
+
 #define MCP3422_SRATE_240      0x0
 #define MCP3422_SRATE_60       0x1
 #define MCP3422_SRATE_15       0x2
@@ -36,7 +37,7 @@
 #define MCP3422_PGA_2  1
 #define MCP3422_PGA_4  2
 #define MCP3422_PGA_8  3
-#define MCP3422_CONT_SAMPLING  0x10
+#define MCP3422_CONT_SAMPLING  BIT(4)
 
 #define MCP3422_CHANNEL(config)        (((config) & MCP3422_CHANNEL_MASK) >> 5)
 #define MCP3422_PGA(config)    ((config) & MCP3422_PGA_MASK)