This is an automated email from the ASF dual-hosted git repository. jerzy pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit a2b3e23e9ac5f01d7cd2bac11084536fe7f27418 Author: Jerzy Kasenberg <[email protected]> AuthorDate: Fri Jun 6 19:34:21 2025 +0200 drivers/lsm6dso: Register command statically Now lsm6dso shell command is registered at link time to reduce memory footprint. Command was register before by function lsm6dso_shell_init() that is not removed and replaced by syscfg value LSM6DSO_SHELL Signed-off-by: Jerzy Kasenberg <[email protected]> --- hw/drivers/sensors/lsm6dso/include/lsm6dso/lsm6dso.h | 7 ------- hw/drivers/sensors/lsm6dso/pkg.yml | 8 ++++++++ hw/drivers/sensors/lsm6dso/src/lsm6dso_shell.c | 19 ++----------------- hw/drivers/sensors/lsm6dso/syscfg.yml | 3 +++ 4 files changed, 13 insertions(+), 24 deletions(-) diff --git a/hw/drivers/sensors/lsm6dso/include/lsm6dso/lsm6dso.h b/hw/drivers/sensors/lsm6dso/include/lsm6dso/lsm6dso.h index 168d3e850..b8ff2c9dd 100644 --- a/hw/drivers/sensors/lsm6dso/include/lsm6dso/lsm6dso.h +++ b/hw/drivers/sensors/lsm6dso/include/lsm6dso/lsm6dso.h @@ -314,13 +314,6 @@ int lsm6dso_init(struct os_dev *dev, void *arg); */ int lsm6dso_config(struct lsm6dso *, struct lsm6dso_cfg *); -/** - * Init shell - * - * @return 0 on success, non-zero on failure. - */ -int lsm6dso_shell_init(void); - /** * Read acc/gyro data * diff --git a/hw/drivers/sensors/lsm6dso/pkg.yml b/hw/drivers/sensors/lsm6dso/pkg.yml index 714b97815..219af0df2 100644 --- a/hw/drivers/sensors/lsm6dso/pkg.yml +++ b/hw/drivers/sensors/lsm6dso/pkg.yml @@ -33,3 +33,11 @@ pkg.deps: pkg.req_apis: - stats + +pkg.source_files: + - src/lsm6dso.c + +pkg.source_files.LSM6DSO_SHELL: + - src/lsm6dso_shell.c + +pkg.whole_archive: true diff --git a/hw/drivers/sensors/lsm6dso/src/lsm6dso_shell.c b/hw/drivers/sensors/lsm6dso/src/lsm6dso_shell.c index f5c39b27b..5b8267575 100644 --- a/hw/drivers/sensors/lsm6dso/src/lsm6dso_shell.c +++ b/hw/drivers/sensors/lsm6dso/src/lsm6dso_shell.c @@ -32,8 +32,6 @@ typedef struct { char *regname; } reg_name_t; -static int lsm6dso_shell_cmd(int argc, char **argv); - /* Human readable register map for page 0 */ static const reg_name_t reg_name[] = { { .add = 0x02, .regname = "PIN_CTRL" }, @@ -71,11 +69,6 @@ static const reg_name_t reg_name[] = { { .add = 0x5f, .regname = "MD2_CFG" }, }; -static struct shell_cmd lsm6dso_shell_cmd_struct = { - .sc_cmd = "lsm6dso", - .sc_cmd_func = lsm6dso_shell_cmd -}; - static struct sensor_itf *g_sensor_itf; static struct lsm6dso *g_lsm6dso; @@ -119,7 +112,7 @@ static int lsm6dso_shell_err_unknown_arg(char *cmd_name) static void lsm6dso_shell_help(void) { - console_printf("%s cmd [flags...]\n", lsm6dso_shell_cmd_struct.sc_cmd); + console_printf("lsm6dso cmd [flags...]\n"); console_printf("cmd:\n"); console_printf("\tdump\tSTART\tEND\n"); console_printf("\tread\tADD\n"); @@ -278,12 +271,4 @@ static int lsm6dso_shell_cmd(int argc, char **argv) return lsm6dso_shell_err_unknown_arg(argv[1]); } -int lsm6dso_shell_init(void) -{ - int rc; - - rc = shell_cmd_register(&lsm6dso_shell_cmd_struct); - SYSINIT_PANIC_ASSERT(rc == 0); - - return rc; -} +MAKE_SHELL_CMD(lsm6dso, lsm6dso_shell_cmd, NULL) diff --git a/hw/drivers/sensors/lsm6dso/syscfg.yml b/hw/drivers/sensors/lsm6dso/syscfg.yml index f4790e357..2ac1eefe1 100644 --- a/hw/drivers/sensors/lsm6dso/syscfg.yml +++ b/hw/drivers/sensors/lsm6dso/syscfg.yml @@ -30,6 +30,9 @@ syscfg.defs: description: > Number of OS ticks to wait for each I2C transaction to complete. value: 3 + LSM6DSO_SHELL: + description: 'Add lsm6dso command to shell' + value: 0 LSM6DSO_SHELL_DEV_NAME: description: 'Name of LSM6DSO device to use in shell' value: '"lsm6dso_0"'
