All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Raag Jadav <raag.jadav@intel.com>
Cc: linus.walleij@linaro.org, andriy.shevchenko@linux.intel.com,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	mallikarjunappa.sangannavar@intel.com, pandith.n@intel.com
Subject: Re: [PATCH v1 4/4] pinctrl: intel: simplify exit path of gpio_request_enable hook
Date: Thu, 8 Jun 2023 11:10:36 +0300	[thread overview]
Message-ID: <20230608081036.GH45886@black.fi.intel.com> (raw)
In-Reply-To: <20230608070017.28072-5-raag.jadav@intel.com>

On Thu, Jun 08, 2023 at 12:30:17PM +0530, Raag Jadav wrote:
> Simplify exit path of ->gpio_request_enable() hook
> and save a few bytes.
> 
> add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-36 (-36)
> Function                                     old     new   delta
> intel_gpio_request_enable                    186     150     -36
> Total: Before=10431, After=10395, chg -0.35%
> 
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>
> ---
>  drivers/pinctrl/intel/pinctrl-intel.c | 23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c
> index 1b5745202058..947797d87c93 100644
> --- a/drivers/pinctrl/intel/pinctrl-intel.c
> +++ b/drivers/pinctrl/intel/pinctrl-intel.c
> @@ -489,20 +489,22 @@ static int intel_gpio_request_enable(struct pinctrl_dev *pctldev,
>  	struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
>  	void __iomem *padcfg0;
>  	unsigned long flags;
> +	int ret;
>  
>  	padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0);
>  
> +	/* For positive cases */
> +	ret = 0;

You can set it

	int ret = 0;

and drop the useless comment.

> +
>  	raw_spin_lock_irqsave(&pctrl->lock, flags);
>  
>  	if (!intel_pad_owned_by_host(pctrl, pin)) {
> -		raw_spin_unlock_irqrestore(&pctrl->lock, flags);
> -		return -EBUSY;
> +		ret = -EBUSY;
> +		goto out_unlock;
>  	}
>  
> -	if (!intel_pad_is_unlocked(pctrl, pin)) {
> -		raw_spin_unlock_irqrestore(&pctrl->lock, flags);
> -		return 0;
> -	}
> +	if (!intel_pad_is_unlocked(pctrl, pin))
> +		goto out_unlock;
>  
>  	/*
>  	 * If pin is already configured in GPIO mode, we assume that
> @@ -510,16 +512,15 @@ static int intel_gpio_request_enable(struct pinctrl_dev *pctldev,
>  	 * potential glitches on the pin. Otherwise, for the pin in
>  	 * alternative mode, consumer has to supply respective flags.
>  	 */
> -	if (intel_gpio_get_gpio_mode(padcfg0) == PADCFG0_PMODE_GPIO) {
> -		raw_spin_unlock_irqrestore(&pctrl->lock, flags);
> -		return 0;
> -	}
> +	if (intel_gpio_get_gpio_mode(padcfg0) == PADCFG0_PMODE_GPIO)
> +		goto out_unlock;
>  
>  	intel_gpio_set_gpio_mode(padcfg0);
>  
> +out_unlock:
>  	raw_spin_unlock_irqrestore(&pctrl->lock, flags);
>  
> -	return 0;
> +	return ret;
>  }
>  
>  static int intel_gpio_set_direction(struct pinctrl_dev *pctldev,
> -- 
> 2.17.1

  reply	other threads:[~2023-06-08  8:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-08  7:00 [PATCH v1 0/4] Minor optimizations for Intel pinctrl Raag Jadav
2023-06-08  7:00 ` [PATCH v1 1/4] pinctrl: intel: optimize set_mux hook Raag Jadav
2023-06-08  8:08   ` Mika Westerberg
2023-06-08 10:20     ` Jadav, Raag
2023-06-08 10:56       ` Mika Westerberg
2023-06-08  7:00 ` [PATCH v1 2/4] pinctrl: intel: optimize irq_set_type hook Raag Jadav
2023-06-08  7:00 ` [PATCH v1 3/4] pinctrl: intel: simplify exit path of set_mux hook Raag Jadav
2023-06-08  8:09   ` Mika Westerberg
2023-06-08  7:00 ` [PATCH v1 4/4] pinctrl: intel: simplify exit path of gpio_request_enable hook Raag Jadav
2023-06-08  8:10   ` Mika Westerberg [this message]
2023-06-08 14:30 ` [PATCH v1 0/4] Minor optimizations for Intel pinctrl Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230608081036.GH45886@black.fi.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mallikarjunappa.sangannavar@intel.com \
    --cc=pandith.n@intel.com \
    --cc=raag.jadav@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.