You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2025/11/07 16:53:17 UTC
(mynewt-core) 17/26: drivers/ina226: Register command statically
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 0ac24eeb13397a94bc531a8115c3f9bda73a0592
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Wed Jun 4 18:52:11 2025 +0200
drivers/ina226: Register command statically
Now ina226 shell command is registered at link time to
reduce memory footprint.
No change in functionality.
Signed-off-by: Jerzy Kasenberg <je...@apache.org>
---
hw/drivers/sensors/ina226/pkg.yml | 5 ++---
hw/drivers/sensors/ina226/src/ina226_shell.c | 20 ++------------------
hw/drivers/sensors/ina226/syscfg.yml | 3 ---
3 files changed, 4 insertions(+), 24 deletions(-)
diff --git a/hw/drivers/sensors/ina226/pkg.yml b/hw/drivers/sensors/ina226/pkg.yml
index 595b16e57..e81368ae8 100644
--- a/hw/drivers/sensors/ina226/pkg.yml
+++ b/hw/drivers/sensors/ina226/pkg.yml
@@ -33,8 +33,7 @@ pkg.deps:
pkg.req_apis:
- stats
+pkg.whole_archive: true
+
pkg.deps.INA226_CLI:
- "@apache-mynewt-core/util/parse"
-
-pkg.init.INA226_CLI:
- ina226_shell_init: 'MYNEWT_VAL(INA226_CLI_SYSINIT_STAGE)'
diff --git a/hw/drivers/sensors/ina226/src/ina226_shell.c b/hw/drivers/sensors/ina226/src/ina226_shell.c
index 3ecf8c648..36e04fab8 100644
--- a/hw/drivers/sensors/ina226/src/ina226_shell.c
+++ b/hw/drivers/sensors/ina226/src/ina226_shell.c
@@ -30,13 +30,6 @@ static enum ina226_ct sct;
static enum ina226_avg_mode avg;
static uint8_t soft_avg = 1;
-static int ina226_shell_cmd(int argc, char **argv);
-
-static struct shell_cmd ina226_shell_cmd_struct = {
- .sc_cmd = "ina226",
- .sc_cmd_func = ina226_shell_cmd
-};
-
static int
ina226_shell_err_too_many_args(char *cmd_name)
{
@@ -64,7 +57,7 @@ ina226_shell_err_invalid_arg(char *cmd_name)
static int
ina226_shell_help(void)
{
- console_printf("%s cmd [flags...]\n", ina226_shell_cmd_struct.sc_cmd);
+ console_printf("ina226 cmd [flags...]\n");
console_printf("cmd:\n");
console_printf("\tr [n_samples]\n");
console_printf("\tavg n\n");
@@ -240,15 +233,6 @@ ina226_shell_cmd(int argc, char **argv)
return ina226_shell_err_unknown_arg(argv[1]);
}
-int
-ina226_shell_init(void)
-{
- int rc;
-
- rc = shell_cmd_register(&ina226_shell_cmd_struct);
- SYSINIT_PANIC_ASSERT(rc == 0);
-
- return rc;
-}
+MAKE_SHELL_CMD(ina226, ina226_shell_cmd, NULL)
#endif
diff --git a/hw/drivers/sensors/ina226/syscfg.yml b/hw/drivers/sensors/ina226/syscfg.yml
index ec71cd095..12000226f 100644
--- a/hw/drivers/sensors/ina226/syscfg.yml
+++ b/hw/drivers/sensors/ina226/syscfg.yml
@@ -54,9 +54,6 @@ syscfg.defs:
INA226_LOG_LVL:
description: 'Minimum level for the INA226 log.'
value: 1
- INA226_CLI_SYSINIT_STAGE:
- description: 'Sysinit stage for the INA226 shell'
- value: 500
syscfg.logs:
INA226_LOG:
module: MYNEWT_VAL(INA226_LOG_MODULE)