mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-23 11:33:32 +00:00
e97c89cc15
When building with clang, we see: board/emulation/common/qemu_dfu.c:51:24: warning: 'memset' call operates on objects of type 'char' while the size is based on a different type 'char *' [-Wsizeof-pointer-memaccess] As we're calling memset with the length set to the size of the pointer and not the size of the buffer. Correct this with a call of the size of the buffer itself. Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org> Acked-by: Sughosh Ganu <sughosh.ganu@linaro.org>
69 lines
1.5 KiB
C
69 lines
1.5 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (c) 2020 Linaro Limited
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <dfu.h>
|
|
#include <env.h>
|
|
#include <memalign.h>
|
|
#include <mtd.h>
|
|
|
|
#define DFU_ALT_BUF_LEN SZ_1K
|
|
|
|
static void board_get_alt_info(struct mtd_info *mtd, char *buf)
|
|
{
|
|
struct mtd_info *part;
|
|
bool first = true;
|
|
const char *name;
|
|
int len, partnum = 0;
|
|
|
|
name = mtd->name;
|
|
len = strlen(buf);
|
|
|
|
if (buf[0] != '\0')
|
|
len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, "&");
|
|
len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
|
|
"mtd %s=", name);
|
|
|
|
list_for_each_entry(part, &mtd->partitions, node) {
|
|
partnum++;
|
|
if (!first)
|
|
len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, ";");
|
|
first = false;
|
|
|
|
len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
|
|
"%s part %d",
|
|
part->name, partnum);
|
|
}
|
|
}
|
|
|
|
void set_dfu_alt_info(char *interface, char *devstr)
|
|
{
|
|
struct mtd_info *mtd;
|
|
|
|
ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
|
|
|
|
if (!IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) &&
|
|
env_get("dfu_alt_info"))
|
|
return;
|
|
|
|
memset(buf, 0, DFU_ALT_BUF_LEN);
|
|
|
|
/*
|
|
* Currently dfu_alt_info is needed on Qemu ARM64 for
|
|
* capsule updates
|
|
*/
|
|
if (IS_ENABLED(CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT) &&
|
|
IS_ENABLED(CONFIG_TARGET_QEMU_ARM_64BIT)) {
|
|
/* probe all MTD devices */
|
|
mtd_probe_devices();
|
|
|
|
mtd = get_mtd_device_nm("nor0");
|
|
if (!IS_ERR_OR_NULL(mtd))
|
|
board_get_alt_info(mtd, buf);
|
|
}
|
|
|
|
env_set("dfu_alt_info", buf);
|
|
printf("dfu_alt_info set\n");
|
|
}
|