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 8f2a45473a33aaa7a86c28109418d05929f90491
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Fri Jun 6 20:37:58 2025 +0200

    drivers/ds1307: Register command statically
    
    Now ds1307 shell command is registered at link time to
    reduce memory footprint.
    No change in functionality.
    
    Signed-off-by: Jerzy Kasenberg <[email protected]>
---
 hw/drivers/rtc/ds1307/pkg.yml            | 11 ++++++++---
 hw/drivers/rtc/ds1307/src/ds1307_shell.c | 18 ++----------------
 2 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/hw/drivers/rtc/ds1307/pkg.yml b/hw/drivers/rtc/ds1307/pkg.yml
index 03b010831..9dea617da 100644
--- a/hw/drivers/rtc/ds1307/pkg.yml
+++ b/hw/drivers/rtc/ds1307/pkg.yml
@@ -35,8 +35,13 @@ pkg.req_apis:
     - log
     - stats
 
+pkg.whole_archive: true
+
+pkg.source_files:
+    - src/ds1307.c
+
+pkg.source_files.DS1307_CLI:
+    - src/ds1307_shell.c
+
 pkg.init:
     ds1307_pkg_init: 601
-
-pkg.init.DS1307_CLI:
-    ds1307_shell_init: 1000
diff --git a/hw/drivers/rtc/ds1307/src/ds1307_shell.c 
b/hw/drivers/rtc/ds1307/src/ds1307_shell.c
index 6d6b12624..672528fb5 100644
--- a/hw/drivers/rtc/ds1307/src/ds1307_shell.c
+++ b/hw/drivers/rtc/ds1307/src/ds1307_shell.c
@@ -24,17 +24,10 @@
 
 #if MYNEWT_VAL(DS1307_CLI)
 
-static int ds1307_shell_cmd(int argc, char **argv);
-
-static struct shell_cmd ds1307_shell_cmd_struct = {
-    .sc_cmd = "ds1307",
-    .sc_cmd_func = ds1307_shell_cmd
-};
-
 static int
 ds1307_shell_help(void)
 {
-    console_printf("%s cmd [args]\n", ds1307_shell_cmd_struct.sc_cmd);
+    console_printf("ds1307 cmd [args]\n");
     console_printf("cmd:\n");
     console_printf("\tdate [date-time]\n");
     console_printf("\tr addr\n");
@@ -161,13 +154,6 @@ ds1307_shell_cmd(int argc, char **argv)
     return 0;
 }
 
-void
-ds1307_shell_init(void)
-{
-    int rc;
-
-    rc = shell_cmd_register(&ds1307_shell_cmd_struct);
-    SYSINIT_PANIC_ASSERT(rc == 0);
-}
+MAKE_SHELL_CMD(ds1307, ds1307_shell_cmd, NULL)
 
 #endif

Reply via email to