Skip to content

Commit a8353b6

Browse files
committed
Input: samsung-keypad - use BIT() and GENMASK() where appropriate
Instead of using (1 << <shift>) construct use BIT() helper. Convert (1 << <shift>) - 1 to GENMASK(). Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 42121e7 commit a8353b6

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

drivers/input/keyboard/samsung-keypad.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Author: Donghwa Lee <[email protected]>
88
*/
99

10+
#include <linux/bits.h>
1011
#include <linux/clk.h>
1112
#include <linux/delay.h>
1213
#include <linux/err.h>
@@ -29,11 +30,11 @@
2930
#define SAMSUNG_KEYIFFC 0x10
3031

3132
/* SAMSUNG_KEYIFCON */
32-
#define SAMSUNG_KEYIFCON_INT_F_EN (1 << 0)
33-
#define SAMSUNG_KEYIFCON_INT_R_EN (1 << 1)
34-
#define SAMSUNG_KEYIFCON_DF_EN (1 << 2)
35-
#define SAMSUNG_KEYIFCON_FC_EN (1 << 3)
36-
#define SAMSUNG_KEYIFCON_WAKEUPEN (1 << 4)
33+
#define SAMSUNG_KEYIFCON_INT_F_EN BIT(0)
34+
#define SAMSUNG_KEYIFCON_INT_R_EN BIT(1)
35+
#define SAMSUNG_KEYIFCON_DF_EN BIT(2)
36+
#define SAMSUNG_KEYIFCON_FC_EN BIT(3)
37+
#define SAMSUNG_KEYIFCON_WAKEUPEN BIT(4)
3738

3839
/* SAMSUNG_KEYIFSTSCLR */
3940
#define SAMSUNG_KEYIFSTSCLR_P_INT_MASK (0xff << 0)
@@ -81,14 +82,14 @@ static void samsung_keypad_scan(struct samsung_keypad *keypad,
8182
unsigned int val;
8283

8384
for (col = 0; col < keypad->cols; col++) {
84-
val = SAMSUNG_KEYIFCOL_MASK & ~(1 << col);
85+
val = SAMSUNG_KEYIFCOL_MASK & ~BIT(col);
8586
val <<= keypad->chip->column_shift;
8687

8788
writel(val, keypad->base + SAMSUNG_KEYIFCOL);
8889
mdelay(1);
8990

9091
val = readl(keypad->base + SAMSUNG_KEYIFROW);
91-
row_state[col] = ~val & ((1 << keypad->rows) - 1);
92+
row_state[col] = ~val & GENMASK(keypad->rows - 1, 0);
9293
}
9394

9495
/* KEYIFCOL reg clear */
@@ -112,10 +113,10 @@ static bool samsung_keypad_report(struct samsung_keypad *keypad,
112113
continue;
113114

114115
for (row = 0; row < keypad->rows; row++) {
115-
if (!(changed & (1 << row)))
116+
if (!(changed & BIT(row)))
116117
continue;
117118

118-
pressed = row_state[col] & (1 << row);
119+
pressed = row_state[col] & BIT(row);
119120

120121
dev_dbg(&keypad->input_dev->dev,
121122
"key %s, row: %d, col: %d\n",

0 commit comments

Comments
 (0)