cfi new: fix new disabling buffer support
[barebox-mini2440.git] / commands / sleep.c
blob4a7aef083c4b491dd988530192be5dd13f6f1b76
1 /*
2 * sleep.c - delay execution
4 * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
6 * See file CREDITS for list of people who contributed to this
7 * project.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2
11 * as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <common.h>
24 #include <command.h>
25 #include <clock.h>
27 static int do_sleep (cmd_tbl_t *cmdtp, int argc, char *argv[])
29 uint64_t start;
30 ulong delay;
32 if (argc != 2)
33 return COMMAND_ERROR_USAGE;
35 delay = simple_strtoul(argv[1], NULL, 10);
37 start = get_time_ns();
38 while (!is_timeout(start, delay * SECOND)) {
39 if (ctrlc())
40 return 1;
43 return 0;
46 U_BOOT_CMD_START(sleep)
47 .cmd = do_sleep,
48 .usage = "delay execution for n seconds",
49 U_BOOT_CMD_END