smem-uclass.c 846 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (c) 2018 Ramon Fried <ramon.fried@gmail.com>
  4. */
  5. #include <common.h>
  6. #include <dm.h>
  7. #include <smem.h>
  8. int smem_alloc(struct udevice *dev, unsigned int host,
  9. unsigned int item, size_t size)
  10. {
  11. struct smem_ops *ops = smem_get_ops(dev);
  12. if (!ops->alloc)
  13. return -ENOSYS;
  14. return ops->alloc(host, item, size);
  15. }
  16. void *smem_get(struct udevice *dev, unsigned int host,
  17. unsigned int item, size_t *size)
  18. {
  19. struct smem_ops *ops = smem_get_ops(dev);
  20. if (!ops->get)
  21. return NULL;
  22. return ops->get(host, item, size);
  23. }
  24. int smem_get_free_space(struct udevice *dev, unsigned int host)
  25. {
  26. struct smem_ops *ops = smem_get_ops(dev);
  27. if (!ops->get_free_space)
  28. return -ENOSYS;
  29. return ops->get_free_space(host);
  30. }
  31. UCLASS_DRIVER(smem) = {
  32. .id = UCLASS_SMEM,
  33. .name = "smem",
  34. };