a413688f1cd90b2af0c8c79b08bc9efac310edec
[openwrt/staging/rmilecki.git] / package / boot / uboot-mediatek / patches / 006-cmd-button-return-button-status.patch
1 From a6bfd71a96201127836d59736abcb54dc2d5e1a5 Mon Sep 17 00:00:00 2001
2 From: Heinrich Schuchardt <xypron.glpk@gmx.de>
3 Date: Mon, 14 Sep 2020 12:50:56 +0200
4 Subject: [PATCH] cmd/button: return button status
5
6 To make the button command useful in a shell script it should return the
7 status of the button:
8
9 * 0 (true) - pressed, on
10 * 1 (false) - not pressed, off
11
12 The button command takes only one argument. Correct maxargs.
13
14 Adjust the Python unit test.
15
16 Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
17 Reviewed-by: Philippe Reynes <philippe.reynes@softathome.com>
18 ---
19 cmd/button.c | 4 ++--
20 test/py/tests/test_button.py | 34 ++++++++++++++++++++++++++--------
21 2 files changed, 28 insertions(+), 10 deletions(-)
22
23 --- a/cmd/button.c
24 +++ b/cmd/button.c
25 @@ -75,11 +75,11 @@ int do_button(struct cmd_tbl *cmdtp, int
26
27 ret = show_button_state(dev);
28
29 - return 0;
30 + return !ret;
31 }
32
33 U_BOOT_CMD(
34 - button, 4, 1, do_button,
35 + button, 2, 1, do_button,
36 "manage buttons",
37 "<button_label> \tGet button state\n"
38 "button list\t\tShow a list of buttons"