linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-next v1 0/3] Minor improvements for Baytrail pinctrl
@ 2023-06-16 20:33 Raag Jadav
  2023-06-16 20:33 ` [PATCH for-next v1 1/3] pinctrl: baytrail: reduce scope of spinlock in ->dbg_show() hook Raag Jadav
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Raag Jadav @ 2023-06-16 20:33 UTC (permalink / raw)
  To: linus.walleij, mika.westerberg, andriy.shevchenko
  Cc: linux-gpio, linux-kernel, mallikarjunappa.sangannavar, pandith.n,
	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

 drivers/pinctrl/intel/pinctrl-baytrail.c | 32 ++++++++++++++----------
 1 file changed, 19 insertions(+), 13 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH for-next v1 1/3] pinctrl: baytrail: reduce scope of spinlock in ->dbg_show() hook
  2023-06-16 20:33 [PATCH for-next v1 0/3] Minor improvements for Baytrail pinctrl Raag Jadav
@ 2023-06-16 20:33 ` Raag Jadav
  2023-06-16 20:33 ` [PATCH for-next v1 2/3] pinctrl: baytrail: add warning for BYT_VAL_REG retrieval failure Raag Jadav
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Raag Jadav @ 2023-06-16 20:33 UTC (permalink / raw)
  To: linus.walleij, mika.westerberg, andriy.shevchenko
  Cc: linux-gpio, linux-kernel, mallikarjunappa.sangannavar, pandith.n,
	Raag Jadav

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%

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/pinctrl/intel/pinctrl-baytrail.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
index d53952f5c87c..54d3c5c26944 100644
--- a/drivers/pinctrl/intel/pinctrl-baytrail.c
+++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
@@ -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);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH for-next v1 2/3] pinctrl: baytrail: add warning for BYT_VAL_REG retrieval failure
  2023-06-16 20:33 [PATCH for-next v1 0/3] Minor improvements for Baytrail pinctrl Raag Jadav
  2023-06-16 20:33 ` [PATCH for-next v1 1/3] pinctrl: baytrail: reduce scope of spinlock in ->dbg_show() hook Raag Jadav
@ 2023-06-16 20:33 ` Raag Jadav
  2023-06-16 20:33 ` [PATCH for-next v1 3/3] pinctrl: baytrail: invert if condition Raag Jadav
  2023-06-19  6:22 ` [PATCH for-next v1 0/3] Minor improvements for Baytrail pinctrl Mika Westerberg
  3 siblings, 0 replies; 6+ messages in thread
From: Raag Jadav @ 2023-06-16 20:33 UTC (permalink / raw)
  To: linus.walleij, mika.westerberg, andriy.shevchenko
  Cc: linux-gpio, linux-kernel, mallikarjunappa.sangannavar, pandith.n,
	Raag Jadav

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

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/pinctrl/intel/pinctrl-baytrail.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
index 54d3c5c26944..97ead2c58b66 100644
--- a/drivers/pinctrl/intel/pinctrl-baytrail.c
+++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
@@ -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) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH for-next v1 3/3] pinctrl: baytrail: invert if condition
  2023-06-16 20:33 [PATCH for-next v1 0/3] Minor improvements for Baytrail pinctrl Raag Jadav
  2023-06-16 20:33 ` [PATCH for-next v1 1/3] pinctrl: baytrail: reduce scope of spinlock in ->dbg_show() hook Raag Jadav
  2023-06-16 20:33 ` [PATCH for-next v1 2/3] pinctrl: baytrail: add warning for BYT_VAL_REG retrieval failure Raag Jadav
@ 2023-06-16 20:33 ` Raag Jadav
  2023-06-19  6:22 ` [PATCH for-next v1 0/3] Minor improvements for Baytrail pinctrl Mika Westerberg
  3 siblings, 0 replies; 6+ messages in thread
From: Raag Jadav @ 2023-06-16 20:33 UTC (permalink / raw)
  To: linus.walleij, mika.westerberg, andriy.shevchenko
  Cc: linux-gpio, linux-kernel, mallikarjunappa.sangannavar, pandith.n,
	Raag Jadav

Invert if condition and get rid of redundant else.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/pinctrl/intel/pinctrl-baytrail.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
index 97ead2c58b66..27aef62fc7c0 100644
--- a/drivers/pinctrl/intel/pinctrl-baytrail.c
+++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
@@ -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);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH for-next v1 0/3] Minor improvements for Baytrail pinctrl
  2023-06-16 20:33 [PATCH for-next v1 0/3] Minor improvements for Baytrail pinctrl Raag Jadav
                   ` (2 preceding siblings ...)
  2023-06-16 20:33 ` [PATCH for-next v1 3/3] pinctrl: baytrail: invert if condition Raag Jadav
@ 2023-06-19  6:22 ` Mika Westerberg
  2023-06-19 10:53   ` Andy Shevchenko
  3 siblings, 1 reply; 6+ messages in thread
From: Mika Westerberg @ 2023-06-19  6:22 UTC (permalink / raw)
  To: Raag Jadav
  Cc: linus.walleij, andriy.shevchenko, linux-gpio, linux-kernel,
	mallikarjunappa.sangannavar, pandith.n

On Sat, Jun 17, 2023 at 02:03:53AM +0530, Raag Jadav wrote:
> 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,

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH for-next v1 0/3] Minor improvements for Baytrail pinctrl
  2023-06-19  6:22 ` [PATCH for-next v1 0/3] Minor improvements for Baytrail pinctrl Mika Westerberg
@ 2023-06-19 10:53   ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2023-06-19 10:53 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: Raag Jadav, linus.walleij, linux-gpio, linux-kernel,
	mallikarjunappa.sangannavar, pandith.n

On Mon, Jun 19, 2023 at 09:22:47AM +0300, Mika Westerberg wrote:
> On Sat, Jun 17, 2023 at 02:03:53AM +0530, Raag Jadav wrote:
> > 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,
> 
> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

Pushed to my review and testing queue, thanks!

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-06-19 10:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-16 20:33 [PATCH for-next v1 0/3] Minor improvements for Baytrail pinctrl Raag Jadav
2023-06-16 20:33 ` [PATCH for-next v1 1/3] pinctrl: baytrail: reduce scope of spinlock in ->dbg_show() hook Raag Jadav
2023-06-16 20:33 ` [PATCH for-next v1 2/3] pinctrl: baytrail: add warning for BYT_VAL_REG retrieval failure Raag Jadav
2023-06-16 20:33 ` [PATCH for-next v1 3/3] pinctrl: baytrail: invert if condition Raag Jadav
2023-06-19  6:22 ` [PATCH for-next v1 0/3] Minor improvements for Baytrail pinctrl Mika Westerberg
2023-06-19 10:53   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).