laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1d/+/27578 )
Change subject: usb: Pass not just the actual transfer length but also the buffer size ...................................................................... usb: Pass not just the actual transfer length but also the buffer size Change-Id: I5088a5213d2945fdfaf3b242a63e35d0ed511914 --- M src/usb.c 1 file changed, 9 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/78/27578/1 diff --git a/src/usb.c b/src/usb.c index 40518d8..4d30742 100644 --- a/src/usb.c +++ b/src/usb.c @@ -104,7 +104,8 @@ struct libusb_transfer *xfr; }; -typedef int (*xfer_cb_t)(struct e1_usb_flow *flow, uint8_t *buf, int len); +/* len == actual length, size == underlying size of buffer */ +typedef int (*xfer_cb_t)(struct e1_usb_flow *flow, uint8_t *buf, int len, size_t size); struct e1_usb_flow { struct e1_line *line; @@ -124,7 +125,7 @@ // --------------------------------------------------------------------------- static int -e1_usb_xfer_in(struct e1_usb_flow *flow, uint8_t *buf, int len) +e1_usb_xfer_in(struct e1_usb_flow *flow, uint8_t *buf, int len, size_t size) { if (len == 0) return 0; @@ -132,7 +133,7 @@ } static int -e1_usb_xfer_out(struct e1_usb_flow *flow, uint8_t *buf, int len) +e1_usb_xfer_out(struct e1_usb_flow *flow, uint8_t *buf, int len, size_t size) { struct e1_line *line = flow->line; struct e1_usb_line_data *ld = (struct e1_usb_line_data *) line->drv_data; @@ -161,7 +162,7 @@ } static int -e1_usb_xfer_fb(struct e1_usb_flow *flow, uint8_t *buf, int len) +e1_usb_xfer_fb(struct e1_usb_flow *flow, uint8_t *buf, int len, size_t size) { struct e1_usb_line_data *ld = (struct e1_usb_line_data *) flow->line->drv_data; @@ -216,7 +217,8 @@ } flow->cb(flow, libusb_get_iso_packet_buffer_simple(xfr, j), - (iso_pd->status == LIBUSB_TRANSFER_COMPLETED) ? (int)iso_pd->actual_length : -1 + (iso_pd->status == LIBUSB_TRANSFER_COMPLETED) ? (int)iso_pd->actual_length : -1, + iso_pd->length ); len += (iso_pd->length = flow->size); } @@ -227,7 +229,7 @@ LOGPLI(flow->line, DE1D, LOGL_ERROR, "OUT EP %02x ISO packet %d failed with status %s\n", flow->ep, j, get_value_string(libusb_status_str, iso_pd->status)); } - len += (iso_pd->length = flow->cb(flow, &xfr->buffer[len], flow->size)); + len += (iso_pd->length = flow->cb(flow, &xfr->buffer[len], flow->size, flow->size)); } } @@ -300,7 +302,7 @@ len += (xfr->iso_packet_desc[j].length = flow->size); } else { for (j = 0; j < flow->ppx; j++) - len += (xfr->iso_packet_desc[j].length = flow->cb(flow, &flow->entries[i].buf[len], flow->size)); + len += (xfr->iso_packet_desc[j].length = flow->cb(flow, &flow->entries[i].buf[len], flow->size, flow->size)); } libusb_fill_iso_transfer(xfr, id->devh, flow->ep, -- To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/27578 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-e1d Gerrit-Branch: master Gerrit-Change-Id: I5088a5213d2945fdfaf3b242a63e35d0ed511914 Gerrit-Change-Number: 27578 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <lafo...@osmocom.org> Gerrit-MessageType: newchange