summaryrefslogtreecommitdiffstats
path: root/commands/loadxy.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-06-09 08:11:43 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-06-09 09:22:14 +0200
commit230c22252a11c2e8a2cf62fd8a141bb18bc213cb (patch)
tree810795f300c5b4aa12f53a549a28beac1a44b9f2 /commands/loadxy.c
parent3894344053adc2bf42d565670e4197316284e1a3 (diff)
downloadbarebox-230c22252a11c2e8a2cf62fd8a141bb18bc213cb.tar.gz
loadxy: use console_set_baudrate
No need to do this manually Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/loadxy.c')
-rw-r--r--commands/loadxy.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/commands/loadxy.c b/commands/loadxy.c
index d5cc588..a4b1bec 100644
--- a/commands/loadxy.c
+++ b/commands/loadxy.c
@@ -40,21 +40,6 @@
#define DEF_FILE "image.bin"
-static int console_change_speed(struct console_device *cdev, int baudrate)
-{
- int current_baudrate;
-
- current_baudrate = console_get_baudrate(cdev);
- if (baudrate && baudrate != current_baudrate) {
- printf("## Switch baudrate from %d to %d bps and press ENTER ...\n",
- current_baudrate, baudrate);
- mdelay(50);
- cdev->setbrg(cdev, baudrate);
- mdelay(50);
- }
- return current_baudrate;
-}
-
/**
* @brief provide the loady(Y-Modem or Y-Modem/G) support
*
@@ -97,7 +82,15 @@ static int do_loady(int argc, char *argv[])
return -ENODEV;
}
- current_baudrate = console_change_speed(cdev, load_baudrate);
+ current_baudrate = console_get_baudrate(cdev);
+
+ if (!load_baudrate)
+ load_baudrate = current_baudrate;
+
+ rc = console_set_baudrate(cdev, load_baudrate);
+ if (rc)
+ return rc;
+
printf("## Ready for binary (ymodem) download at %d bps...\n",
load_baudrate ? load_baudrate : current_baudrate);
@@ -111,7 +104,9 @@ static int do_loady(int argc, char *argv[])
rcode = 1;
}
- console_change_speed(cdev, current_baudrate);
+ rc = console_set_baudrate(cdev, current_baudrate);
+ if (rc)
+ return rc;
return rcode;
}
@@ -143,7 +138,7 @@ BAREBOX_CMD_END
static int do_loadx(int argc, char *argv[])
{
ulong offset = 0;
- int load_baudrate = 0, current_baudrate, ofd, opt, rcode = 0;
+ int load_baudrate = 0, current_baudrate, rc, ofd, opt, rcode = 0;
char *output_file = NULL, *cname = NULL;
struct console_device *cdev = NULL;
@@ -198,7 +193,15 @@ static int do_loadx(int argc, char *argv[])
}
}
- current_baudrate = console_change_speed(cdev, load_baudrate);
+ current_baudrate = console_get_baudrate(cdev);
+
+ if (!load_baudrate)
+ load_baudrate = current_baudrate;
+
+ rc = console_set_baudrate(cdev, load_baudrate);
+ if (rc)
+ return rc;
+
printf("## Ready for binary (xmodem) download "
"to 0x%08lX offset on %s device at %d bps...\n", offset,
output_file, load_baudrate ? load_baudrate : current_baudrate);
@@ -207,7 +210,10 @@ static int do_loadx(int argc, char *argv[])
printf("## Binary (xmodem) download aborted (%d)\n", rcode);
rcode = 1;
}
- console_change_speed(cdev, current_baudrate);
+
+ rc = console_set_baudrate(cdev, current_baudrate);
+ if (rc)
+ return rc;
return rcode;
}