DM USB: dynamically allocate block count for struct usb_xfer

The block count of the struct usb_xfer is hard coded by the macro
USB_MAX_XFER_BLOCKS (1024), it wastes memory if 1024 blocks are
allocated for low speed transfer such as control transfer or interrupt
transfer. This patch introduces a new method to allocate different
number of blocks according to different endpoint type.

Tracked-On: #3628
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
Xiaoguang Wu
2019-08-27 22:28:18 +08:00
committed by wenlingz
parent f1b142e6e0
commit 06781b37e9
6 changed files with 95 additions and 42 deletions

View File

@@ -336,7 +336,7 @@ umouse_request(void *scarg, struct usb_xfer *xfer)
}
xfer->data[idx].stat = USB_BLOCK_HANDLED;
idx = index_inc(idx, USB_MAX_XFER_BLOCKS);
idx = index_inc(idx, xfer->max_blk_cnt);
}
err = USB_ERR_NORMAL_COMPLETION;
@@ -716,7 +716,7 @@ umouse_data_handler(void *scarg, struct usb_xfer *xfer, int dir,
data->stat = USB_BLOCK_HANDLED;
data = NULL;
idx = index_inc(idx, USB_MAX_XFER_BLOCKS);
idx = index_inc(idx, xfer->max_blk_cnt);
}
if (!data)
goto done;