1 /* 2 * Copyright (c) 2017 Google, Inc 3 * Written by Simon Glass <sjg@chromium.org> 4 * 5 * SPDX-License-Identifier: GPL-2.0+ 6 */ 7 8 #include <common.h> 9 #include <command.h> 10 #include <dm.h> 11 #include <log.h> 12 13 static int do_log_level(cmd_tbl_t *cmdtp, int flag, int argc, 14 char * const argv[]) 15 { 16 if (argc > 1) 17 gd->default_log_level = simple_strtol(argv[1], NULL, 10); 18 else 19 printf("Default log level: %d\n", gd->default_log_level); 20 21 return 0; 22 } 23 24 static cmd_tbl_t log_sub[] = { 25 U_BOOT_CMD_MKENT(level, CONFIG_SYS_MAXARGS, 1, do_log_level, "", ""), 26 #ifdef CONFIG_LOG_TEST 27 U_BOOT_CMD_MKENT(test, 2, 1, do_log_test, "", ""), 28 #endif 29 }; 30 31 static int do_log(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 32 { 33 cmd_tbl_t *cp; 34 35 if (argc < 2) 36 return CMD_RET_USAGE; 37 38 /* drop initial "log" arg */ 39 argc--; 40 argv++; 41 42 cp = find_cmd_tbl(argv[0], log_sub, ARRAY_SIZE(log_sub)); 43 if (cp) 44 return cp->cmd(cmdtp, flag, argc, argv); 45 46 return CMD_RET_USAGE; 47 } 48 49 #ifdef CONFIG_SYS_LONGHELP 50 static char log_help_text[] = 51 "level - get/set log level\n" 52 #ifdef CONFIG_LOG_TEST 53 "log test - run log tests\n" 54 #endif 55 ; 56 #endif 57 58 U_BOOT_CMD( 59 log, CONFIG_SYS_MAXARGS, 1, do_log, 60 "log system", log_help_text 61 ); 62