006-cmd-button-return-button-status.patch 1.0 KB

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