From: Antony Pavlov <antonynpavlov@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH 1/3] gpiolib: gpio_request(): print message on error
Date: Thu, 9 Jan 2014 21:58:37 +0400 [thread overview]
Message-ID: <1389290319-28518-2-git-send-email-antonynpavlov@gmail.com> (raw)
In-Reply-To: <1389290319-28518-1-git-send-email-antonynpavlov@gmail.com>
Just copy gpiod_request() function logic from linux-v3.13-rc7.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
drivers/gpio/gpiolib.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index cafef90..b7430b0 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -50,22 +50,33 @@ int gpio_request(unsigned gpio, const char *label)
struct gpio_info *gi = gpio_to_desc(gpio);
int ret;
- if (!gi)
- return -ENODEV;
+ if (!gi) {
+ ret = -ENODEV;
+ goto done;
+ }
- if (gi->requested)
- return -EBUSY;
+ if (gi->requested) {
+ ret = -EBUSY;
+ goto done;
+ }
+
+ ret = 0;
if (gi->chip->ops->request) {
ret = gi->chip->ops->request(gi->chip, gpio - gi->chip->base);
if (ret)
- return ret;
+ goto done;
}
gi->requested = true;
gi->label = xstrdup(label);
- return 0;
+done:
+ if (ret)
+ pr_err("_gpio_request: gpio-%d (%s) status %d\n",
+ gpio, label ? : "?", ret);
+
+ return ret;
}
void gpio_free(unsigned gpio)
--
1.8.5.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-01-09 17:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-09 17:58 [PATCH 0/3] gpiolib: add checks and error message Antony Pavlov
2014-01-09 17:58 ` Antony Pavlov [this message]
2014-01-09 17:58 ` [PATCH 2/3] gpiolib: gpio_free: clear gpio's "label" field too Antony Pavlov
2014-01-09 17:58 ` [PATCH 3/3] gpiolib: gpiolib command: show label only for requested pins Antony Pavlov
2014-01-10 9:10 ` [PATCH 0/3] gpiolib: add checks and error message Sascha Hauer
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=1389290319-28518-2-git-send-email-antonynpavlov@gmail.com \
--to=antonynpavlov@gmail.com \
--cc=barebox@lists.infradead.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