Skip to content

Commit d338655

Browse files
committed
pinctrl: cherryview: Avoid duplicated I/O
In some cases we already read the value from the register followed by a reading of it again for other purposes, but the both reads are under the lock and bits we are insterested in are not going to change (they are not volatile from HW perspective). Hence, no need to read the same register twice. Acked-by: Mika Westerberg <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]>
1 parent 3013c7f commit d338655

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

drivers/pinctrl/intel/pinctrl-cherryview.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -612,9 +612,14 @@ static void chv_writel(struct intel_pinctrl *pctrl, unsigned int pin, unsigned i
612612
}
613613

614614
/* When Pad Cfg is locked, driver can only change GPIOTXState or GPIORXState */
615+
static bool chv_pad_is_locked(u32 ctrl1)
616+
{
617+
return ctrl1 & CHV_PADCTRL1_CFGLOCK;
618+
}
619+
615620
static bool chv_pad_locked(struct intel_pinctrl *pctrl, unsigned int offset)
616621
{
617-
return chv_readl(pctrl, offset, CHV_PADCTRL1) & CHV_PADCTRL1_CFGLOCK;
622+
return chv_pad_is_locked(chv_readl(pctrl, offset, CHV_PADCTRL1));
618623
}
619624

620625
static void chv_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
@@ -623,13 +628,11 @@ static void chv_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
623628
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
624629
unsigned long flags;
625630
u32 ctrl0, ctrl1;
626-
bool locked;
627631

628632
raw_spin_lock_irqsave(&chv_lock, flags);
629633

630634
ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0);
631635
ctrl1 = chv_readl(pctrl, offset, CHV_PADCTRL1);
632-
locked = chv_pad_locked(pctrl, offset);
633636

634637
raw_spin_unlock_irqrestore(&chv_lock, flags);
635638

@@ -646,7 +649,7 @@ static void chv_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
646649

647650
seq_printf(s, "0x%08x 0x%08x", ctrl0, ctrl1);
648651

649-
if (locked)
652+
if (chv_pad_is_locked(ctrl1))
650653
seq_puts(s, " [LOCKED]");
651654
}
652655

0 commit comments

Comments
 (0)