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