Patchwork [U-Boot] Generalize "cls" command

login
register
mail settings
Submitter Anatolij Gustschin
Date March 30, 2013, 6:53 p.m.
Message ID <1364669620-27063-1-git-send-email-agust@denx.de>
Download mbox | patch
Permalink /patch/232548/
State Awaiting Upstream
Delegated to: Anatolij Gustschin
Headers show

Comments

Anatolij Gustschin - March 30, 2013, 6:53 p.m.
From: Pali Rohár <pali.rohar@gmail.com>

Add unified command "cls". Previously this command existed only
as part of the LCD driver, now it is available for other users
as well and supports clearing ANSI terminal. The command is
enabled for all boards defining CONFIG_LCD to be backward
compatible.

Also add command description to README and fix nokia_rx51
board config file to enable the "cls" command.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Cc: Marcel Mol <marcel@mesa.nl>
Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
This patch is a rework based on the original patch
http://patchwork.ozlabs.org/patch/217492/

 README                       |    1 +
 common/Makefile              |    1 +
 common/cmd_cls.c             |   37 +++++++++++++++++++++++++++++++++++++
 common/lcd.c                 |   13 -------------
 include/common.h             |    9 +++++++++
 include/configs/nokia_rx51.h |    2 +-
 6 files changed, 49 insertions(+), 14 deletions(-)
 create mode 100644 common/cmd_cls.c
Anatolij Gustschin - May 6, 2013, 3:43 p.m.
Hi,

On Sat, 30 Mar 2013 19:53:40 +0100
Anatolij Gustschin <agust@denx.de> wrote:

> From: Pali Rohár <pali.rohar@gmail.com>
> 
> Add unified command "cls". Previously this command existed only
> as part of the LCD driver, now it is available for other users
> as well and supports clearing ANSI terminal. The command is
> enabled for all boards defining CONFIG_LCD to be backward
> compatible.
> 
> Also add command description to README and fix nokia_rx51
> board config file to enable the "cls" command.
> 
> Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> Cc: Marcel Mol <marcel@mesa.nl>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> ---
> This patch is a rework based on the original patch
> http://patchwork.ozlabs.org/patch/217492/
> 
>  README                       |    1 +
>  common/Makefile              |    1 +
>  common/cmd_cls.c             |   37 +++++++++++++++++++++++++++++++++++++
>  common/lcd.c                 |   13 -------------
>  include/common.h             |    9 +++++++++
>  include/configs/nokia_rx51.h |    2 +-
>  6 files changed, 49 insertions(+), 14 deletions(-)
>  create mode 100644 common/cmd_cls.c

Applied to u-boot-staging/agust@denx.de after re-base.

Thanks,

Anatolij

Patch

diff --git a/README b/README
index 7f2506a..b0ea592 100644
--- a/README
+++ b/README
@@ -819,6 +819,7 @@  The following options need to be configured:
 		CONFIG_CMD_BSP		* Board specific commands
 		CONFIG_CMD_BOOTD	  bootd
 		CONFIG_CMD_CACHE	* icache, dcache
+		CONFIG_CMD_CLS		  clear screen
 		CONFIG_CMD_CONSOLE	  coninfo
 		CONFIG_CMD_CRC32	* crc32
 		CONFIG_CMD_DATE		* support for RTC, date/time...
diff --git a/common/Makefile b/common/Makefile
index f631311..a4f780a 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -80,6 +80,7 @@  COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o
 COBJS-$(CONFIG_CMD_BOOTSTAGE) += cmd_bootstage.o
 COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o
 COBJS-$(CONFIG_CMD_CBFS) += cmd_cbfs.o
+COBJS-$(CONFIG_CMD_CLS) += cmd_cls.o
 COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o
 COBJS-$(CONFIG_CMD_CPLBINFO) += cmd_cplbinfo.o
 COBJS-$(CONFIG_DATAFLASH_MMC_SELECT) += cmd_dataflash_mmc_mux.o
diff --git a/common/cmd_cls.c b/common/cmd_cls.c
new file mode 100644
index 0000000..c220558
--- /dev/null
+++ b/common/cmd_cls.c
@@ -0,0 +1,37 @@ 
+/*
+ * Copyright 2011
+ * Marcel Mol, MESA Consulting, marcel@mesa.nl
+ *
+ * Copyright 2011
+ * Pali Rohár, pali.rohar@gmail.com
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ */
+
+#include <common.h>
+#include <command.h>
+#include <ansi.h>
+#include <lcd.h>
+
+static int do_clear(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+#ifdef CONFIG_LCD
+	lcd_clear();
+#else
+	puts(ANSI_CLEAR_CONSOLE);
+	printf(ANSI_CURSOR_POSITION, 1, 1);
+#endif
+	return 0;
+}
+
+U_BOOT_CMD(
+	cls,    1,     1,      do_clear,
+	"clear screen",
+	""
+);
diff --git a/common/lcd.c b/common/lcd.c
index 590bbb9..c511193 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -449,19 +449,6 @@  void lcd_clear(void)
 	lcd_sync();
 }
 
-static int do_lcd_clear(cmd_tbl_t *cmdtp, int flag, int argc,
-			char *const argv[])
-{
-	lcd_clear();
-	return 0;
-}
-
-U_BOOT_CMD(
-	cls,	1,	1,	do_lcd_clear,
-	"clear screen",
-	""
-);
-
 /*----------------------------------------------------------------------*/
 
 static int lcd_init(void *lcdbase)
diff --git a/include/common.h b/include/common.h
index d41aeb4..69eeea4 100644
--- a/include/common.h
+++ b/include/common.h
@@ -1015,4 +1015,13 @@  static inline void unmap_sysmem(const void *vaddr)
 # include <environment.h>
 #endif
 
+/*
+ * Boards with LCD support always provided the "cls" command.
+ * Enable this command for these boards to be backward
+ * compatible.
+ */
+#if defined(CONFIG_LCD)
+#define CONFIG_CMD_CLS
+#endif
+
 #endif	/* __COMMON_H_ */
diff --git a/include/configs/nokia_rx51.h b/include/configs/nokia_rx51.h
index 8506604..1a9b365 100644
--- a/include/configs/nokia_rx51.h
+++ b/include/configs/nokia_rx51.h
@@ -148,7 +148,7 @@ 
 #define CONFIG_CMDLINE_EDITING		/* add command line history */
 #define CONFIG_AUTO_COMPLETE		/* add autocompletion support */
 
-#define CONFIG_CMD_CLEAR		/* ANSI terminal clear screen command */
+#define CONFIG_CMD_CLS			/* ANSI terminal clear screen command */
 
 #ifdef ONENAND_SUPPORT