From c6fe3cd6bec591c6f49af2a95ca8b81226c8b31a Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 8 Jun 2015 14:12:01 +0200 Subject: loadxy: Use console_get_by_name Use console_get_by_name rather than iterating over the console list in the loadxy code. The code in loadxy.c used to test whether a console is active before using it. This check is dropped along the way since there's no reason to not being able to use a disabled console for loadxy. Signed-off-by: Sascha Hauer --- commands/loadxy.c | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) (limited to 'commands/loadxy.c') diff --git a/commands/loadxy.c b/commands/loadxy.c index 1e65cb6221..62b395626d 100644 --- a/commands/loadxy.c +++ b/commands/loadxy.c @@ -57,28 +57,6 @@ static int console_change_speed(struct console_device *cdev, int baudrate) return current_baudrate; } -static struct console_device *get_named_console(const char *cname) -{ - struct console_device *cdev; - const char *target; - - /* - * Assumption to have BOTH CONSOLE_STDIN AND STDOUT in the - * same output console - */ - for_each_console(cdev) { - target = dev_id(&cdev->class_dev); - if (strlen(target) != strlen(cname)) - continue; - printf("RJK: looking for %s in console name %s\n", - cname, target); - if ((cdev->f_active & (CONSOLE_STDIN | CONSOLE_STDOUT)) - && !strcmp(cname, target)) - return cdev; - } - return NULL; -} - /** * @brief provide the loady(Y-Modem or Y-Modem/G) support * @@ -112,7 +90,7 @@ static int do_loady(int argc, char *argv[]) } if (cname) - cdev = get_named_console(cname); + cdev = console_get_by_name(cname); else cdev = console_get_first_active(); if (!cdev) { @@ -196,7 +174,7 @@ static int do_loadx(int argc, char *argv[]) } if (cname) - cdev = get_named_console(cname); + cdev = console_get_by_name(cname); else cdev = console_get_first_active(); if (!cdev) { -- cgit v1.2.3