shell: device_service: refine level output
Fix the order so that it reflects the actual initialization order, rather than putting PRE_KERNEL initializations after APPLICATION. Add SMP in the proper location. Use the helper function to provide unique identifiers for "devices" that don't have a device pointer (so don't have a name). Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
parent
f0df72c269
commit
1fa3447b4e
1 changed files with 36 additions and 26 deletions
|
@ -33,16 +33,32 @@ static const struct device *levels[] = {
|
||||||
__device_end,
|
__device_end,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char *get_device_name(const struct device *dev,
|
||||||
|
char *buf,
|
||||||
|
size_t len)
|
||||||
|
{
|
||||||
|
const char *name = dev->name;
|
||||||
|
|
||||||
|
if ((name == NULL) || (name[0] == 0)) {
|
||||||
|
snprintf(buf, len, "[%p]", dev);
|
||||||
|
name = buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
static bool device_get_config_level(const struct shell *shell, int level)
|
static bool device_get_config_level(const struct shell *shell, int level)
|
||||||
{
|
{
|
||||||
const struct device *dev;
|
const struct device *dev;
|
||||||
bool devices = false;
|
bool devices = false;
|
||||||
|
char buf[20];
|
||||||
|
|
||||||
for (dev = levels[level]; dev < levels[level+1]; dev++) {
|
for (dev = levels[level]; dev < levels[level+1]; dev++) {
|
||||||
if (device_is_ready(dev)) {
|
if (device_is_ready(dev)) {
|
||||||
devices = true;
|
devices = true;
|
||||||
|
|
||||||
shell_fprintf(shell, SHELL_NORMAL, "- %s\n", dev->name);
|
shell_fprintf(shell, SHELL_NORMAL, "- %s\n",
|
||||||
|
get_device_name(dev, buf, sizeof(buf)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return devices;
|
return devices;
|
||||||
|
@ -55,18 +71,6 @@ static int cmd_device_levels(const struct shell *shell,
|
||||||
ARG_UNUSED(argv);
|
ARG_UNUSED(argv);
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
shell_fprintf(shell, SHELL_NORMAL, "POST_KERNEL:\n");
|
|
||||||
ret = device_get_config_level(shell, _SYS_INIT_LEVEL_POST_KERNEL);
|
|
||||||
if (ret == false) {
|
|
||||||
shell_fprintf(shell, SHELL_NORMAL, "- None\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
shell_fprintf(shell, SHELL_NORMAL, "APPLICATION:\n");
|
|
||||||
ret = device_get_config_level(shell, _SYS_INIT_LEVEL_APPLICATION);
|
|
||||||
if (ret == false) {
|
|
||||||
shell_fprintf(shell, SHELL_NORMAL, "- None\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
shell_fprintf(shell, SHELL_NORMAL, "PRE KERNEL 1:\n");
|
shell_fprintf(shell, SHELL_NORMAL, "PRE KERNEL 1:\n");
|
||||||
ret = device_get_config_level(shell, _SYS_INIT_LEVEL_PRE_KERNEL_1);
|
ret = device_get_config_level(shell, _SYS_INIT_LEVEL_PRE_KERNEL_1);
|
||||||
if (ret == false) {
|
if (ret == false) {
|
||||||
|
@ -79,21 +83,27 @@ static int cmd_device_levels(const struct shell *shell,
|
||||||
shell_fprintf(shell, SHELL_NORMAL, "- None\n");
|
shell_fprintf(shell, SHELL_NORMAL, "- None\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
shell_fprintf(shell, SHELL_NORMAL, "POST_KERNEL:\n");
|
||||||
}
|
ret = device_get_config_level(shell, _SYS_INIT_LEVEL_POST_KERNEL);
|
||||||
|
if (ret == false) {
|
||||||
static const char *get_device_name(const struct device *dev,
|
shell_fprintf(shell, SHELL_NORMAL, "- None\n");
|
||||||
char *buf,
|
|
||||||
size_t len)
|
|
||||||
{
|
|
||||||
const char *name = dev->name;
|
|
||||||
|
|
||||||
if ((name == NULL) || (name[0] == 0)) {
|
|
||||||
snprintf(buf, len, "[%p]", dev);
|
|
||||||
name = buf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
shell_fprintf(shell, SHELL_NORMAL, "APPLICATION:\n");
|
||||||
|
ret = device_get_config_level(shell, _SYS_INIT_LEVEL_APPLICATION);
|
||||||
|
if (ret == false) {
|
||||||
|
shell_fprintf(shell, SHELL_NORMAL, "- None\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
shell_fprintf(shell, SHELL_NORMAL, "SMP:\n");
|
||||||
|
ret = device_get_config_level(shell, _SYS_INIT_LEVEL_SMP);
|
||||||
|
if (ret == false) {
|
||||||
|
shell_fprintf(shell, SHELL_NORMAL, "- None\n");
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_SMP */
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cmd_device_list(const struct shell *shell,
|
static int cmd_device_list(const struct shell *shell,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue