summaryrefslogtreecommitdiff
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorRaag Jadav <raag.jadav@intel.com>2023-08-08 14:19:01 +0530
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>2023-08-15 16:06:26 +0300
commit4cfff5b7af8b9df3f1e55ff774944c2f8c8bb9ba (patch)
tree3bbf803559a0488e07a7488cbe09dcf191f2ae7f /drivers/pinctrl
parent06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5 (diff)
pinctrl: baytrail: consolidate common mask operation
Consolidate common mask operation outside of switch cases and limit IO operations to positive cases. Signed-off-by: Raag Jadav <raag.jadav@intel.com> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/intel/pinctrl-baytrail.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
index 27aef62fc7c0..02ab5fd7cbd5 100644
--- a/drivers/pinctrl/intel/pinctrl-baytrail.c
+++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
@@ -995,8 +995,8 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev,
void __iomem *conf_reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG);
void __iomem *val_reg = byt_gpio_reg(vg, offset, BYT_VAL_REG);
void __iomem *db_reg = byt_gpio_reg(vg, offset, BYT_DEBOUNCE_REG);
+ u32 conf, val, db_pulse, debounce;
unsigned long flags;
- u32 conf, val, debounce;
int i, ret = 0;
raw_spin_lock_irqsave(&byt_lock, flags);
@@ -1053,8 +1053,6 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev,
break;
case PIN_CONFIG_INPUT_DEBOUNCE:
- debounce = readl(db_reg);
-
if (arg)
conf |= BYT_DEBOUNCE_EN;
else
@@ -1062,32 +1060,25 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev,
switch (arg) {
case 375:
- debounce &= ~BYT_DEBOUNCE_PULSE_MASK;
- debounce |= BYT_DEBOUNCE_PULSE_375US;
+ db_pulse = BYT_DEBOUNCE_PULSE_375US;
break;
case 750:
- debounce &= ~BYT_DEBOUNCE_PULSE_MASK;
- debounce |= BYT_DEBOUNCE_PULSE_750US;
+ db_pulse = BYT_DEBOUNCE_PULSE_750US;
break;
case 1500:
- debounce &= ~BYT_DEBOUNCE_PULSE_MASK;
- debounce |= BYT_DEBOUNCE_PULSE_1500US;
+ db_pulse = BYT_DEBOUNCE_PULSE_1500US;
break;
case 3000:
- debounce &= ~BYT_DEBOUNCE_PULSE_MASK;
- debounce |= BYT_DEBOUNCE_PULSE_3MS;
+ db_pulse = BYT_DEBOUNCE_PULSE_3MS;
break;
case 6000:
- debounce &= ~BYT_DEBOUNCE_PULSE_MASK;
- debounce |= BYT_DEBOUNCE_PULSE_6MS;
+ db_pulse = BYT_DEBOUNCE_PULSE_6MS;
break;
case 12000:
- debounce &= ~BYT_DEBOUNCE_PULSE_MASK;
- debounce |= BYT_DEBOUNCE_PULSE_12MS;
+ db_pulse = BYT_DEBOUNCE_PULSE_12MS;
break;
case 24000:
- debounce &= ~BYT_DEBOUNCE_PULSE_MASK;
- debounce |= BYT_DEBOUNCE_PULSE_24MS;
+ db_pulse = BYT_DEBOUNCE_PULSE_24MS;
break;
default:
if (arg)
@@ -1095,8 +1086,13 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev,
break;
}
- if (!ret)
- writel(debounce, db_reg);
+ if (ret)
+ break;
+
+ debounce = readl(db_reg);
+ debounce = (debounce & ~BYT_DEBOUNCE_PULSE_MASK) | db_pulse;
+ writel(debounce, db_reg);
+
break;
default:
ret = -ENOTSUPP;