]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
spi: fix mxs_spi_slave structure allocation to clear memory
authorMatt Sealey <matt@genesi-usa.com>
Fri, 17 Aug 2012 08:15:11 +0000 (08:15 +0000)
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>
Sat, 1 Sep 2012 12:58:27 +0000 (14:58 +0200)
Use calloc() instead of malloc() to allocate the mxs_spi_slave structure.
Clearing the memory is necessary since most of the time this gets done
super early in boot, but on warm reboots, and when SPI probing is done
long after the init stages it could actually pick up previously used memory,
and things like the chipselect polarity and other data end up being filled
with trash data if not explicitly set by the board files.

This solves a semi-random, almost unreproducable error whereby SPI devices
act very, very strangly on boot.

Signed-off-by: Matt Sealey <matt@genesi-usa.com>
Acked-by: Stefano Babic <sbabic@denx.de>
drivers/spi/mxs_spi.c

index a037c130efa5c09557c4be0a5552129222fc2759..5fa7f2b73c52b22e26919714dd66fcda8495639c 100644 (file)
@@ -91,7 +91,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
                return NULL;
        }
 
-       mxs_slave = malloc(sizeof(struct mxs_spi_slave));
+       mxs_slave = calloc(sizeof(struct mxs_spi_slave), 1);
        if (!mxs_slave)
                return NULL;