Skip to content
Snippets Groups Projects
Commit c6b52c49 authored by Matt Sealey's avatar Matt Sealey Committed by Albert ARIBAUD
Browse files

spi: fix mxs_spi_slave structure allocation to clear memory


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: default avatarMatt Sealey <matt@genesi-usa.com>
Acked-by: default avatarStefano Babic <sbabic@denx.de>
parent 784097ae
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment