dt-bindings: pinctrl: k3: Synchronize with v5.14 kernel
[platform/kernel/u-boot.git] / drivers / smem / smem-uclass.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (c) 2018 Ramon Fried <ramon.fried@gmail.com>
4  */
5
6 #define LOG_CATEGORY UCLASS_SMEM
7
8 #include <common.h>
9 #include <dm.h>
10 #include <smem.h>
11
12 int smem_alloc(struct udevice *dev, unsigned int host,
13                 unsigned int item, size_t size)
14 {
15         struct smem_ops *ops = smem_get_ops(dev);
16
17         if (!ops->alloc)
18                 return -ENOSYS;
19
20         return ops->alloc(host, item, size);
21 }
22
23 void *smem_get(struct udevice *dev, unsigned int host,
24                 unsigned int item, size_t *size)
25 {
26         struct smem_ops *ops = smem_get_ops(dev);
27
28         if (!ops->get)
29                 return NULL;
30
31         return ops->get(host, item, size);
32 }
33
34 int smem_get_free_space(struct udevice *dev, unsigned int host)
35 {
36         struct smem_ops *ops = smem_get_ops(dev);
37
38         if (!ops->get_free_space)
39                 return -ENOSYS;
40
41         return ops->get_free_space(host);
42 }
43
44 UCLASS_DRIVER(smem) = {
45         .id     = UCLASS_SMEM,
46         .name       = "smem",
47 };