]> git.sur5r.net Git - u-boot/blobdiff - drivers/spi/spi.c
dm: core: Add a function to decode a memory region
[u-boot] / drivers / spi / spi.c
index b76a26cef053fea6528098db03172f113d87b007..22910de0dd93581d3cddfd4f32e6d98acb96c812 100644 (file)
@@ -1,17 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (c) 2011 The Chromium OS Authors.
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
+#include <fdtdec.h>
 #include <malloc.h>
 #include <spi.h>
 
 int spi_set_wordlen(struct spi_slave *slave, unsigned int wordlen)
 {
        if (wordlen == 0 || wordlen > 32) {
-               printf("spi: invalid wordlen %d\n", wordlen);
+               printf("spi: invalid wordlen %u\n", wordlen);
                return -1;
        }
 
@@ -23,11 +23,12 @@ int spi_set_wordlen(struct spi_slave *slave, unsigned int wordlen)
 void *spi_do_alloc_slave(int offset, int size, unsigned int bus,
                         unsigned int cs)
 {
-       struct spi_slave *slave;
-       void *ptr;
+       u8 *ptr;
 
        ptr = malloc(size);
        if (ptr) {
+               struct spi_slave *slave;
+
                memset(ptr, '\0', size);
                slave = (struct spi_slave *)(ptr + offset);
                slave->bus = bus;