diff options
| author | Marcelo Machado Lage <marcelomlage@usp.br> | 2026-04-29 19:44:00 -0300 |
|---|---|---|
| committer | Jonathan Cameron <jic23@kernel.org> | 2026-05-31 10:59:35 +0100 |
| commit | 0c794147f2450a7948f22820698607b4e1b7c49e (patch) | |
| tree | c5f592879948eade1df58679513cdfc64cef530d | |
| parent | 5a6249110e0f845bfe181ccc0c275995f26469cf (diff) | |
iio: adc: mcp3422: rewrite mask macros with help of bits.h APIs
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>
| -rw-r--r-- | drivers/iio/adc/mcp3422.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c index 50834fdcf738..0cd0e7d39e39 100644 --- a/drivers/iio/adc/mcp3422.c +++ b/drivers/iio/adc/mcp3422.c @@ -13,6 +13,7 @@ * voltage unit is nV. */ +#include <linux/bits.h> #include <linux/err.h> #include <linux/i2c.h> #include <linux/module.h> @@ -24,10 +25,10 @@ #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) |
