From: Boris BREZILLON <b.brezillon@overkiz.com>
To: Rob Herring <rob.herring@calxeda.com>,
Pawel Moll <pawel.moll@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Stephen Warren <swarren@wwwdotorg.org>,
Ian Campbell <ian.campbell@citrix.com>,
Rob Landley <rob@landley.net>,
Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
Linus Walleij <linus.walleij@linaro.org>,
Grant Likely <grant.likely@linaro.org>,
Nicolas Ferre <nicolas.ferre@atmel.com>,
Richard Genoud <richard.genoud@gmail.com>,
Jiri Kosina <jkosina@suse.cz>
Cc: devicetree@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Boris BREZILLON <b.brezillon@overkiz.com>
Subject: [RFC PATCH 3/4] pinctrl: at91: improve pinconf_set/get function robustness
Date: Fri, 13 Sep 2013 09:49:09 +0200 [thread overview]
Message-ID: <1379058549-3413-1-git-send-email-b.brezillon@overkiz.com> (raw)
In-Reply-To: <1379058213-3245-1-git-send-email-b.brezillon@overkiz.com>
Reset caller's config variable before setting current config flags to avoid
erronous config return.
DEBOUNCE and DEGLITCH options are mutually exclusive. Return an error if they
are both defined in the config.
Do not call set_deglitch if DEBOUNCE is enabled to avoid reseting the IFSR
register (which will result in disabling the debounce filter).
Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
---
drivers/pinctrl/pinctrl-at91.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 6624bce..ac9dbea 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -724,6 +724,7 @@ static int at91_pinconf_get(struct pinctrl_dev *pctldev,
dev_dbg(info->dev, "%s:%d, pin_id=%d, config=0x%lx", __func__, __LINE__, pin_id, *config);
pio = pin_to_controller(info, pin_to_bank(pin_id));
pin = pin_id % MAX_NB_GPIO_PER_BANK;
+ *config = 0;
if (at91_mux_get_multidrive(pio, pin))
*config |= MULTI_DRIVE;
@@ -757,13 +758,20 @@ static int at91_pinconf_set(struct pinctrl_dev *pctldev,
if (config & PULL_UP && config & PULL_DOWN)
return -EINVAL;
- at91_mux_set_pullup(pio, mask, config & PULL_UP);
- at91_mux_set_multidrive(pio, mask, config & MULTI_DRIVE);
- if (info->ops->set_deglitch)
- info->ops->set_deglitch(pio, mask, config & DEGLITCH);
- if (info->ops->set_debounce)
+ if (config & DEBOUNCE && config & DEGLITCH)
+ return -EINVAL;
+
+ if (config & DEBOUNCE) {
+ if (!info->ops->set_debounce)
+ return -ENOTSUPP;
+
info->ops->set_debounce(pio, mask, config & DEBOUNCE,
(config & DEBOUNCE_VAL) >> DEBOUNCE_VAL_SHIFT);
+ } else if (info->ops->set_deglitch)
+ info->ops->set_deglitch(pio, mask, config & DEGLITCH);
+
+ at91_mux_set_pullup(pio, mask, config & PULL_UP);
+ at91_mux_set_multidrive(pio, mask, config & MULTI_DRIVE);
if (info->ops->set_pulldown)
info->ops->set_pulldown(pio, mask, config & PULL_DOWN);
if (info->ops->disable_schmitt_trig && config & DIS_SCHMIT)
--
1.7.9.5
next prev parent reply other threads:[~2013-09-13 7:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-13 7:43 [RFC PATCH 0/4] pinctrl: at91: various fixes Boris BREZILLON
2013-09-13 7:45 ` [RFC PATCH 1/4] pinctrl: at91: fix typos Boris BREZILLON
2013-09-14 16:45 ` Jean-Christophe PLAGNIOL-VILLARD
2013-09-27 12:10 ` Linus Walleij
2013-09-13 7:47 ` [RFC PATCH 2/4] pinctrl: at91: fix sam9x5 debounce/deglitch functions Boris BREZILLON
2013-09-14 16:49 ` Jean-Christophe PLAGNIOL-VILLARD
2013-09-27 12:12 ` Linus Walleij
2013-09-13 7:49 ` Boris BREZILLON [this message]
2013-09-14 16:55 ` [RFC PATCH 3/4] pinctrl: at91: improve pinconf_set/get function robustness Jean-Christophe PLAGNIOL-VILLARD
2013-09-13 7:51 ` [RFC PATCH 4/4] pinctrl: at91: check for debounce time conflicts Boris BREZILLON
2013-09-13 7:53 ` [RFC PATCH alt 4/4] pinctrl: at91: rework debounce configuration Boris BREZILLON
2013-09-13 22:40 ` Stephen Warren
2013-09-14 7:08 ` boris brezillon
2013-09-16 16:41 ` Stephen Warren
2013-09-16 17:18 ` boris brezillon
2013-09-16 18:14 ` Stephen Warren
2013-09-14 16:31 ` Jean-Christophe PLAGNIOL-VILLARD
2013-09-14 16:37 ` Jean-Christophe PLAGNIOL-VILLARD
2013-09-15 6:21 ` boris brezillon
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=1379058549-3413-1-git-send-email-b.brezillon@overkiz.com \
--to=b.brezillon@overkiz.com \
--cc=devicetree@vger.kernel.org \
--cc=grant.likely@linaro.org \
--cc=ian.campbell@citrix.com \
--cc=jkosina@suse.cz \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=nicolas.ferre@atmel.com \
--cc=pawel.moll@arm.com \
--cc=plagnioj@jcrosoft.com \
--cc=richard.genoud@gmail.com \
--cc=rob.herring@calxeda.com \
--cc=rob@landley.net \
--cc=swarren@wwwdotorg.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
all inboxes | Powered by JetHome®