devices: merge to list_head

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
diff --git a/common/cmd_terminal.c b/common/cmd_terminal.c
index 57943c1..67a2546 100644
--- a/common/cmd_terminal.c
+++ b/common/cmd_terminal.c
@@ -27,10 +27,10 @@
 #include <common.h>
 #include <command.h>
 #include <devices.h>
+#include <serial.h>
 
 int do_terminal(cmd_tbl_t * cmd, int flag, int argc, char *argv[])
 {
-	int i, l;
 	int last_tilde = 0;
 	device_t *dev = NULL;
 
@@ -38,13 +38,7 @@
 		return -1;
 
 	/* Scan for selected output/input device */
-	for (i = 1; i <= ListNumItems (devlist); i++) {
-		device_t *tmp = ListGetPtrToItem (devlist, i);
-		if (!strcmp(tmp->name, argv[1])) {
-			dev = tmp;
-			break;
-		}
-	}
+	dev = device_get_by_name(argv[1]);
 	if (!dev)
 		return -1;