Skip to content

Commit 221681e

Browse files
committed
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]>
1 parent 19e7e5d commit 221681e

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

hw/drivers/rtc/ds1307/pkg.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ pkg.req_apis:
3535
- log
3636
- stats
3737

38+
pkg.whole_archive: true
39+
40+
pkg.source_files:
41+
- src/ds1307.c
42+
43+
pkg.source_files.DS1307_CLI:
44+
- src/ds1307_shell.c
45+
3846
pkg.init:
3947
ds1307_pkg_init: 601
40-
41-
pkg.init.DS1307_CLI:
42-
ds1307_shell_init: 1000

hw/drivers/rtc/ds1307/src/ds1307_shell.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,10 @@
2424

2525
#if MYNEWT_VAL(DS1307_CLI)
2626

27-
static int ds1307_shell_cmd(int argc, char **argv);
28-
29-
static struct shell_cmd ds1307_shell_cmd_struct = {
30-
.sc_cmd = "ds1307",
31-
.sc_cmd_func = ds1307_shell_cmd
32-
};
33-
3427
static int
3528
ds1307_shell_help(void)
3629
{
37-
console_printf("%s cmd [args]\n", ds1307_shell_cmd_struct.sc_cmd);
30+
console_printf("ds1307 cmd [args]\n");
3831
console_printf("cmd:\n");
3932
console_printf("\tdate [date-time]\n");
4033
console_printf("\tr addr\n");
@@ -161,13 +154,6 @@ ds1307_shell_cmd(int argc, char **argv)
161154
return 0;
162155
}
163156

164-
void
165-
ds1307_shell_init(void)
166-
{
167-
int rc;
168-
169-
rc = shell_cmd_register(&ds1307_shell_cmd_struct);
170-
SYSINIT_PANIC_ASSERT(rc == 0);
171-
}
157+
MAKE_SHELL_CMD(ds1307, ds1307_shell_cmd, NULL)
172158

173159
#endif

0 commit comments

Comments
 (0)