mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-06 13:14:27 +00:00
83d290c56f
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
64 lines
1.4 KiB
C
64 lines
1.4 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* (C) Copyright 2015
|
|
* Lukasz Majewski <l.majewski@majess.pl>
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <malloc.h>
|
|
#include <errno.h>
|
|
#include <dfu.h>
|
|
|
|
int dfu_tftp_write(char *dfu_entity_name, unsigned int addr, unsigned int len,
|
|
char *interface, char *devstring)
|
|
{
|
|
char *s, *sb;
|
|
int alt_setting_num, ret;
|
|
struct dfu_entity *dfu;
|
|
|
|
debug("%s: name: %s addr: 0x%x len: %d device: %s:%s\n", __func__,
|
|
dfu_entity_name, addr, len, interface, devstring);
|
|
|
|
ret = dfu_init_env_entities(interface, devstring);
|
|
if (ret)
|
|
goto done;
|
|
|
|
/*
|
|
* We need to copy name pointed by *dfu_entity_name since this text
|
|
* is the integral part of the FDT image.
|
|
* Any implicit modification (i.e. done by strsep()) will corrupt
|
|
* the FDT image and prevent other images to be stored.
|
|
*/
|
|
s = strdup(dfu_entity_name);
|
|
sb = s;
|
|
if (!s) {
|
|
ret = -ENOMEM;
|
|
goto done;
|
|
}
|
|
|
|
strsep(&s, "@");
|
|
debug("%s: image name: %s strlen: %zd\n", __func__, sb, strlen(sb));
|
|
|
|
alt_setting_num = dfu_get_alt(sb);
|
|
free(sb);
|
|
if (alt_setting_num < 0) {
|
|
pr_err("Alt setting [%d] to write not found!",
|
|
alt_setting_num);
|
|
ret = -ENODEV;
|
|
goto done;
|
|
}
|
|
|
|
dfu = dfu_get_entity(alt_setting_num);
|
|
if (!dfu) {
|
|
pr_err("DFU entity for alt: %d not found!", alt_setting_num);
|
|
ret = -ENODEV;
|
|
goto done;
|
|
}
|
|
|
|
ret = dfu_write_from_mem_addr(dfu, (void *)(uintptr_t)addr, len);
|
|
|
|
done:
|
|
dfu_free_entities();
|
|
|
|
return ret;
|
|
}
|