[v1,2/2] pinctrl: cherryview: simplify exit path of gpio_request_enable hook

Message ID 20230608071903.19170-3-raag.jadav@intel.com
State New
Headers
Series Minor optimizations for Cherryview pinctrl |

Commit Message

Raag Jadav June 8, 2023, 7:19 a.m. UTC
  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%

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

Patch

diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c
index 1e21c6f8aa7f..8dbe92cd1c21 100644
--- a/drivers/pinctrl/intel/pinctrl-cherryview.c
+++ b/drivers/pinctrl/intel/pinctrl-cherryview.c
@@ -803,15 +803,18 @@  static int chv_gpio_request_enable(struct pinctrl_dev *pctldev,
 	struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
 	unsigned long flags;
 	u32 value;
+	int ret;
+
+	/* For positive cases */
+	ret = 0;
 
 	raw_spin_lock_irqsave(&chv_lock, flags);
 
 	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];
@@ -845,9 +848,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,