blob: 92abb94dcc90fbc9164c9c509ca4bf493f994e89 [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 */
Sughosh Ganu15665c52024-03-22 16:27:16 +053022int fwu_read_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary,
23 uint32_t size)
Jassi Brar821e4622023-03-06 17:18:28 -060024{
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
Sughosh Ganu15665c52024-03-22 16:27:16 +053032 return ops->read_mdata(dev, mdata, primary, size);
Jassi Brar821e4622023-03-06 17:18:28 -060033}
34
35/**
36 * fwu_write_mdata() - Wrapper around fwu_mdata_ops.write_mdata()
37 *
38 * Return: 0 if OK, -ve on error
39 */
Sughosh Ganu15665c52024-03-22 16:27:16 +053040int fwu_write_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary,
41 uint32_t size)
Jassi Brar821e4622023-03-06 17:18:28 -060042{
43 const struct fwu_mdata_ops *ops = device_get_ops(dev);
44
45 if (!ops->write_mdata) {
46 log_debug("write_mdata() method not defined\n");
47 return -ENOSYS;
48 }
49
Sughosh Ganu15665c52024-03-22 16:27:16 +053050 return ops->write_mdata(dev, mdata, primary, size);
Jassi Brar821e4622023-03-06 17:18:28 -060051}
52
Sughosh Ganu0f9399a2022-10-21 18:15:55 +053053UCLASS_DRIVER(fwu_mdata) = {
54 .id = UCLASS_FWU_MDATA,
55 .name = "fwu-mdata",
56};