blob: bab7a7e80d1d3e121a9531f610a8465d8a6a4624 [file] [log] [blame]
Sughosh Ganu0f9399a2022-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
Sughosh Ganu0f9399a2022-10-21 18:15:55 +05308#include <dm.h>
9#include <efi_loader.h>
10#include <fwu.h>
11#include <fwu_mdata.h>
12#include <log.h>
13
14#include <linux/errno.h>
15#include <linux/types.h>
Sughosh Ganu0f9399a2022-10-21 18:15:55 +053016
17/**
Jassi Brar821e4622023-03-06 17:18:28 -060018 * fwu_read_mdata() - Wrapper around fwu_mdata_ops.read_mdata()
19 *
20 * Return: 0 if OK, -ve on error
21 */
22int fwu_read_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary)
23{
24 const struct fwu_mdata_ops *ops = device_get_ops(dev);
25
26 if (!ops->read_mdata) {
27 log_debug("read_mdata() method not defined\n");
28 return -ENOSYS;
29 }
30
31 return ops->read_mdata(dev, mdata, primary);
32}
33
34/**
35 * fwu_write_mdata() - Wrapper around fwu_mdata_ops.write_mdata()
36 *
37 * Return: 0 if OK, -ve on error
38 */
39int fwu_write_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary)
40{
41 const struct fwu_mdata_ops *ops = device_get_ops(dev);
42
43 if (!ops->write_mdata) {
44 log_debug("write_mdata() method not defined\n");
45 return -ENOSYS;
46 }
47
48 return ops->write_mdata(dev, mdata, primary);
49}
50
Sughosh Ganu0f9399a2022-10-21 18:15:55 +053051UCLASS_DRIVER(fwu_mdata) = {
52 .id = UCLASS_FWU_MDATA,
53 .name = "fwu-mdata",
54};