// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright (c) 2022, Linaro Limited
 */

#define LOG_CATEGORY UCLASS_FWU_MDATA

#include <dm.h>
#include <efi_loader.h>
#include <fwu.h>
#include <fwu_mdata.h>
#include <log.h>

#include <linux/errno.h>
#include <linux/types.h>

/**
 * fwu_read_mdata() - Wrapper around fwu_mdata_ops.read_mdata()
 *
 * Return: 0 if OK, -ve on error
 */
int fwu_read_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary,
		   uint32_t size)
{
	const struct fwu_mdata_ops *ops = device_get_ops(dev);

	if (!ops->read_mdata) {
		log_debug("read_mdata() method not defined\n");
		return -ENOSYS;
	}

	return ops->read_mdata(dev, mdata, primary, size);
}

/**
 * fwu_write_mdata() - Wrapper around fwu_mdata_ops.write_mdata()
 *
 * Return: 0 if OK, -ve on error
 */
int fwu_write_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary,
		    uint32_t size)
{
	const struct fwu_mdata_ops *ops = device_get_ops(dev);

	if (!ops->write_mdata) {
		log_debug("write_mdata() method not defined\n");
		return -ENOSYS;
	}

	return ops->write_mdata(dev, mdata, primary, size);
}

UCLASS_DRIVER(fwu_mdata) = {
	.id		= UCLASS_FWU_MDATA,
	.name		= "fwu-mdata",
};
