Commit 478a5707 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: adp5589-keys - use BIT()

Let's use BIT() macro instead of explicitly shifting '1'.
Acked-by: default avatarAlexandru Ardelean <Alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20201119072440.GA116840@dtor-wsSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent a2650678
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* Copyright (C) 2010-2011 Analog Devices Inc. * Copyright (C) 2010-2011 Analog Devices Inc.
*/ */
#include <linux/bitops.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/irq.h> #include <linux/irq.h>
...@@ -153,48 +154,48 @@ ...@@ -153,48 +154,48 @@
#define ADP5589_5_MAN_ID 0x02 #define ADP5589_5_MAN_ID 0x02
/* GENERAL_CFG Register */ /* GENERAL_CFG Register */
#define OSC_EN (1 << 7) #define OSC_EN BIT(7)
#define CORE_CLK(x) (((x) & 0x3) << 5) #define CORE_CLK(x) (((x) & 0x3) << 5)
#define LCK_TRK_LOGIC (1 << 4) /* ADP5589 only */ #define LCK_TRK_LOGIC BIT(4) /* ADP5589 only */
#define LCK_TRK_GPI (1 << 3) /* ADP5589 only */ #define LCK_TRK_GPI BIT(3) /* ADP5589 only */
#define INT_CFG (1 << 1) #define INT_CFG BIT(1)
#define RST_CFG (1 << 0) #define RST_CFG BIT(0)
/* INT_EN Register */ /* INT_EN Register */
#define LOGIC2_IEN (1 << 5) /* ADP5589 only */ #define LOGIC2_IEN BIT(5) /* ADP5589 only */
#define LOGIC1_IEN (1 << 4) #define LOGIC1_IEN BIT(4)
#define LOCK_IEN (1 << 3) /* ADP5589 only */ #define LOCK_IEN BIT(3) /* ADP5589 only */
#define OVRFLOW_IEN (1 << 2) #define OVRFLOW_IEN BIT(2)
#define GPI_IEN (1 << 1) #define GPI_IEN BIT(1)
#define EVENT_IEN (1 << 0) #define EVENT_IEN BIT(0)
/* Interrupt Status Register */ /* Interrupt Status Register */
#define LOGIC2_INT (1 << 5) /* ADP5589 only */ #define LOGIC2_INT BIT(5) /* ADP5589 only */
#define LOGIC1_INT (1 << 4) #define LOGIC1_INT BIT(4)
#define LOCK_INT (1 << 3) /* ADP5589 only */ #define LOCK_INT BIT(3) /* ADP5589 only */
#define OVRFLOW_INT (1 << 2) #define OVRFLOW_INT BIT(2)
#define GPI_INT (1 << 1) #define GPI_INT BIT(1)
#define EVENT_INT (1 << 0) #define EVENT_INT BIT(0)
/* STATUS Register */ /* STATUS Register */
#define LOGIC2_STAT (1 << 7) /* ADP5589 only */ #define LOGIC2_STAT BIT(7) /* ADP5589 only */
#define LOGIC1_STAT (1 << 6) #define LOGIC1_STAT BIT(6)
#define LOCK_STAT (1 << 5) /* ADP5589 only */ #define LOCK_STAT BIT(5) /* ADP5589 only */
#define KEC 0x1F #define KEC 0x1F
/* PIN_CONFIG_D Register */ /* PIN_CONFIG_D Register */
#define C4_EXTEND_CFG (1 << 6) /* RESET2 */ #define C4_EXTEND_CFG BIT(6) /* RESET2 */
#define R4_EXTEND_CFG (1 << 5) /* RESET1 */ #define R4_EXTEND_CFG BIT(5) /* RESET1 */
/* LOCK_CFG */ /* LOCK_CFG */
#define LOCK_EN (1 << 0) #define LOCK_EN BIT(0)
#define PTIME_MASK 0x3 #define PTIME_MASK 0x3
#define LTIME_MASK 0x3 /* ADP5589 only */ #define LTIME_MASK 0x3 /* ADP5589 only */
/* Key Event Register xy */ /* Key Event Register xy */
#define KEY_EV_PRESSED (1 << 7) #define KEY_EV_PRESSED BIT(7)
#define KEY_EV_MASK (0x7F) #define KEY_EV_MASK 0x7F
#define KEYP_MAX_EVENT 16 #define KEYP_MAX_EVENT 16
#define ADP5589_MAXGPIO 19 #define ADP5589_MAXGPIO 19
...@@ -472,7 +473,7 @@ static int adp5589_build_gpiomap(struct adp5589_kpad *kpad, ...@@ -472,7 +473,7 @@ static int adp5589_build_gpiomap(struct adp5589_kpad *kpad,
memset(pin_used, false, sizeof(pin_used)); memset(pin_used, false, sizeof(pin_used));
for (i = 0; i < kpad->var->maxgpio; i++) 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; pin_used[i] = true;
for (i = 0; i < kpad->gpimapsize; i++) for (i = 0; i < kpad->gpimapsize; i++)
...@@ -651,13 +652,13 @@ static int adp5589_setup(struct adp5589_kpad *kpad) ...@@ -651,13 +652,13 @@ static int adp5589_setup(struct adp5589_kpad *kpad)
unsigned short pin = pdata->gpimap[i].pin; unsigned short pin = pdata->gpimap[i].pin;
if (pin <= kpad->var->gpi_pin_row_end) { 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 { } else {
evt_mode2 |= evt_mode2 |=
((1 << (pin - kpad->var->gpi_pin_col_base)) & 0xFF); BIT(pin - kpad->var->gpi_pin_col_base) & 0xFF;
if (!kpad->is_adp5585) if (!kpad->is_adp5585)
evt_mode3 |= ((1 << (pin - evt_mode3 |=
kpad->var->gpi_pin_col_base)) >> 8); BIT(pin - kpad->var->gpi_pin_col_base) >> 8;
} }
} }
...@@ -677,7 +678,7 @@ static int adp5589_setup(struct adp5589_kpad *kpad) ...@@ -677,7 +678,7 @@ static int adp5589_setup(struct adp5589_kpad *kpad)
dev_warn(&client->dev, "Conflicting pull resistor config\n"); dev_warn(&client->dev, "Conflicting pull resistor config\n");
for (i = 0; i <= kpad->var->max_row_num; i++) { 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) if (pdata->pullup_en_300k & bit)
val = 0; val = 0;
else if (pdata->pulldown_en_300k & bit) else if (pdata->pulldown_en_300k & bit)
...@@ -697,7 +698,7 @@ static int adp5589_setup(struct adp5589_kpad *kpad) ...@@ -697,7 +698,7 @@ static int adp5589_setup(struct adp5589_kpad *kpad)
} }
for (i = 0; i <= kpad->var->max_col_num; i++) { 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) if (pdata->pullup_en_300k & bit)
val = 0; val = 0;
else if (pdata->pulldown_en_300k & bit) else if (pdata->pulldown_en_300k & bit)
...@@ -813,7 +814,7 @@ static void adp5589_report_switch_state(struct adp5589_kpad *kpad) ...@@ -813,7 +814,7 @@ static void adp5589_report_switch_state(struct adp5589_kpad *kpad)
input_report_switch(kpad->input, input_report_switch(kpad->input,
kpad->gpimap[i].sw_evt, kpad->gpimap[i].sw_evt,
!(gpi_stat_tmp & (1 << pin_loc))); !(gpi_stat_tmp & BIT(pin_loc)));
} }
input_sync(kpad->input); input_sync(kpad->input);
...@@ -859,7 +860,7 @@ static int adp5589_keypad_add(struct adp5589_kpad *kpad, unsigned int revid) ...@@ -859,7 +860,7 @@ static int adp5589_keypad_add(struct adp5589_kpad *kpad, unsigned int revid)
return -EINVAL; return -EINVAL;
} }
if ((1 << (pin - kpad->var->gpi_pin_row_base)) & if (BIT(pin - kpad->var->gpi_pin_row_base) &
pdata->keypad_en_mask) { pdata->keypad_en_mask) {
dev_err(&client->dev, "invalid gpi row/col data\n"); dev_err(&client->dev, "invalid gpi row/col data\n");
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment