linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Linus Walleij <linus.walleij@linaro.org>,
	linux-gpio@vger.kernel.org,
	Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v2 02/13] pinctrl: intel: Reduce scope of the lock
Date: Fri, 12 Jun 2020 17:49:55 +0300	[thread overview]
Message-ID: <20200612145006.9145-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20200612145006.9145-1-andriy.shevchenko@linux.intel.com>

In some cases lock covers unneeded calls and operations.
Reduce scope of the lock in such cases.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/intel/pinctrl-intel.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c
index 9df5a0c0d416..d0b658ba2136 100644
--- a/drivers/pinctrl/intel/pinctrl-intel.c
+++ b/drivers/pinctrl/intel/pinctrl-intel.c
@@ -460,6 +460,8 @@ static int intel_gpio_request_enable(struct pinctrl_dev *pctldev,
 	void __iomem *padcfg0;
 	unsigned long flags;
 
+	padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0);
+
 	raw_spin_lock_irqsave(&pctrl->lock, flags);
 
 	if (!intel_pad_owned_by_host(pctrl, pin)) {
@@ -472,8 +474,6 @@ static int intel_gpio_request_enable(struct pinctrl_dev *pctldev,
 		return 0;
 	}
 
-	padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0);
-
 	/*
 	 * If pin is already configured in GPIO mode, we assume that
 	 * firmware provides correct settings. In such case we avoid
@@ -503,11 +503,10 @@ static int intel_gpio_set_direction(struct pinctrl_dev *pctldev,
 	void __iomem *padcfg0;
 	unsigned long flags;
 
-	raw_spin_lock_irqsave(&pctrl->lock, flags);
-
 	padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0);
-	__intel_gpio_set_direction(padcfg0, input);
 
+	raw_spin_lock_irqsave(&pctrl->lock, flags);
+	__intel_gpio_set_direction(padcfg0, input);
 	raw_spin_unlock_irqrestore(&pctrl->lock, flags);
 
 	return 0;
@@ -622,10 +621,11 @@ static int intel_config_set_pull(struct intel_pinctrl *pctrl, unsigned int pin,
 	int ret = 0;
 	u32 value;
 
-	raw_spin_lock_irqsave(&pctrl->lock, flags);
-
 	community = intel_get_community(pctrl, pin);
 	padcfg1 = intel_get_padcfg(pctrl, pin, PADCFG1);
+
+	raw_spin_lock_irqsave(&pctrl->lock, flags);
+
 	value = readl(padcfg1);
 
 	switch (param) {
-- 
2.27.0.rc2


  reply	other threads:[~2020-06-12 14:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-12 14:49 [PATCH v2 01/13] pinctrl: intel: Disable input and output buffer when switching to GPIO Andy Shevchenko
2020-06-12 14:49 ` Andy Shevchenko [this message]
2020-06-12 14:49 ` [PATCH v2 03/13] pinctrl: intel: Make use of IRQ_RETVAL() Andy Shevchenko
2020-06-12 14:49 ` [PATCH v2 04/13] pinctrl: intel: Get rid of redundant 'else' in intel_config_set_debounce() Andy Shevchenko
2020-06-12 14:49 ` [PATCH v2 05/13] pinctrl: intel: Drop the only label in the code for consistency Andy Shevchenko
2020-06-12 14:49 ` [PATCH v2 06/13] pinctrl: intel: Split intel_config_get() to three functions Andy Shevchenko
2020-06-12 14:50 ` [PATCH v2 07/13] pinctrl: intel: Protect IO in few call backs by lock Andy Shevchenko
2020-06-12 14:50 ` [PATCH v2 08/13] pinctrl: intel: Introduce for_each_requested_gpio() macro Andy Shevchenko
2020-06-15 11:59   ` Mika Westerberg
2020-06-15 12:01     ` Andy Shevchenko
2020-06-20 20:56       ` Linus Walleij
2020-06-12 14:50 ` [PATCH v2 09/13] pinctrl: intel: Make use of for_each_requested_gpio() Andy Shevchenko
2020-06-12 14:50 ` [PATCH v2 10/13] pinctrl: lynxpoint: " Andy Shevchenko
2020-06-12 14:50 ` [PATCH v2 11/13] pinctrl: lynxpoint: Introduce helpers to enable or disable input Andy Shevchenko
2020-06-12 14:50 ` [PATCH v2 12/13] pinctrl: lynxpoint: Drop no-op ACPI_PTR() call Andy Shevchenko
2020-06-12 14:50 ` [PATCH v2 13/13] pinctrl: baytrail: " Andy Shevchenko
2020-06-15 12:01 ` [PATCH v2 01/13] pinctrl: intel: Disable input and output buffer when switching to GPIO Mika Westerberg
2020-06-15 13:04   ` 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=20200612145006.9145-2-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=mika.westerberg@linux.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 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).