From: Gabriel Somlo Date: Wed, 17 Jun 2020 21:21:33 +0000 (-0400) Subject: liblitesdcard/[spi]sdcard: avoid redundant (re-)initialization X-Git-Tag: 24jan2021_ls180~175^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9ad45a693273abc5cabe5b9d6376753a1e3b907e;p=litex.git liblitesdcard/[spi]sdcard: avoid redundant (re-)initialization --- diff --git a/litex/soc/software/liblitesdcard/sdcard.c b/litex/soc/software/liblitesdcard/sdcard.c index f3108f8a..abf8e7db 100644 --- a/litex/soc/software/liblitesdcard/sdcard.c +++ b/litex/soc/software/liblitesdcard/sdcard.c @@ -728,7 +728,8 @@ DSTATUS disk_status(uint8_t drv) { DSTATUS disk_initialize(uint8_t drv) { if (drv) return STA_NOINIT; - sdcardstatus = sdcard_init() ? 0 : STA_NOINIT; + if (sdcardstatus) + sdcardstatus = sdcard_init() ? 0 : STA_NOINIT; return sdcardstatus; } diff --git a/litex/soc/software/liblitesdcard/spisdcard.c b/litex/soc/software/liblitesdcard/spisdcard.c index 510c34fe..7131d083 100644 --- a/litex/soc/software/liblitesdcard/spisdcard.c +++ b/litex/soc/software/liblitesdcard/spisdcard.c @@ -277,8 +277,10 @@ DSTATUS disk_status(uint8_t drv) { DSTATUS disk_initialize(uint8_t drv) { if (drv) return STA_NOINIT; - spisdcardstatus = spisdcard_init() ? 0 : STA_NOINIT; - spisdcard_deselect(); + if (spisdcardstatus) { + spisdcardstatus = spisdcard_init() ? 0 : STA_NOINIT; + spisdcard_deselect(); + } return spisdcardstatus; }