Ramon Fried | 7b384ec | 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 | b953ec2 | 2021-04-27 11:02:19 +0200 | [diff] [blame] | 6 | #define LOG_CATEGORY UCLASS_SMEM |
| 7 | |
Ramon Fried | 7b384ec | 2018-07-02 02:57:55 +0300 | [diff] [blame] | 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 | }; |