mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-05 11:00:15 +00:00
246ec2a12c
The common code can now read, verify and fix meta-data copies while exposing one consistent structure to users. Only the .read_mdata() and .write_mdata() callbacks of fwu_mdata_ops are needed. Get rid of .get_mdata() .update_mdata() .get_mdata_part_num() .read_mdata_partition() and .write_mdata_partition() and also the corresponding wrapper functions. Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Tested-by: Sughosh Ganu <sughosh.ganu@linaro.org>
55 lines
1.1 KiB
C
55 lines
1.1 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)
|
|
{
|
|
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);
|
|
}
|
|
|
|
/**
|
|
* 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)
|
|
{
|
|
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);
|
|
}
|
|
|
|
UCLASS_DRIVER(fwu_mdata) = {
|
|
.id = UCLASS_FWU_MDATA,
|
|
.name = "fwu-mdata",
|
|
};
|