Sughosh Ganu | 2eaedc9 | 2022-10-21 18:15:55 +0530 | [diff] [blame] | 1 | // 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 Ganu | 2eaedc9 | 2022-10-21 18:15:55 +0530 | [diff] [blame] | 17 | |
| 18 | /** |
Jassi Brar | 167994f | 2023-03-06 17:18:28 -0600 | [diff] [blame] | 19 | * fwu_read_mdata() - Wrapper around fwu_mdata_ops.read_mdata() |
| 20 | * |
| 21 | * Return: 0 if OK, -ve on error |
| 22 | */ |
| 23 | int 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 | */ |
| 40 | int 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 Ganu | 2eaedc9 | 2022-10-21 18:15:55 +0530 | [diff] [blame] | 52 | UCLASS_DRIVER(fwu_mdata) = { |
| 53 | .id = UCLASS_FWU_MDATA, |
| 54 | .name = "fwu-mdata", |
| 55 | }; |