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 }; 27 28 static int do_log(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 29 { 30 cmd_tbl_t *cp; 31 32 if (argc < 2) 33 return CMD_RET_USAGE; 34 35 /* drop initial "log" arg */ 36 argc--; 37 argv++; 38 39 cp = find_cmd_tbl(argv[0], log_sub, ARRAY_SIZE(log_sub)); 40 if (cp) 41 return cp->cmd(cmdtp, flag, argc, argv); 42 43 return CMD_RET_USAGE; 44 } 45 46 #ifdef CONFIG_SYS_LONGHELP 47 static char log_help_text[] = 48 "level - get/set log level\n" 49 ; 50 #endif 51 52 U_BOOT_CMD( 53 log, CONFIG_SYS_MAXARGS, 1, do_log, 54 "log system", log_help_text 55 ); 56