summaryrefslogtreecommitdiffstats
path: root/scripts/omap3-usb-loader.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/omap3-usb-loader.c')
-rw-r--r--scripts/omap3-usb-loader.c47
1 files changed, 3 insertions, 44 deletions
diff --git a/scripts/omap3-usb-loader.c b/scripts/omap3-usb-loader.c
index 0f352c8453..a8d626c32f 100644
--- a/scripts/omap3-usb-loader.c
+++ b/scripts/omap3-usb-loader.c
@@ -30,6 +30,9 @@
#include <libusb.h> /* the main event */
+#include "common.h"
+#include "common.c"
+
/* Device specific defines (OMAP)
* Primary source: http://www.ti.com/lit/pdf/sprugn4
* Section 26.4.5 "Peripheral Booting"
@@ -325,50 +328,6 @@ found:
return handle;
}
-static unsigned char *read_file(char *path, size_t *readamt)
-{
- FILE *fp = fopen(path, "rb");
-
- if (!fp) {
- log_error("failed to open file \'%s\': %s\n", path,
- strerror(errno));
- return NULL;
- }
-
- unsigned char *data = NULL;
- size_t allocsize = 0;
- size_t iter = 0;
-
- while (1) {
- allocsize += 1024;
- data = realloc(data, allocsize);
- if (!data)
- return NULL;
-
- size_t readsize = allocsize - iter;
- size_t ret = fread(data + iter, sizeof (unsigned char), readsize, fp);
-
- iter += ret;
-
- if (ret != readsize) {
- if (feof(fp)) {
- break;
- } else if (ferror(fp)) {
- log_error("error file reading file \'%s\': %s\n",
- path, strerror(errno));
- free(data);
- return NULL;
- }
- }
- }
-
- /* trim the allocation down to size */
- data = realloc(data, iter);
- *readamt = iter;
-
- return data;
-}
-
static int transfer_first_stage(libusb_device_handle * handle, struct arg_state *args)
{
unsigned char *buffer = NULL;