Ramon Fried | cf1e49f | 2018-07-02 02:57:55 +0300 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (c) 2018 Ramon Fried <ramon.fried@gmail.com> |
| 4 | */ |
| 5 | |
Patrick Delaunay | 8131335 | 2021-04-27 11:02:19 +0200 | [diff] [blame] | 6 | #define LOG_CATEGORY UCLASS_SMEM |
| 7 | |
Ramon Fried | cf1e49f | 2018-07-02 02:57:55 +0300 | [diff] [blame] | 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 | }; |