Simon Glass | ba6c3ce | 2013-03-11 06:08:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The Chromium OS Authors. |
| 3 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | ba6c3ce | 2013-03-11 06:08:00 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <malloc.h> |
| 9 | #include <spi.h> |
| 10 | |
| 11 | void *spi_do_alloc_slave(int offset, int size, unsigned int bus, |
| 12 | unsigned int cs) |
| 13 | { |
| 14 | struct spi_slave *slave; |
| 15 | void *ptr; |
| 16 | |
| 17 | ptr = malloc(size); |
| 18 | if (ptr) { |
| 19 | memset(ptr, '\0', size); |
| 20 | slave = (struct spi_slave *)(ptr + offset); |
| 21 | slave->bus = bus; |
| 22 | slave->cs = cs; |
| 23 | } |
| 24 | |
| 25 | return ptr; |
| 26 | } |