Skip to content

Commit 0c79414

Browse files
Marcelo Machado Lagejic23
authored andcommitted
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>
1 parent 5a62491 commit 0c79414

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

drivers/iio/adc/mcp3422.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* voltage unit is nV.
1414
*/
1515

16+
#include <linux/bits.h>
1617
#include <linux/err.h>
1718
#include <linux/i2c.h>
1819
#include <linux/module.h>
@@ -24,10 +25,10 @@
2425
#include <linux/iio/iio.h>
2526
#include <linux/iio/sysfs.h>
2627

27-
/* Masks */
28-
#define MCP3422_CHANNEL_MASK 0x60
29-
#define MCP3422_PGA_MASK 0x03
30-
#define MCP3422_SRATE_MASK 0x0C
28+
#define MCP3422_CHANNEL_MASK GENMASK(6, 5)
29+
#define MCP3422_SRATE_MASK GENMASK(3, 2)
30+
#define MCP3422_PGA_MASK GENMASK(1, 0)
31+
3132
#define MCP3422_SRATE_240 0x0
3233
#define MCP3422_SRATE_60 0x1
3334
#define MCP3422_SRATE_15 0x2
@@ -36,7 +37,7 @@
3637
#define MCP3422_PGA_2 1
3738
#define MCP3422_PGA_4 2
3839
#define MCP3422_PGA_8 3
39-
#define MCP3422_CONT_SAMPLING 0x10
40+
#define MCP3422_CONT_SAMPLING BIT(4)
4041

4142
#define MCP3422_CHANNEL(config) (((config) & MCP3422_CHANNEL_MASK) >> 5)
4243
#define MCP3422_PGA(config) ((config) & MCP3422_PGA_MASK)

0 commit comments

Comments
 (0)