Skip to contentSkip to conversation

Minor improvements for Cherryview pinctrl

PATCH Superseded Raag Jadav 2 participants 5 messages Jun 9, 2023

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Raag Jadav

author
#0 lore raw

v2 cover Minor improvements for Cherryview pinctrl

This series implements minor improvements for Cherryview pinctrl driver.

The optimizations are as tested with gcc 7.5.0 with default -O2.

Raag Jadav (2):
pinctrl: cherryview: simplify exit path of set_mux hook
pinctrl: cherryview: simplify exit path of gpio_request_enable hook

 drivers/pinctrl/intel/pinctrl-cherryview.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 1/2 pinctrl: cherryview: simplify exit path of set_mux hook

Simplify exit path of ->set_mux() hook and save a few bytes.

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

Function                                     old     new   delta
chv_pinmux_set_mux                           640     606     -34

Total: Before=19233, After=19199, chg -0.18%

---
 drivers/pinctrl/intel/pinctrl-cherryview.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/pinctrl/intel/pinctrl-cherryview.c +5 -4
index b9b2b1d2d47f..4942d22cf9d9 100644
@@ -716,7 +716,7 @@ static int chv_pinmux_set_mux(struct pinctrl_dev *pctldev,
 	struct device *dev = pctrl->dev;
 	const struct intel_pingroup *grp;
 	unsigned long flags;
-	int i;
+	int i, ret = 0;
 
 	grp = &pctrl->soc->groups[group];
 
@@ -725,9 +725,9 @@ static int chv_pinmux_set_mux(struct pinctrl_dev *pctldev,
 	/* Check first that the pad is not locked */
 	for (i = 0; i < grp->grp.npins; i++) {
 		if (chv_pad_locked(pctrl, grp->grp.pins[i])) {
-			raw_spin_unlock_irqrestore(&chv_lock, flags);
 			dev_warn(dev, "unable to set mode for locked pin %u\n", grp->grp.pins[i]);
-			return -EBUSY;
+			ret = -EBUSY;
+			goto out_unlock;
 		}
 	}
 
@@ -765,9 +765,10 @@ static int chv_pinmux_set_mux(struct pinctrl_dev *pctldev,
 			invert_oe ? "" : "not ");
 	}
 
+out_unlock:
 	raw_spin_unlock_irqrestore(&chv_lock, flags);
 
-	return 0;
+	return ret;
 }
 
 static void chv_gpio_clear_triggering(struct intel_pinctrl *pctrl,
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH v2 1/2] pinctrl: cherryview: simplify exit path of set_mux hook

Quoted 11 lines · Raag Jadav

Simplify exit path of ->set_mux() hook and save a few bytes.

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

Function                                     old     new   delta
chv_pinmux_set_mux                           640     606     -34

Total: Before=19233, After=19199, chg -0.18%

---
 drivers/pinctrl/intel/pinctrl-cherryview.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Ditto here regarding simplifying.

author
#3 lore raw

PATCH v2 2/2 pinctrl: cherryview: simplify exit path of gpio_request_enable hook

In reply to Raag Jadav

Simplify exit path of ->gpio_request_enable() hook and save a few bytes.

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

Function                                     old     new   delta
chv_gpio_request_enable                      296     286     -10

Total: Before=19199, After=19189, chg -0.05%

---
 drivers/pinctrl/intel/pinctrl-cherryview.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/pinctrl/intel/pinctrl-cherryview.c +5 -4
index 4942d22cf9d9..49af41e4b6af 100644
@@ -799,6 +799,7 @@ static int chv_gpio_request_enable(struct pinctrl_dev *pctldev,
 {
 	struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
 	unsigned long flags;
+	int ret = 0;
 	u32 value;
 
 	raw_spin_lock_irqsave(&chv_lock, flags);
@@ -806,9 +807,8 @@ static int chv_gpio_request_enable(struct pinctrl_dev *pctldev,
 	if (chv_pad_locked(pctrl, offset)) {
 		value = chv_readl(pctrl, offset, CHV_PADCTRL0);
 		if (!(value & CHV_PADCTRL0_GPIOEN)) {
-			/* Locked so cannot enable */
-			raw_spin_unlock_irqrestore(&chv_lock, flags);
-			return -EBUSY;
+			ret = -EBUSY;
+			goto out_unlock;
 		}
 	} else {
 		struct intel_community_context *cctx = &pctrl->context.communities[0];
@@ -842,9 +842,10 @@ static int chv_gpio_request_enable(struct pinctrl_dev *pctldev,
 		chv_writel(pctrl, offset, CHV_PADCTRL0, value);
 	}
 
+out_unlock:
 	raw_spin_unlock_irqrestore(&chv_lock, flags);
 
-	return 0;
+	return ret;
 }
 
 static void chv_gpio_disable_free(struct pinctrl_dev *pctldev,
Signature · 1 line
2.17.1
maintainer
#4 lore raw

Re: [PATCH v2 2/2] pinctrl: cherryview: simplify exit path of gpio_request_enable hook

Quoted 11 lines · Raag Jadav

Simplify exit path of ->gpio_request_enable() hook and save a few bytes.

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

Function                                     old     new   delta
chv_gpio_request_enable                      296     286     -10

Total: Before=19199, After=19189, chg -0.05%

---
 drivers/pinctrl/intel/pinctrl-cherryview.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

and here.