From ab6c4c651d3c8fb1f522ea97818f460583c5cbc8 Mon Sep 17 00:00:00 2001 From: Harry Cutts Date: Mon, 14 Oct 2019 16:55:27 -0700 Subject: util/ectool: move `struct command` into `ectool.h` This allows it to be used by private host binaries (such as the one in https://crrev.com/i/1914158), which may wish to follow the same pattern as `ectool`. While we're at it, add some documentation comments. BRANCH=none BUG=chromium:1008568 TEST=Check `ectool` builds and runs. Change-Id: I94b02f9b734f65b1344a79d6ac8752c40ecf1f04 Signed-off-by: Harry Cutts Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1861075 Reviewed-by: Daisuke Nojiri --- util/ectool.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'util/ectool.h') diff --git a/util/ectool.h b/util/ectool.h index 65687f292f..c47edbf27c 100644 --- a/util/ectool.h +++ b/util/ectool.h @@ -3,6 +3,22 @@ * found in the LICENSE file. */ +/** @brief A handler for an `ectool` command. */ +struct command { + /** The name of the command. */ + const char *name; + + /** + * The function to handle the command. + * + * @param argc The length of `argv` + * @param argv The arguments passed, including the command itself but + * not 'ectool'. + * @return 0 if successful, or a negative `enum ec_status` value. + */ + int (*handler)(int argc, char *argv[]); +}; + /** * Test low-level key scanning * @@ -22,9 +38,5 @@ * is a (possibly empty) list of ASCII keys * * The key matrix is read from the fdt. - * - * @param argc Number of arguments (excluding 'ectool') - * @param argv List of arguments - * @return 0 if ok, -1 on error */ int cmd_keyscan(int argc, char *argv[]); -- cgit v1.2.1