blob: 0a8edaaa418fdf24c0aa984ada7a560980751637 [file] [log] [blame]
Sughosh Ganu2eaedc92022-10-21 18:15:55 +05301// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright (c) 2022, Linaro Limited
4 */
5
6#define LOG_CATEGORY UCLASS_FWU_MDATA
7
8#include <common.h>
9#include <dm.h>
10#include <efi_loader.h>
11#include <fwu.h>
12#include <fwu_mdata.h>
13#include <log.h>
14
15#include <linux/errno.h>
16#include <linux/types.h>
Sughosh Ganu2eaedc92022-10-21 18:15:55 +053017
18/**
Jassi Brar167994f2023-03-06 17:18:28 -060019 * fwu_read_mdata() - Wrapper around fwu_mdata_ops.read_mdata()
20 *
21 * Return: 0 if OK, -ve on error
22 */
23int fwu_read_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary)
24{
25 const struct fwu_mdata_ops *ops = device_get_ops(dev);
26
27 if (!ops->read_mdata) {
28 log_debug("read_mdata() method not defined\n");
29 return -ENOSYS;
30 }
31
32 return ops->read_mdata(dev, mdata, primary);
33}
34
35/**
36 * fwu_write_mdata() - Wrapper around fwu_mdata_ops.write_mdata()
37 *
38 * Return: 0 if OK, -ve on error
39 */
40int fwu_write_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary)
41{
42 const struct fwu_mdata_ops *ops = device_get_ops(dev);
43
44 if (!ops->write_mdata) {
45 log_debug("write_mdata() method not defined\n");
46 return -ENOSYS;
47 }
48
49 return ops->write_mdata(dev, mdata, primary);
50}
51
Sughosh Ganu2eaedc92022-10-21 18:15:55 +053052UCLASS_DRIVER(fwu_mdata) = {
53 .id = UCLASS_FWU_MDATA,
54 .name = "fwu-mdata",
55};