fwu-mdata-uclass.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright (c) 2022, Linaro Limited
  4. */
  5. #define LOG_CATEGORY UCLASS_FWU_MDATA
  6. #include <common.h>
  7. #include <dm.h>
  8. #include <efi_loader.h>
  9. #include <fwu.h>
  10. #include <fwu_mdata.h>
  11. #include <log.h>
  12. #include <linux/errno.h>
  13. #include <linux/types.h>
  14. /**
  15. * fwu_read_mdata() - Wrapper around fwu_mdata_ops.read_mdata()
  16. *
  17. * Return: 0 if OK, -ve on error
  18. */
  19. int fwu_read_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary)
  20. {
  21. const struct fwu_mdata_ops *ops = device_get_ops(dev);
  22. if (!ops->read_mdata) {
  23. log_debug("read_mdata() method not defined\n");
  24. return -ENOSYS;
  25. }
  26. return ops->read_mdata(dev, mdata, primary);
  27. }
  28. /**
  29. * fwu_write_mdata() - Wrapper around fwu_mdata_ops.write_mdata()
  30. *
  31. * Return: 0 if OK, -ve on error
  32. */
  33. int fwu_write_mdata(struct udevice *dev, struct fwu_mdata *mdata, bool primary)
  34. {
  35. const struct fwu_mdata_ops *ops = device_get_ops(dev);
  36. if (!ops->write_mdata) {
  37. log_debug("write_mdata() method not defined\n");
  38. return -ENOSYS;
  39. }
  40. return ops->write_mdata(dev, mdata, primary);
  41. }
  42. UCLASS_DRIVER(fwu_mdata) = {
  43. .id = UCLASS_FWU_MDATA,
  44. .name = "fwu-mdata",
  45. };