summaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2020-11-19 10:11:22 -0800
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2020-11-19 19:18:19 -0800
commit478a57072a4c4fafd83e10c329c9c8ad5c0ff97b (patch)
treecacfb7b1935974f06cc9544fbf41389be06c009c /drivers/input/keyboard
parenta26506788320d8dda4e3520dd1b020f20cc7a2fd (diff)
downloadlinux-478a57072a4c4fafd83e10c329c9c8ad5c0ff97b.tar.bz2
Input: adp5589-keys - use BIT()
Let's use BIT() macro instead of explicitly shifting '1'. Acked-by: Alexandru Ardelean <Alexandru.ardelean@analog.com> Link: https://lore.kernel.org/r/20201119072440.GA116840@dtor-ws Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/keyboard')
-rw-r--r--drivers/input/keyboard/adp5589-keys.c69
1 files changed, 35 insertions, 34 deletions
diff --git a/drivers/input/keyboard/adp5589-keys.c b/drivers/input/keyboard/adp5589-keys.c
index a9b69a268c09..e2cdf14d90cd 100644
--- a/drivers/input/keyboard/adp5589-keys.c
+++ b/drivers/input/keyboard/adp5589-keys.c
@@ -7,6 +7,7 @@
* Copyright (C) 2010-2011 Analog Devices Inc.
*/
+#include <linux/bitops.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
@@ -153,48 +154,48 @@
#define ADP5589_5_MAN_ID 0x02
/* GENERAL_CFG Register */
-#define OSC_EN (1 << 7)
+#define OSC_EN BIT(7)
#define CORE_CLK(x) (((x) & 0x3) << 5)
-#define LCK_TRK_LOGIC (1 << 4) /* ADP5589 only */
-#define LCK_TRK_GPI (1 << 3) /* ADP5589 only */
-#define INT_CFG (1 << 1)
-#define RST_CFG (1 << 0)
+#define LCK_TRK_LOGIC BIT(4) /* ADP5589 only */
+#define LCK_TRK_GPI BIT(3) /* ADP5589 only */
+#define INT_CFG BIT(1)
+#define RST_CFG BIT(0)
/* INT_EN Register */
-#define LOGIC2_IEN (1 << 5) /* ADP5589 only */
-#define LOGIC1_IEN (1 << 4)
-#define LOCK_IEN (1 << 3) /* ADP5589 only */
-#define OVRFLOW_IEN (1 << 2)
-#define GPI_IEN (1 << 1)
-#define EVENT_IEN (1 << 0)
+#define LOGIC2_IEN BIT(5) /* ADP5589 only */
+#define LOGIC1_IEN BIT(4)
+#define LOCK_IEN BIT(3) /* ADP5589 only */
+#define OVRFLOW_IEN BIT(2)
+#define GPI_IEN BIT(1)
+#define EVENT_IEN BIT(0)
/* Interrupt Status Register */
-#define LOGIC2_INT (1 << 5) /* ADP5589 only */
-#define LOGIC1_INT (1 << 4)
-#define LOCK_INT (1 << 3) /* ADP5589 only */
-#define OVRFLOW_INT (1 << 2)
-#define GPI_INT (1 << 1)
-#define EVENT_INT (1 << 0)
+#define LOGIC2_INT BIT(5) /* ADP5589 only */
+#define LOGIC1_INT BIT(4)
+#define LOCK_INT BIT(3) /* ADP5589 only */
+#define OVRFLOW_INT BIT(2)
+#define GPI_INT BIT(1)
+#define EVENT_INT BIT(0)
/* STATUS Register */
-#define LOGIC2_STAT (1 << 7) /* ADP5589 only */
-#define LOGIC1_STAT (1 << 6)
-#define LOCK_STAT (1 << 5) /* ADP5589 only */
+#define LOGIC2_STAT BIT(7) /* ADP5589 only */
+#define LOGIC1_STAT BIT(6)
+#define LOCK_STAT BIT(5) /* ADP5589 only */
#define KEC 0x1F
/* PIN_CONFIG_D Register */
-#define C4_EXTEND_CFG (1 << 6) /* RESET2 */
-#define R4_EXTEND_CFG (1 << 5) /* RESET1 */
+#define C4_EXTEND_CFG BIT(6) /* RESET2 */
+#define R4_EXTEND_CFG BIT(5) /* RESET1 */
/* LOCK_CFG */
-#define LOCK_EN (1 << 0)
+#define LOCK_EN BIT(0)
#define PTIME_MASK 0x3
#define LTIME_MASK 0x3 /* ADP5589 only */
/* Key Event Register xy */
-#define KEY_EV_PRESSED (1 << 7)
-#define KEY_EV_MASK (0x7F)
+#define KEY_EV_PRESSED BIT(7)
+#define KEY_EV_MASK 0x7F
#define KEYP_MAX_EVENT 16
#define ADP5589_MAXGPIO 19
@@ -472,7 +473,7 @@ static int adp5589_build_gpiomap(struct adp5589_kpad *kpad,
memset(pin_used, false, sizeof(pin_used));
for (i = 0; i < kpad->var->maxgpio; i++)
- if (pdata->keypad_en_mask & (1 << i))
+ if (pdata->keypad_en_mask & BIT(i))
pin_used[i] = true;
for (i = 0; i < kpad->gpimapsize; i++)
@@ -651,13 +652,13 @@ static int adp5589_setup(struct adp5589_kpad *kpad)
unsigned short pin = pdata->gpimap[i].pin;
if (pin <= kpad->var->gpi_pin_row_end) {
- evt_mode1 |= (1 << (pin - kpad->var->gpi_pin_row_base));
+ evt_mode1 |= BIT(pin - kpad->var->gpi_pin_row_base);
} else {
evt_mode2 |=
- ((1 << (pin - kpad->var->gpi_pin_col_base)) & 0xFF);
+ BIT(pin - kpad->var->gpi_pin_col_base) & 0xFF;
if (!kpad->is_adp5585)
- evt_mode3 |= ((1 << (pin -
- kpad->var->gpi_pin_col_base)) >> 8);
+ evt_mode3 |=
+ BIT(pin - kpad->var->gpi_pin_col_base) >> 8;
}
}
@@ -677,7 +678,7 @@ static int adp5589_setup(struct adp5589_kpad *kpad)
dev_warn(&client->dev, "Conflicting pull resistor config\n");
for (i = 0; i <= kpad->var->max_row_num; i++) {
- unsigned val = 0, bit = (1 << i);
+ unsigned int val = 0, bit = BIT(i);
if (pdata->pullup_en_300k & bit)
val = 0;
else if (pdata->pulldown_en_300k & bit)
@@ -697,7 +698,7 @@ static int adp5589_setup(struct adp5589_kpad *kpad)
}
for (i = 0; i <= kpad->var->max_col_num; i++) {
- unsigned val = 0, bit = 1 << (i + kpad->var->col_shift);
+ unsigned int val = 0, bit = BIT(i + kpad->var->col_shift);
if (pdata->pullup_en_300k & bit)
val = 0;
else if (pdata->pulldown_en_300k & bit)
@@ -813,7 +814,7 @@ static void adp5589_report_switch_state(struct adp5589_kpad *kpad)
input_report_switch(kpad->input,
kpad->gpimap[i].sw_evt,
- !(gpi_stat_tmp & (1 << pin_loc)));
+ !(gpi_stat_tmp & BIT(pin_loc)));
}
input_sync(kpad->input);
@@ -859,7 +860,7 @@ static int adp5589_keypad_add(struct adp5589_kpad *kpad, unsigned int revid)
return -EINVAL;
}
- if ((1 << (pin - kpad->var->gpi_pin_row_base)) &
+ if (BIT(pin - kpad->var->gpi_pin_row_base) &
pdata->keypad_en_mask) {
dev_err(&client->dev, "invalid gpi row/col data\n");
return -EINVAL;