smem-uclass.c 880 B

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