aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/fwu-mdata
diff options
context:
space:
mode:
authorJassi Brar <jaswinder.singh@linaro.org>2023-03-06 17:18:28 -0600
committerTom Rini <trini@konsulko.com>2023-06-09 13:49:55 -0400
commit167994f295e29de417bdb7b05e02fe5fd9b0d054 (patch)
treee9b37032867069a33c68f418207c96a9f90e2dd0 /drivers/fwu-mdata
parentb042c705548da5a78f4144071a88083be60d331d (diff)
downloadu-boot-167994f295e29de417bdb7b05e02fe5fd9b0d054.tar.gz
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>
Diffstat (limited to 'drivers/fwu-mdata')
-rw-r--r--drivers/fwu-mdata/fwu-mdata-uclass.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/drivers/fwu-mdata/fwu-mdata-uclass.c b/drivers/fwu-mdata/fwu-mdata-uclass.c
index b477e9603fb..e03773c584a 100644
--- a/drivers/fwu-mdata/fwu-mdata-uclass.c
+++ b/drivers/fwu-mdata/fwu-mdata-uclass.c
@@ -17,6 +17,40 @@
#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
* @mdata_parts: array for storing the metadata partition numbers