static const char ep1_path[] = USB_FUNCFS_SDB_PATH"/ep1";
static const char ep2_path[] = USB_FUNCFS_SDB_PATH"/ep2";
-/* Limit bulk read/write transfers to page size (usually 4096 bytes)
- *
- * This is the size individual transfer that sdbd will request to/from
- * kernel (via read/write(endpoint, ...). While the buffer could be
- * bigger (ffs allows that) this size is also the size of the
- * _continuous memory_ buffer allocated in kernel. Continous memory
- * is scarce resource and allocation of higher order can often fail in
- * a system with fragmented memory (kernel message: "sdbd: page
- * allocation failure: order:6, mode:0x24040c0").
- *
- * Only page-sized allocation are guaranteed to succeed and this is
- * used as default below (ffs_usb_init() will update to system's page
- * size, if possible).
- */
-#define XFER_MAX_DEFAULT 4096
-static int xfer_max = XFER_MAX_DEFAULT;
/* A local struct to store state of application */
struct usb_handle
int ret;
do {
- int xfer_len = length - count > xfer_max ? xfer_max : length - count;
- ret = sdb_write(bulkin_fd, buf + count, xfer_len);
+ ret = sdb_write(bulkin_fd, buf + count, length - count);
if (ret < 0) {
if (errno != EINTR)
return ret;
int ret;
do {
- int xfer_len = length - count > xfer_max ? xfer_max : length - count;
- ret = sdb_read(bulkout_fd, buf + count, xfer_len);
+ ret = sdb_read(bulkout_fd, buf + count, length - count);
if (ret < 0) {
if (errno != EINTR) {
D("[ usb_init - using FunctionFS ]\n");
- int pagesize = sysconf(_SC_PAGESIZE);
- if (pagesize > 0)
- xfer_max = pagesize;
-
h = calloc(1, sizeof(usb_handle));
if (h == NULL) {
perror("[ failed to allocate memory for usb FunctionFS bulk device ]\n");