spi.c 443 B

1234567891011121314151617181920212223242526
  1. /*
  2. * Copyright (c) 2011 The Chromium OS Authors.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <malloc.h>
  8. #include <spi.h>
  9. void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
  10. unsigned int cs)
  11. {
  12. struct spi_slave *slave;
  13. void *ptr;
  14. ptr = malloc(size);
  15. if (ptr) {
  16. memset(ptr, '\0', size);
  17. slave = (struct spi_slave *)(ptr + offset);
  18. slave->bus = bus;
  19. slave->cs = cs;
  20. }
  21. return ptr;
  22. }