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 1b8a84216875891f528988b03b4886b8d4ab9a43
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Fri Jun 6 19:43:35 2025 +0200

    drivers/ds3231: Register command statically
    
    Now ds3231 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/ds3231/include/ds3231/ds3231.h | 11 -----------
 hw/drivers/rtc/ds3231/pkg.yml                 |  9 +++++++--
 hw/drivers/rtc/ds3231/src/ds3231_shell.c      | 20 +++-----------------
 3 files changed, 10 insertions(+), 30 deletions(-)

diff --git a/hw/drivers/rtc/ds3231/include/ds3231/ds3231.h 
b/hw/drivers/rtc/ds3231/include/ds3231/ds3231.h
index 5440da8cc..c9a11f364 100644
--- a/hw/drivers/rtc/ds3231/include/ds3231/ds3231.h
+++ b/hw/drivers/rtc/ds3231/include/ds3231/ds3231.h
@@ -166,17 +166,6 @@ int ds3231_read_regs(struct ds3231_dev *ds3231, uint8_t 
addr, uint8_t *regs, uin
  */
 int ds3231_write_regs(struct ds3231_dev *ds3231, uint8_t addr, uint8_t *vals, 
uint8_t count);
 
-
-#if MYNEWT_VAL(DS3231_CLI)
-/**
- * Initialize the DS3231 shell extensions.
- *
- * @return 0 on success, non-zero on failure.
- */
-void ds3231_shell_init(void);
-#endif
-
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/hw/drivers/rtc/ds3231/pkg.yml b/hw/drivers/rtc/ds3231/pkg.yml
index cba092376..8477bc570 100644
--- a/hw/drivers/rtc/ds3231/pkg.yml
+++ b/hw/drivers/rtc/ds3231/pkg.yml
@@ -36,5 +36,10 @@ pkg.req_apis:
 pkg.init:
     ds3231_pkg_init: 601
 
-pkg.init.DS3231_CLI:
-    ds3231_shell_init: 1000
+pkg.whole_archive: true
+
+pkg.source_files:
+    - src/ds3231.c
+
+pkg.source_files.DS3231_CLI:
+    - src/ds3231_shell.c
diff --git a/hw/drivers/rtc/ds3231/src/ds3231_shell.c 
b/hw/drivers/rtc/ds3231/src/ds3231_shell.c
index 4434c86db..83b52c6ee 100644
--- a/hw/drivers/rtc/ds3231/src/ds3231_shell.c
+++ b/hw/drivers/rtc/ds3231/src/ds3231_shell.c
@@ -23,13 +23,6 @@
 
 #if MYNEWT_VAL(DS3231_CLI)
 
-static int ds3231_shell_cmd(int argc, char **argv);
-
-static struct shell_cmd ds3231_shell_cmd_struct = {
-    .sc_cmd = "ds3231",
-    .sc_cmd_func = ds3231_shell_cmd
-};
-
 static int
 ds3231_shell_err_unknown_arg(char *cmd_name)
 {
@@ -41,7 +34,7 @@ ds3231_shell_err_unknown_arg(char *cmd_name)
 static int
 ds3231_shell_help(void)
 {
-    console_printf("%s cmd [flags...]\n", ds3231_shell_cmd_struct.sc_cmd);
+    console_printf("ds3231 cmd [flags...]\n");
     console_printf("cmd:\n");
     console_printf("\tdate [date-time]\n");
     console_printf("\ttemp\n");
@@ -71,7 +64,7 @@ ds3231_shell_cmd_date(int argc, char **argv)
             console_printf("Invalid time format\n");
         } else {
             timeval_to_clocktime(&tv, &tz, &ct);
-            ds3231_write_time(ds3231, &ct);
+            rc = ds3231_write_time(ds3231, &ct);
             if (rc) {
                 console_printf("write time failed %d\n", rc);
             }
@@ -217,13 +210,6 @@ ds3231_shell_cmd(int argc, char **argv)
     return ds3231_shell_err_unknown_arg(argv[1]);
 }
 
-void
-ds3231_shell_init(void)
-{
-    int rc;
-
-    rc = shell_cmd_register(&ds3231_shell_cmd_struct);
-    SYSINIT_PANIC_ASSERT(rc == 0);
-}
+MAKE_SHELL_CMD(ds3231, ds3231_shell_cmd, NULL)
 
 #endif

Reply via email to