diff mbox series

[5/6] cmd: button: store button state in the 'button' env

Message ID 20201214112437.18757-6-m.szyprowski@samsung.com
State Superseded
Headers show
Series VIM3: add support for checking 'Function' button state | expand

Commit Message

Marek Szyprowski Dec. 14, 2020, 11:24 a.m. UTC
Save examined button state in 'button' environment variable to enable
checking button state in the scripts.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

Change-Id: I78b539e1516573fcfea4401f75469291844daae4
---
 cmd/button.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
2.17.1

Comments

Simon Glass Dec. 19, 2020, 2:28 a.m. UTC | #1
Hi Marek,

On Mon, 14 Dec 2020 at 04:25, Marek Szyprowski <m.szyprowski@samsung.com> wrote:
>

> Save examined button state in 'button' environment variable to enable

> checking button state in the scripts.

>

> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

> Change-Id: I78b539e1516573fcfea4401f75469291844daae4

> ---

>  cmd/button.c | 4 +++-

>  1 file changed, 3 insertions(+), 1 deletion(-)


Can you add this to the README /docs where it talks about env vars?

>

> diff --git a/cmd/button.c b/cmd/button.c

> index 64c5a8fa046..8da911068a4 100644

> --- a/cmd/button.c

> +++ b/cmd/button.c

> @@ -23,8 +23,10 @@ static int show_button_state(struct udevice *dev)

>         ret = button_get_state(dev);

>         if (ret >= BUTTON_COUNT)

>                 ret = -EINVAL;

> -       if (ret >= 0)

> +       if (ret >= 0) {

>                 printf("%s\n", state_label[ret]);

> +               env_set("button", state_label[ret]);

> +       }

>

>         return ret;

>  }

> --

> 2.17.1

>


Regards,
Simon
diff mbox series

Patch

diff --git a/cmd/button.c b/cmd/button.c
index 64c5a8fa046..8da911068a4 100644
--- a/cmd/button.c
+++ b/cmd/button.c
@@ -23,8 +23,10 @@  static int show_button_state(struct udevice *dev)
 	ret = button_get_state(dev);
 	if (ret >= BUTTON_COUNT)
 		ret = -EINVAL;
-	if (ret >= 0)
+	if (ret >= 0) {
 		printf("%s\n", state_label[ret]);
+		env_set("button", state_label[ret]);
+	}
 
 	return ret;
 }