From: stefano babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] spi: fix mxc_spi_slave structure allocation to clear memory
Date: Sat, 18 Aug 2012 11:05:58 +0200 [thread overview]
Message-ID: <502F5AF6.8010404@denx.de> (raw)
In-Reply-To: <1345227311-11433-1-git-send-email-matt@genesi-usa.com>
Am 17/08/2012 20:15, schrieb Matt Sealey:
> Use calloc() instead of malloc() to allocate the mxc_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. Tested on Efika MX over several years..
>
> Signed-off-by: Matt Sealey <matt@genesi-usa.com>
> ---
> drivers/spi/mxc_spi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c
> index 2e15318..d1dab18 100644
> --- a/drivers/spi/mxc_spi.c
> +++ b/drivers/spi/mxc_spi.c
> @@ -408,7 +408,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
> if (bus >= ARRAY_SIZE(spi_bases))
> return NULL;
>
> - mxcs = malloc(sizeof(struct mxc_spi_slave));
> + mxcs = calloc(sizeof(struct mxc_spi_slave), 1);
> if (!mxcs) {
> puts("mxc_spi: SPI Slave not allocated !\n");
> return NULL;
>
Agree, the structure must be zeroed.
Acked-by: Stefano Babic <sbabic@denx.de>
Best regards,
Stefano Babic
--
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
next prev parent reply other threads:[~2012-08-18 9:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-17 18:15 [U-Boot] [PATCH 1/2] spi: fix mxc_spi_slave structure allocation to clear memory Matt Sealey
2012-08-17 18:15 ` [U-Boot] [PATCH 2/2] spi: fix mxs_spi_slave " Matt Sealey
2012-08-18 9:05 ` stefano babic
2012-08-20 7:59 ` Stefano Babic
2012-08-18 9:05 ` stefano babic [this message]
2012-08-20 7:59 ` [U-Boot] [PATCH 1/2] spi: fix mxc_spi_slave " Stefano Babic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=502F5AF6.8010404@denx.de \
--to=sbabic@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.