From: Peter Rosin <peda@axentia.se>
To: linux-kernel@vger.kernel.org
Cc: Peter Rosin <peda@axentia.se>,
Linus Walleij <linus.walleij@linaro.org>,
Andrey Smirnov <andrew.smirnov@gmail.com>,
Neil Armstrong <narmstrong@baylibre.com>,
linux-gpio@vger.kernel.org
Subject: [PATCH v2 2/2] pinctrl: sx150x: support setting multiple pins at once
Date: Wed, 23 Nov 2016 11:18:51 +0100 [thread overview]
Message-ID: <1479896331-16915-3-git-send-email-peda@axentia.se> (raw)
In-Reply-To: <1479896331-16915-1-git-send-email-peda@axentia.se>
If the chip does not have an oscio pin, all pins are configured in
the same regmap register making it trivial to update all pins at
once, so do that. If an oscio pin is present, there needs to be
more locking in place to handle all cases correctly, so this is
skipped.
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/pinctrl/pinctrl-sx150x.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/pinctrl/pinctrl-sx150x.c b/drivers/pinctrl/pinctrl-sx150x.c
index ef4ef88e0ee9..f9e559e22537 100644
--- a/drivers/pinctrl/pinctrl-sx150x.c
+++ b/drivers/pinctrl/pinctrl-sx150x.c
@@ -395,6 +395,15 @@ static void sx150x_gpio_set(struct gpio_chip *chip, unsigned int offset,
}
+static void sx150x_gpio_set_multiple(struct gpio_chip *chip,
+ unsigned long *mask,
+ unsigned long *bits)
+{
+ struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
+
+ regmap_write_bits(pctl->regmap, pctl->data->reg_data, *mask, *bits);
+}
+
static int sx150x_gpio_direction_input(struct gpio_chip *chip,
unsigned int offset)
{
@@ -1075,6 +1084,14 @@ static int sx150x_probe(struct i2c_client *client,
pctl->gpio.of_node = dev->of_node;
#endif
pctl->gpio.can_sleep = true;
+ /*
+ * Setting multiple pins is not safe when all pins are not
+ * handled by the same regmap register. The oscio pin (present
+ * on the SX150X_789 chips) lives in its own register, so
+ * would require locking that is not in place at this time.
+ */
+ if (pctl->data->model != SX150X_789)
+ pctl->gpio.set_multiple = sx150x_gpio_set_multiple;
ret = devm_gpiochip_add_data(dev, &pctl->gpio, pctl);
if (ret)
--
2.1.4
next prev parent reply other threads:[~2016-11-23 10:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-23 10:18 [PATCH v2 0/2] pinctrl: sx150x: set multiple pins at once Peter Rosin
2016-11-23 10:18 ` [PATCH v2 1/2] pinctrl: sx150x: various spelling fixes and some white-space cleanup Peter Rosin
2016-11-23 13:46 ` Linus Walleij
2016-11-23 10:18 ` Peter Rosin [this message]
2016-11-24 14:08 ` [PATCH v2 2/2] pinctrl: sx150x: support setting multiple pins at once 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=1479896331-16915-3-git-send-email-peda@axentia.se \
--to=peda@axentia.se \
--cc=andrew.smirnov@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=narmstrong@baylibre.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).