From: Michael Walle <michael@walle.cc>
To: Lars Povlsen <lars.povlsen@microchip.com>,
Steen Hegelund <Steen.Hegelund@microchip.com>,
Linus Walleij <linus.walleij@linaro.org>
Cc: UNGLinuxDriver@microchip.com,
linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org,
Colin Foster <colin.foster@in-advantage.com>,
Michael Walle <michael@walle.cc>
Subject: [PATCH v2 3/5] pinctrl: microchip-sgpio: use regmap_update_bits()
Date: Sat, 26 Feb 2022 21:45:05 +0100 [thread overview]
Message-ID: <20220226204507.2511633-4-michael@walle.cc> (raw)
In-Reply-To: <20220226204507.2511633-1-michael@walle.cc>
Convert sgpio_clrsetbits() to use regmap_update_bits() and drop the
spinlocks because regmap already takes care of the locking.
Signed-off-by: Michael Walle <michael@walle.cc>
---
drivers/pinctrl/pinctrl-microchip-sgpio.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-microchip-sgpio.c b/drivers/pinctrl/pinctrl-microchip-sgpio.c
index 29cce0609fd9..a6ad61aa845e 100644
--- a/drivers/pinctrl/pinctrl-microchip-sgpio.c
+++ b/drivers/pinctrl/pinctrl-microchip-sgpio.c
@@ -168,12 +168,11 @@ static void sgpio_writel(struct sgpio_priv *priv,
static inline void sgpio_clrsetbits(struct sgpio_priv *priv,
u32 rno, u32 off, u32 clear, u32 set)
{
- u32 val = sgpio_readl(priv, rno, off);
-
- val &= ~clear;
- val |= set;
+ u32 addr = sgpio_get_addr(priv, rno, off);
+ int ret;
- sgpio_writel(priv, val, rno, off);
+ ret = regmap_update_bits(priv->regs, addr, clear | set, set);
+ WARN_ONCE(ret, "error updating sgpio reg %d\n", ret);
}
static inline void sgpio_configure_bitstream(struct sgpio_priv *priv)
@@ -231,7 +230,6 @@ static void sgpio_output_set(struct sgpio_priv *priv,
int value)
{
unsigned int bit = SGPIO_SRC_BITS * addr->bit;
- unsigned long flags;
u32 clr, set;
switch (priv->properties->arch) {
@@ -251,9 +249,7 @@ static void sgpio_output_set(struct sgpio_priv *priv,
return;
}
- spin_lock_irqsave(&priv->lock, flags);
sgpio_clrsetbits(priv, REG_PORT_CONFIG, addr->port, clr, set);
- spin_unlock_irqrestore(&priv->lock, flags);
}
static int sgpio_output_get(struct sgpio_priv *priv,
@@ -616,16 +612,13 @@ static void microchip_sgpio_irq_setreg(struct irq_data *data,
struct sgpio_bank *bank = gpiochip_get_data(chip);
unsigned int gpio = irqd_to_hwirq(data);
struct sgpio_port_addr addr;
- unsigned long flags;
sgpio_pin_to_addr(bank->priv, gpio, &addr);
- spin_lock_irqsave(&bank->priv->lock, flags);
if (clear)
sgpio_clrsetbits(bank->priv, reg, addr.bit, BIT(addr.port), 0);
else
sgpio_clrsetbits(bank->priv, reg, addr.bit, 0, BIT(addr.port));
- spin_unlock_irqrestore(&bank->priv->lock, flags);
}
static void microchip_sgpio_irq_mask(struct irq_data *data)
--
2.30.2
next prev parent reply other threads:[~2022-02-26 20:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-26 20:45 [PATCH v2 0/5] pinctrl: microchip-sgpio: locking and synchronous output Michael Walle
2022-02-26 20:45 ` [PATCH v2 1/5] pinctrl: microchip-sgpio: lock RMW access Michael Walle
2022-02-26 20:45 ` [PATCH v2 2/5] pinctrl: microchip-sgpio: don't do RMW for interrupt ack register Michael Walle
2022-02-26 20:45 ` Michael Walle [this message]
2022-02-26 20:45 ` [PATCH v2 4/5] pinctrl: microchip-sgpio: return error in spgio_output_set() Michael Walle
2022-02-26 20:45 ` [PATCH v2 5/5] pinctrl: microchip-sgpio: wait until output is actually set Michael Walle
2022-03-15 0:57 ` [PATCH v2 0/5] pinctrl: microchip-sgpio: locking and synchronous output Linus Walleij
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=20220226204507.2511633-4-michael@walle.cc \
--to=michael@walle.cc \
--cc=Steen.Hegelund@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=colin.foster@in-advantage.com \
--cc=lars.povlsen@microchip.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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).