blob: ea39d1a1eea628fe54a8cd92dd05f23e34ea92fc [file] [log] [blame]
Simon Glassba6c3ce2013-03-11 06:08:00 +00001/*
2 * Copyright (c) 2011 The Chromium OS Authors.
3 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Simon Glassba6c3ce2013-03-11 06:08:00 +00005 */
6
7#include <common.h>
8#include <malloc.h>
9#include <spi.h>
10
11void *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}