summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-02-16 20:24:42 -0700
committerBin Meng <bmeng.cn@gmail.com>2019-02-20 15:24:29 +0800
commitb8989b537eb1f3387d08a1c34633e78e6a56acc2 (patch)
tree185e26669cb45ac9f9736600d34a5e395459db6d /cmd
parent7d38db55f70a30eaa64f91b35720abc5f595783f (diff)
gpio: Show inactive GPIOs when explicitly requested
At present the gpio command only shows GPIOs which are marked as in use. This makes sense with 'gpio status' since we already have the '-a' flag to indicate that all GPIOs should be shown. But when a particular GPIO is requested, it seems better to always display it. At present the request is simply ignored. For example if GPIO a10 is not in use, then: > gpio status a10 shows nothing, not even the function being used for that GPIO. With this change, it shows the pin status: > gpio status a10 a10: input: 0 [ ] Add an extra parameter for this to avoid changing the existing flag parameter. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com> [bmeng: correct the 'gpio' command in the commit message] Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gpio.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/cmd/gpio.c b/cmd/gpio.c
index 4ac1f1e418..539e07ee07 100644
--- a/cmd/gpio.c
+++ b/cmd/gpio.c
@@ -34,7 +34,7 @@ enum {
};
static void gpio_get_description(struct udevice *dev, const char *bank_name,
- int offset, int *flagsp)
+ int offset, int *flagsp, bool show_all)
{
char buf[80];
int ret;
@@ -42,7 +42,7 @@ static void gpio_get_description(struct udevice *dev, const char *bank_name,
ret = gpio_get_function(dev, offset, NULL);
if (ret < 0)
goto err;
- if (!(*flagsp & FLAG_SHOW_ALL) && ret == GPIOF_UNUSED)
+ if (!show_all && !(*flagsp & FLAG_SHOW_ALL) && ret == GPIOF_UNUSED)
return;
if ((*flagsp & FLAG_SHOW_BANK) && bank_name) {
if (*flagsp & FLAG_SHOW_NEWLINE) {
@@ -98,11 +98,11 @@ static int do_gpio_status(bool all, const char *gpio_name)
if (gpio_name && *p) {
offset = simple_strtoul(p, NULL, 10);
gpio_get_description(dev, bank_name, offset,
- &flags);
+ &flags, true);
} else {
for (offset = 0; offset < num_bits; offset++) {
gpio_get_description(dev, bank_name,
- offset, &flags);
+ offset, &flags, false);
}
}
}