return dfu_buf_size;
}
-unsigned char *dfu_get_buf(void)
+unsigned char *dfu_get_buf(struct dfu_entity *dfu)
{
char *s;
s = getenv("dfu_bufsiz");
dfu_buf_size = s ? (unsigned long)simple_strtol(s, NULL, 16) :
CONFIG_SYS_DFU_DATA_BUF_SIZE;
+ if (dfu->max_buf_size && dfu_buf_size > dfu->max_buf_size)
+ dfu_buf_size = dfu->max_buf_size;
dfu_buf = memalign(CONFIG_SYS_CACHELINE_SIZE, dfu_buf_size);
if (dfu_buf == NULL)
dfu->offset = 0;
dfu->bad_skip = 0;
dfu->i_blk_seq_num = 0;
- dfu->i_buf_start = dfu_get_buf();
+ dfu->i_buf_start = dfu_get_buf(dfu);
if (dfu->i_buf_start == NULL)
return -ENOMEM;
- dfu->i_buf_end = dfu_get_buf() + dfu_buf_size;
+ dfu->i_buf_end = dfu_get_buf(dfu) + dfu_buf_size;
dfu->i_buf = dfu->i_buf_start;
dfu->inited = 1;
__func__, dfu->name, buf, size, blk_seq_num, dfu->i_buf);
if (!dfu->inited) {
- dfu->i_buf_start = dfu_get_buf();
+ dfu->i_buf_start = dfu_get_buf(dfu);
if (dfu->i_buf_start == NULL)
return -ENOMEM;
dfu->i_blk_seq_num = 0;
dfu->crc = 0;
dfu->offset = 0;
- dfu->i_buf_end = dfu_get_buf() + dfu_buf_size;
+ dfu->i_buf_end = dfu_get_buf(dfu) + dfu_buf_size;
dfu->i_buf = dfu->i_buf_start;
dfu->b_left = 0;
strcpy(dfu->name, st);
dfu->alt = alt;
+ dfu->max_buf_size = 0;
/* Specific for mmc device */
if (strcmp(interface, "mmc") == 0) {
int *cnt)
{
long long int rcv_cnt = 0, left_to_rcv, ret_rcv;
- void *transfer_buffer = dfu_get_buf();
+ struct dfu_entity *dfu_entity = dfu_get_entity(alt_setting_num);
+ void *transfer_buffer = dfu_get_buf(dfu_entity);
void *buf = transfer_buffer;
int usb_pkt_cnt = 0, ret;
static int download_tail(long long int left, int cnt)
{
struct dfu_entity *dfu_entity = dfu_get_entity(alt_setting_num);
- void *transfer_buffer = dfu_get_buf();
+ void *transfer_buffer = dfu_get_buf(dfu_entity);
int ret;
debug("%s: left: %llu cnt: %d\n", __func__, left, cnt);
void *dev_private;
enum dfu_device_type dev_type;
enum dfu_layout layout;
+ unsigned long max_buf_size;
union {
struct mmc_internal_data mmc;
int dfu_get_alt(char *name);
bool dfu_reset(void);
int dfu_init_env_entities(char *interface, char *devstr);
-unsigned char *dfu_get_buf(void);
+unsigned char *dfu_get_buf(struct dfu_entity *dfu);
unsigned char *dfu_free_buf(void);
unsigned long dfu_get_buf_size(void);