3 * Lukasz Majewski <l.majewski@majess.pl>
5 * SPDX-License-Identifier: GPL-2.0+
13 int dfu_tftp_write(char *dfu_entity_name, unsigned int addr, unsigned int len,
14 char *interface, char *devstring)
17 int alt_setting_num, ret;
18 struct dfu_entity *dfu;
20 debug("%s: name: %s addr: 0x%x len: %d device: %s:%s\n", __func__,
21 dfu_entity_name, addr, len, interface, devstring);
23 ret = dfu_init_env_entities(interface, devstring);
28 * We need to copy name pointed by *dfu_entity_name since this text
29 * is the integral part of the FDT image.
30 * Any implicit modification (i.e. done by strsep()) will corrupt
31 * the FDT image and prevent other images to be stored.
33 s = strdup(dfu_entity_name);
41 debug("%s: image name: %s strlen: %d\n", __func__, sb, strlen(sb));
43 alt_setting_num = dfu_get_alt(sb);
45 if (alt_setting_num < 0) {
46 error("Alt setting [%d] to write not found!",
52 dfu = dfu_get_entity(alt_setting_num);
54 error("DFU entity for alt: %d not found!", alt_setting_num);
59 ret = dfu_write_from_mem_addr(dfu, (void *)addr, len);