[PATCH 4/8] loadxy: use console_open/close
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Thu Oct 3 03:21:56 EDT 2013
so we can use non startup console
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
commands/loadxy.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/commands/loadxy.c b/commands/loadxy.c
index b90d2fd..7cefba4 100644
--- a/commands/loadxy.c
+++ b/commands/loadxy.c
@@ -99,6 +99,13 @@ static int do_loady(int argc, char *argv[])
return -ENODEV;
}
+ rcode = console_open(cdev);
+ if (rcode) {
+ printf("%s: can not open console %s\n",
+ argv[0], cname ? cname : "default");
+ return rcode;
+ }
+
current_baudrate = console_change_speed(cdev, load_baudrate);
printf("## Ready for binary (ymodem) download at %d bps...\n",
load_baudrate ? load_baudrate : current_baudrate);
@@ -115,6 +122,8 @@ static int do_loady(int argc, char *argv[])
console_change_speed(cdev, current_baudrate);
+ console_close(cdev);
+
return rcode;
}
@@ -167,6 +176,13 @@ static int do_loadx(int argc, char *argv[])
return -ENODEV;
}
+ rcode = console_open(cdev);
+ if (rcode) {
+ printf("%s: can not open console %s\n",
+ argv[0], cname ? cname : "default");
+ return rcode;
+ }
+
/* Load Defaults */
if (!output_file)
output_file = DEF_FILE;
@@ -175,7 +191,8 @@ static int do_loadx(int argc, char *argv[])
ofd = open(output_file, open_mode);
if (ofd < 0) {
perror(argv[0]);
- return 3;
+ rcode = 3;
+ goto err;
}
/* Seek to the right offset */
if (offset) {
@@ -184,7 +201,8 @@ static int do_loadx(int argc, char *argv[])
close(ofd);
ofd = 0;
perror(argv[0]);
- return 4;
+ rcode = 4;
+ goto err;
}
}
@@ -199,6 +217,9 @@ static int do_loadx(int argc, char *argv[])
}
console_change_speed(cdev, current_baudrate);
+err:
+ console_close(cdev);
+
return rcode;
}
--
1.8.4.rc3
More information about the barebox
mailing list