From: Linus Walleij <linus.walleij@linaro.org>
To: linux-gpio@vger.kernel.org,
Alexandre Courbot <acourbot@nvidia.com>,
Michael Trimarchi <michael@amarulasolutions.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
stable@vger.kernel.org,
Bjorn Andersson <bjorn.andersson@sonymobile.com>,
Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Subject: [PATCH] gpio: revert get() to non-errorprogating behaviour
Date: Thu, 17 Dec 2015 10:21:11 +0100 [thread overview]
Message-ID: <1450344071-7169-1-git-send-email-linus.walleij@linaro.org> (raw)
commit e20538b82f1ffcc06e68feb117f24f211cff7a4d
"gpio: Propagate errors from chip->get()"
started to propagate errors from the .get() functions since
we can get errors from the infrastructure of e.g. slowbus
GPIO expanders.
However it turns out a bunch of drivers relied on the core
to clamp the value, so we need to revert to the old behaviour
and go over all drivers and fix them to conform to the
expectations of the core before we go back to propagating
the error code.
Cc: stable@vger.kernel.org
Cc: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Cc: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Reported-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/gpio/gpiolib.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 2a91f3287e3b..4e4c3083ae56 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1279,7 +1279,13 @@ static int _gpiod_get_raw_value(const struct gpio_desc *desc)
chip = desc->chip;
offset = gpio_chip_hwgpio(desc);
value = chip->get ? chip->get(chip, offset) : -EIO;
- value = value < 0 ? value : !!value;
+ /*
+ * FIXME: fix all drivers to clamp to [0,1] or return negative,
+ * then change this to:
+ * value = value < 0 ? value : !!value;
+ * so we can properly propagate error codes.
+ */
+ value = !!value;
trace_gpio_value(desc_to_gpio(desc), 1, value);
return value;
}
--
2.4.3
next reply other threads:[~2015-12-17 9:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-17 9:21 Linus Walleij [this message]
2015-12-17 21:26 ` [PATCH] gpio: revert get() to non-errorprogating behaviour Bjorn Andersson
2015-12-22 9:07 ` 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=1450344071-7169-1-git-send-email-linus.walleij@linaro.org \
--to=linus.walleij@linaro.org \
--cc=acourbot@nvidia.com \
--cc=bjorn.andersson@sonymobile.com \
--cc=linux-gpio@vger.kernel.org \
--cc=michael@amarulasolutions.com \
--cc=stable@vger.kernel.org \
--cc=vladimir_zapolskiy@mentor.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).