mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-08-06 15:26:58 +02:00
In version 2 of the metadata structure, the size of the structure cannot be determined statically at build time. The structure is now broken into the top level structure which contains a field indicating the total size of the structure. Add a size parameter to the metadata access API functions to indicate the number of bytes to be accessed. This is then used to either read the entire structure, or only the top level structure. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Tested-by: Michal Simek <michal.simek@amd.com>
58 lines
1.2 KiB
C
58 lines
1.2 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* Copyright (c) 2022, Linaro Limited
|
|
*/
|
|
|
|
#define LOG_CATEGORY UCLASS_FWU_MDATA
|
|
|
|
#include <common.h>
|
|
#include <dm.h>
|
|
#include <efi_loader.h>
|
|
#include <fwu.h>
|
|
#include <fwu_mdata.h>
|
|
#include <log.h>
|
|
|
|
#include <linux/errno.h>
|
|
#include <linux/types.h>
|
|
|
|
/**
|
|
* fwu_read_mdata() - Wrapper around fwu_mdata_ops.read_mdata()
|
|
*
|
|
* Return: 0 if OK, -ve on error
|
|
*/
|
|
int fwu_read_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary,
|
|
uint32_t size)
|
|
{
|
|
const struct fwu_mdata_ops *ops = device_get_ops(dev);
|
|
|
|
if (!ops->read_mdata) {
|
|
log_debug("read_mdata() method not defined\n");
|
|
return -ENOSYS;
|
|
}
|
|
|
|
return ops->read_mdata(dev, mdata, primary, size);
|
|
}
|
|
|
|
/**
|
|
* fwu_write_mdata() - Wrapper around fwu_mdata_ops.write_mdata()
|
|
*
|
|
* Return: 0 if OK, -ve on error
|
|
*/
|
|
int fwu_write_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary,
|
|
uint32_t size)
|
|
{
|
|
const struct fwu_mdata_ops *ops = device_get_ops(dev);
|
|
|
|
if (!ops->write_mdata) {
|
|
log_debug("write_mdata() method not defined\n");
|
|
return -ENOSYS;
|
|
}
|
|
|
|
return ops->write_mdata(dev, mdata, primary, size);
|
|
}
|
|
|
|
UCLASS_DRIVER(fwu_mdata) = {
|
|
.id = UCLASS_FWU_MDATA,
|
|
.name = "fwu-mdata",
|
|
};
|