aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjorn Andersson <bjorn.andersson@linaro.org>2021-04-15 17:42:06 -0500
committerBjorn Andersson <bjorn.andersson@linaro.org>2021-04-15 17:42:06 -0500
commit40df480740c5d9ae35764d2bc60a4897e063ef5f (patch)
tree1856076d236d9a3f0fd8ec46f65e606fcb1a54ec
parent91e609b61133300c8e5c60958d0a013a72ab2dc1 (diff)
usb: Drop ununsed eot argument to qdl_write
qdl_write() is always called with eot=true, so drop the parameter. As a length of 0 means we're not entering the loop and we're now always entering the conditonal block at the end we can remove the first chunk. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
-rw-r--r--firehose.c4
-rw-r--r--qdl.c19
-rw-r--r--qdl.h2
-rw-r--r--sahara.c6
4 files changed, 8 insertions, 23 deletions
diff --git a/firehose.c b/firehose.c
index 1912b53..c11c040 100644
--- a/firehose.c
+++ b/firehose.c
@@ -190,7 +190,7 @@ static int firehose_write(struct qdl_device *qdl, xmlDoc *doc)
if (qdl_debug)
fprintf(stderr, "FIREHOSE WRITE: %s\n", s);
- ret = qdl_write(qdl, s, len, true);
+ ret = qdl_write(qdl, s, len);
saved_errno = errno;
xmlFree(s);
return ret < 0 ? -saved_errno : 0;
@@ -404,7 +404,7 @@ static int firehose_program(struct qdl_device *qdl, struct program *program, int
if (n < max_payload_size)
memset(buf + n, 0, max_payload_size - n);
- n = qdl_write(qdl, buf, chunk_size * program->sector_size, true);
+ n = qdl_write(qdl, buf, chunk_size * program->sector_size);
if (n < 0)
err(1, "failed to write");
diff --git a/qdl.c b/qdl.c
index 0b1f4b9..256ca96 100644
--- a/qdl.c
+++ b/qdl.c
@@ -351,7 +351,7 @@ int qdl_read(struct qdl_device *qdl, void *buf, size_t len, unsigned int timeout
return ioctl(qdl->fd, USBDEVFS_BULK, &bulk);
}
-int qdl_write(struct qdl_device *qdl, const void *buf, size_t len, bool eot)
+int qdl_write(struct qdl_device *qdl, const void *buf, size_t len)
{
unsigned char *data = (unsigned char*) buf;
@@ -360,21 +360,6 @@ int qdl_write(struct qdl_device *qdl, const void *buf, size_t len, bool eot)
size_t len_orig = len;
int n;
- if(len == 0) {
- bulk.ep = qdl->out_ep;
- bulk.len = 0;
- bulk.data = data;
- bulk.timeout = 1000;
-
- n = ioctl(qdl->fd, USBDEVFS_BULK, &bulk);
- if(n != 0) {
- fprintf(stderr,"ERROR: n = %d, errno = %d (%s)\n",
- n, errno, strerror(errno));
- return -1;
- }
- return 0;
- }
-
while(len > 0) {
int xfer;
xfer = (len > qdl->out_maxpktsize) ? qdl->out_maxpktsize : len;
@@ -395,7 +380,7 @@ int qdl_write(struct qdl_device *qdl, const void *buf, size_t len, bool eot)
data += xfer;
}
- if (eot && (len_orig % qdl->out_maxpktsize) == 0) {
+ if (len_orig % qdl->out_maxpktsize == 0) {
bulk.ep = qdl->out_ep;
bulk.len = 0;
bulk.data = NULL;
diff --git a/qdl.h b/qdl.h
index 624e6c0..6d8c05a 100644
--- a/qdl.h
+++ b/qdl.h
@@ -10,7 +10,7 @@
struct qdl_device;
int qdl_read(struct qdl_device *qdl, void *buf, size_t len, unsigned int timeout);
-int qdl_write(struct qdl_device *qdl, const void *buf, size_t len, bool eot);
+int qdl_write(struct qdl_device *qdl, const void *buf, size_t len);
int firehose_run(struct qdl_device *qdl, const char *incdir, const char *storage);
int sahara_run(struct qdl_device *qdl, char *prog_mbn);
diff --git a/sahara.c b/sahara.c
index 676ac1c..adb03c6 100644
--- a/sahara.c
+++ b/sahara.c
@@ -101,7 +101,7 @@ static void sahara_hello(struct qdl_device *qdl, struct sahara_pkt *pkt)
resp.hello_resp.status = 0;
resp.hello_resp.mode = pkt->hello_req.mode;
- qdl_write(qdl, &resp, resp.length, true);
+ qdl_write(qdl, &resp, resp.length);
}
static int sahara_read_common(struct qdl_device *qdl, const char *mbn, off_t offset, size_t len)
@@ -126,7 +126,7 @@ static int sahara_read_common(struct qdl_device *qdl, const char *mbn, off_t off
goto out;
}
- n = qdl_write(qdl, buf, n, true);
+ n = qdl_write(qdl, buf, n);
if (n != len)
err(1, "failed to write %zu bytes to sahara", len);
@@ -180,7 +180,7 @@ static void sahara_eoi(struct qdl_device *qdl, struct sahara_pkt *pkt)
done.cmd = 5;
done.length = 0x8;
- qdl_write(qdl, &done, done.length, true);
+ qdl_write(qdl, &done, done.length);
}
static int sahara_done(struct qdl_device *qdl, struct sahara_pkt *pkt)