summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2014-08-11 09:23:53 -0600
committerSimon Glass <sjg@chromium.org>2014-08-31 23:21:19 -0600
commit9165e8428d02b42b7f2b87083035e4e2493df721 (patch)
treeb9bc1b8501cadb93ba49da25c83d61674ef2c6a0 /common
parent89e6405425c7b52fd1330c61b6f5526612b87516 (diff)
downloadblackbird-obmc-uboot-9165e8428d02b42b7f2b87083035e4e2493df721.tar.gz
blackbird-obmc-uboot-9165e8428d02b42b7f2b87083035e4e2493df721.zip
dm: gpio: Allow gpio command to adjust GPIOs that are busy
The gpio command mostly relies on gpio_request() and gpio_free() being nops, in that you can request a GPIO twice. With driver model this is now implemented correctly, so it fails. Change the command to deal with a failure to claim the GPIO. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/cmd_gpio.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/common/cmd_gpio.c b/common/cmd_gpio.c
index b97533f313..11f4e4031d 100644
--- a/common/cmd_gpio.c
+++ b/common/cmd_gpio.c
@@ -8,6 +8,7 @@
#include <common.h>
#include <command.h>
+#include <errno.h>
#include <dm.h>
#include <asm/gpio.h>
@@ -135,9 +136,9 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
enum gpio_cmd sub_cmd;
ulong value;
const char *str_cmd, *str_gpio = NULL;
+ int ret;
#ifdef CONFIG_DM_GPIO
bool all = false;
- int ret;
#endif
if (argc < 2)
@@ -197,7 +198,8 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
goto show_usage;
#endif
/* grab the pin before we tweak it */
- if (gpio_request(gpio, "cmd_gpio")) {
+ ret = gpio_request(gpio, "cmd_gpio");
+ if (ret && ret != -EBUSY) {
printf("gpio: requesting pin %u failed\n", gpio);
return -1;
}
@@ -218,7 +220,8 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
printf("gpio: pin %s (gpio %i) value is %lu\n",
str_gpio, gpio, value);
- gpio_free(gpio);
+ if (ret != -EBUSY)
+ gpio_free(gpio);
return value;
}
OpenPOWER on IntegriCloud