]>
Commit | Line | Data |
---|---|---|
7b384ecc RF |
1 | // SPDX-License-Identifier: GPL-2.0+ |
2 | /* | |
3 | * Copyright (c) 2018 Ramon Fried <[email protected]> | |
4 | */ | |
5 | ||
b953ec2b PD |
6 | #define LOG_CATEGORY UCLASS_SMEM |
7 | ||
7b384ecc RF |
8 | #include <dm.h> |
9 | #include <smem.h> | |
10 | ||
11 | int smem_alloc(struct udevice *dev, unsigned int host, | |
12 | unsigned int item, size_t size) | |
13 | { | |
14 | struct smem_ops *ops = smem_get_ops(dev); | |
15 | ||
16 | if (!ops->alloc) | |
17 | return -ENOSYS; | |
18 | ||
19 | return ops->alloc(host, item, size); | |
20 | } | |
21 | ||
22 | void *smem_get(struct udevice *dev, unsigned int host, | |
23 | unsigned int item, size_t *size) | |
24 | { | |
25 | struct smem_ops *ops = smem_get_ops(dev); | |
26 | ||
27 | if (!ops->get) | |
28 | return NULL; | |
29 | ||
30 | return ops->get(host, item, size); | |
31 | } | |
32 | ||
33 | int smem_get_free_space(struct udevice *dev, unsigned int host) | |
34 | { | |
35 | struct smem_ops *ops = smem_get_ops(dev); | |
36 | ||
37 | if (!ops->get_free_space) | |
38 | return -ENOSYS; | |
39 | ||
40 | return ops->get_free_space(host); | |
41 | } | |
42 | ||
43 | UCLASS_DRIVER(smem) = { | |
44 | .id = UCLASS_SMEM, | |
45 | .name = "smem", | |
46 | }; |