1 /* 2 * Copyright (c) 2011 The Chromium OS Authors. 3 * 4 * SPDX-License-Identifier: GPL-2.0+ 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 } 27