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>
#include <common.h>
#include <command.h>
+#include <errno.h>
#include <dm.h>
#include <asm/gpio.h>
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)
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;
}
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;
}