summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_fastboot.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-04-22 09:02:25 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-04-26 09:10:02 +0200
commit8228f9e1fd0dc5a5dc7ffe5aacd94cb3310cb94b (patch)
treea67b2031aaf9502d96f7e750b889acd760a67f32 /drivers/usb/gadget/f_fastboot.c
parent893228f66c63a452ad46537657d7bf8c98197702 (diff)
downloadbarebox-8228f9e1fd0dc5a5dc7ffe5aacd94cb3310cb94b.tar.gz
barebox-8228f9e1fd0dc5a5dc7ffe5aacd94cb3310cb94b.tar.xz
usb: fastboot: Use C API for ubiformat
This makes it possible to compile the fastboot gadget without command support. While at it bail out when ubiformat is not compiled in. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/usb/gadget/f_fastboot.c')
-rw-r--r--drivers/usb/gadget/f_fastboot.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index aaf784913b..b483d7f556 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -28,6 +28,8 @@
#include <dma.h>
#include <fs.h>
#include <libfile.h>
+#include <ubiformat.h>
+#include <stdlib.h>
#include <file-list.h>
#include <progress.h>
#include <environment.h>
@@ -687,9 +689,12 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req, const char *cmd
}
if (filetype == filetype_ubi) {
- char *cmd;
int fd;
struct mtd_info_user meminfo;
+ struct ubiformat_args args = {
+ .yes = 1,
+ .image = FASTBOOT_TMPFILE,
+ };
fd = open(filename, O_RDONLY);
if (fd < 0)
@@ -701,13 +706,14 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req, const char *cmd
if (ret)
goto copy;
- cmd = asprintf("ubiformat -y -f %s %s", FASTBOOT_TMPFILE, filename);
-
fastboot_tx_print(f_fb, "INFOThis is an UBI image...");
- ret = run_command(cmd);
+ if (!IS_ENABLED(CONFIG_UBIFORMAT)) {
+ fastboot_tx_print(f_fb, "FAILubiformat is not available");
+ return;
+ }
- free(cmd);
+ ret = ubiformat(meminfo.mtd, &args);
if (ret) {
fastboot_tx_print(f_fb, "FAILwrite partition: %s", strerror(-ret));