Skip to contentSkip to conversation

Minor improvements for Baytrail pinctrl

PATCH In review Raag Jadav 3 participants 6 messages Jun 16, 2023 – Jun 19, 2023

Subsystems (3)
lore
Share & tools
lore

Raag Jadav

author
#0 lore raw

cover Minor improvements for Baytrail pinctrl

This series implements minor improvements for Baytrail pinctrl driver.

Raag Jadav (3):
pinctrl: baytrail: reduce scope of spinlock in ->dbg_show() hook
pinctrl: baytrail: add warning for BYT_VAL_REG retrieval failure
pinctrl: baytrail: invert if condition

 drivers/pinctrl/intel/pinctrl-baytrail.c | 32 ++++++++++++++----------
 1 file changed, 19 insertions(+), 13 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/3 pinctrl: baytrail: reduce scope of spinlock in ->dbg_show() hook

Reduce scope of spinlock to IO operations in ->dbg_show() hook and save a few bytes.

add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-12 (-12)

Function                                     old     new   delta
byt_gpio_dbg_show                            890     878     -12

Total: Before=17029, After=17017, chg -0.07%

---
 drivers/pinctrl/intel/pinctrl-baytrail.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/pinctrl/intel/pinctrl-baytrail.c +10 -10
index d53952f5c87c..54d3c5c26944 100644
@@ -1241,30 +1241,30 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
 
 	for (i = 0; i < vg->soc->npins; i++) {
 		const struct intel_community *comm;
+		void __iomem *conf_reg, *val_reg;
 		const char *pull_str = NULL;
 		const char *pull = NULL;
-		void __iomem *reg;
 		unsigned long flags;
 		const char *label;
 		unsigned int pin;
 
-		raw_spin_lock_irqsave(&byt_lock, flags);
 		pin = vg->soc->pins[i].number;
-		reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG);
-		if (!reg) {
+
+		conf_reg = byt_gpio_reg(vg, pin, BYT_CONF0_REG);
+		if (!conf_reg) {
 			seq_printf(s, "Pin %i: can't retrieve CONF0\n", pin);
-			raw_spin_unlock_irqrestore(&byt_lock, flags);
 			continue;
 		}
-		conf0 = readl(reg);
 
-		reg = byt_gpio_reg(vg, pin, BYT_VAL_REG);
-		if (!reg) {
+		val_reg = byt_gpio_reg(vg, pin, BYT_VAL_REG);
+		if (!val_reg) {
 			seq_printf(s, "Pin %i: can't retrieve VAL\n", pin);
-			raw_spin_unlock_irqrestore(&byt_lock, flags);
 			continue;
 		}
-		val = readl(reg);
+
+		raw_spin_lock_irqsave(&byt_lock, flags);
+		conf0 = readl(conf_reg);
+		val = readl(val_reg);
 		raw_spin_unlock_irqrestore(&byt_lock, flags);
 
 		comm = byt_get_community(vg, pin);
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH 2/3 pinctrl: baytrail: add warning for BYT_VAL_REG retrieval failure

In reply to Raag Jadav

Add warning for BYT_VAL_REG retrieval failure and continue such case to avoid unintended reads/writes in pm_ops.

---
 drivers/pinctrl/intel/pinctrl-baytrail.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/pinctrl/intel/pinctrl-baytrail.c +8 -0
index 54d3c5c26944..97ead2c58b66 100644
@@ -1758,6 +1758,10 @@ static int byt_gpio_suspend(struct device *dev)
 		vg->context.pads[i].conf0 = value;
 
 		reg = byt_gpio_reg(vg, pin, BYT_VAL_REG);
+		if (!reg) {
+			dev_warn(vg->dev, "Pin %i: can't retrieve VAL\n", i);
+			continue;
+		}
 		value = readl(reg) & BYT_VAL_RESTORE_MASK;
 		vg->context.pads[i].val = value;
 	}
@@ -1794,6 +1798,10 @@ static int byt_gpio_resume(struct device *dev)
 		}
 
 		reg = byt_gpio_reg(vg, pin, BYT_VAL_REG);
+		if (!reg) {
+			dev_warn(vg->dev, "Pin %i: can't retrieve VAL\n", i);
+			continue;
+		}
 		value = readl(reg);
 		if ((value & BYT_VAL_RESTORE_MASK) !=
 		     vg->context.pads[i].val) {
Signature · 1 line
2.17.1
author
#3 lore raw

PATCH 3/3 pinctrl: baytrail: invert if condition

In reply to Raag Jadav

Invert if condition and get rid of redundant else.

---
 drivers/pinctrl/intel/pinctrl-baytrail.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-baytrail.c +1 -3
index 97ead2c58b66..27aef62fc7c0 100644
@@ -753,9 +753,7 @@ static void byt_gpio_clear_triggering(struct intel_pinctrl *vg, unsigned int off
 	value = readl(reg);
 
 	/* Do not clear direct-irq enabled IRQs (from gpio_disable_free) */
-	if (value & BYT_DIRECT_IRQ_EN)
-		/* nothing to do */ ;
-	else
+	if (!(value & BYT_DIRECT_IRQ_EN))
 		value &= ~(BYT_TRIG_POS | BYT_TRIG_NEG | BYT_TRIG_LVL);
 
 	writel(value, reg);
Signature · 1 line
2.17.1
maintainer Acked-by on the v1 series
#4 lore raw
In reply to Raag Jadav
Quoted 6 lines · Raag Jadav

This series implements minor improvements for Baytrail pinctrl driver.

Raag Jadav (3):
pinctrl: baytrail: reduce scope of spinlock in ->dbg_show() hook
pinctrl: baytrail: add warning for BYT_VAL_REG retrieval failure
pinctrl: baytrail: invert if condition

For the series,

#5 lore raw
Quoted 11 lines · Mika Westerberg
Quoted 6 lines · Raag Jadav

This series implements minor improvements for Baytrail pinctrl driver.

Raag Jadav (3):
pinctrl: baytrail: reduce scope of spinlock in ->dbg_show() hook
pinctrl: baytrail: add warning for BYT_VAL_REG retrieval failure
pinctrl: baytrail: invert if condition

For the series,

Pushed to my review and testing queue, thanks!

Signature · 2 lines
With Best Regards,
Andy Shevchenko