fwu: move meta-data management in core

Instead of each i/f having to implement their own meta-data verification
and storage, move the logic in common code. This simplifies the i/f code
much simpler and compact.

Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Tested-by: Sughosh Ganu <sughosh.ganu@linaro.org>
This commit is contained in:
Jassi Brar
2023-03-06 17:18:28 -06:00
committed by Tom Rini
parent b042c70554
commit 167994f295
3 changed files with 202 additions and 6 deletions

View File

@@ -16,6 +16,40 @@
#include <linux/types.h>
#include <u-boot/crc.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);
}
/**
* fwu_get_mdata_part_num() - Get the FWU metadata partition numbers
* @dev: FWU metadata device