This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit dcd26ac6b2e3d620c8f422aac7ebefc37f77e9e1
Author: Petro Karashchenko <[email protected]>
AuthorDate: Sat Jun 10 20:28:57 2023 +0300

    sdcard: update sdcard detection to avoid 0xff assignment to bool type
    
    Signed-off-by: Petro Karashchenko <[email protected]>
---
 boards/arm/gd32f4/gd32f450zk-eval/src/gd32f4xx_sdio.c    | 15 ++++-----------
 .../lpc4088-quickstart/src/lpc17_40_bringup.c            | 11 +++++++----
 boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_bringup.c    | 11 +++++++----
 boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_nsh.c        | 11 +++++++----
 boards/arm/lpc17xx_40xx/open1788/src/lpc17_40_bringup.c  | 11 +++++++----
 boards/arm/stm32/axoloti/src/stm32_sdio.c                | 11 ++++-------
 boards/arm/stm32/hymini-stm32v/src/stm32_appinit.c       | 16 ++++++----------
 boards/arm/stm32/nucleo-f429zi/src/stm32_sdio.c          | 12 ++++--------
 boards/arm/stm32/olimex-stm32-h407/src/stm32_sdio.c      | 12 ++++--------
 boards/arm/stm32/stm32f4discovery/src/stm32_sdio.c       | 12 ++++--------
 boards/arm/stm32f7/nucleo-144/src/stm32_sdio.c           | 12 ++++--------
 boards/arm/stm32f7/stm32f746-ws/src/stm32_sdmmc.c        | 12 ++++--------
 boards/arm/stm32f7/stm32f746g-disco/src/stm32_sdmmc.c    | 12 ++++--------
 boards/arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c    | 12 ++++--------
 boards/arm/stm32l4/nucleo-l496zg/src/stm32_sdio.c        | 12 ++++--------
 15 files changed, 74 insertions(+), 108 deletions(-)

diff --git a/boards/arm/gd32f4/gd32f450zk-eval/src/gd32f4xx_sdio.c 
b/boards/arm/gd32f4/gd32f450zk-eval/src/gd32f4xx_sdio.c
index c23e7d69a4..f3ec5fff55 100644
--- a/boards/arm/gd32f4/gd32f450zk-eval/src/gd32f4xx_sdio.c
+++ b/boards/arm/gd32f4/gd32f450zk-eval/src/gd32f4xx_sdio.c
@@ -57,7 +57,7 @@
 
 static struct sdio_dev_s *g_sdio_dev;
 #ifdef HAVE_NCD
-static bool g_sd_inserted = 0xff; /* Impossible value */
+static bool g_sd_inserted;
 #endif
 
 /****************************************************************************
@@ -104,13 +104,6 @@ int gd32_sdio_initialize(void)
 {
   int ret;
 
-#ifdef HAVE_NCD
-  /* Card detect */
-
-  bool cd_status;
-
-#endif
-
   /* Mount the SDIO-based MMC/SD block driver
    * First, get an instance of the SDIO interface
    */
@@ -140,10 +133,10 @@ int gd32_sdio_initialize(void)
 #ifdef HAVE_NCD
   /* Use SD card detect pin to check if a card is g_sd_inserted */
 
-  cd_status = !gd32_gpio_read(GPIO_SDMMC1_NCD);
-  finfo("Card detect : %d\n", cd_status);
+  g_sd_inserted = !gd32_gpio_read(GPIO_SDMMC1_NCD);
+  finfo("Card detect : %d\n", g_sd_inserted);
 
-  sdio_mediachange(g_sdio_dev, cd_status);
+  sdio_mediachange(g_sdio_dev, g_sd_inserted);
 #else
   /* Assume that the SD card is inserted.  What choice do we have? */
 
diff --git a/boards/arm/lpc17xx_40xx/lpc4088-quickstart/src/lpc17_40_bringup.c 
b/boards/arm/lpc17xx_40xx/lpc4088-quickstart/src/lpc17_40_bringup.c
index b8f95cc923..f7e8c0e9ae 100644
--- a/boards/arm/lpc17xx_40xx/lpc4088-quickstart/src/lpc17_40_bringup.c
+++ b/boards/arm/lpc17xx_40xx/lpc4088-quickstart/src/lpc17_40_bringup.c
@@ -151,6 +151,9 @@ static struct usbhost_connection_s *g_usbconn;
 #ifdef NSH_HAVE_MMCSD
 static struct sdio_dev_s *g_sdiodev;
 #endif
+#ifdef NSH_HAVE_MMCSD_CD
+static bool g_sd_inserted;
+#endif
 
 /****************************************************************************
  * Private Functions
@@ -205,14 +208,13 @@ static int nsh_waiter(int argc, char *argv[])
 #ifdef NSH_HAVE_MMCSD_CDINT
 static int nsh_cdinterrupt(int irq, void *context, void *arg)
 {
-  static bool inserted = 0xff; /* Impossible value */
   bool present;
 
   present = !lpc17_40_gpioread(GPIO_SD_CD);
-  if (present != inserted)
+  if (present != g_sd_inserted)
     {
       sdio_mediachange(g_sdiodev, present);
-      inserted = present;
+      g_sd_inserted = present;
     }
 
   return OK;
@@ -275,7 +277,8 @@ static int nsh_sdinitialize(void)
    */
 
 #ifdef NSH_HAVE_MMCSD_CD
-  sdio_mediachange(g_sdiodev, !lpc17_40_gpioread(GPIO_SD_CD));
+  g_sd_inserted = !lpc17_40_gpioread(GPIO_SD_CD);
+  sdio_mediachange(g_sdiodev, g_sd_inserted);
 #else
   sdio_mediachange(g_sdiodev, true);
 #endif
diff --git a/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_bringup.c 
b/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_bringup.c
index 076f2f1141..53936d5918 100644
--- a/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_bringup.c
+++ b/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_bringup.c
@@ -150,6 +150,9 @@ static struct usbhost_connection_s *g_usbconn;
 #ifdef NSH_HAVE_MMCSD
 static struct sdio_dev_s *g_sdiodev;
 #endif
+#ifdef NSH_HAVE_MMCSD_CD
+static bool g_sd_inserted;
+#endif
 
 /****************************************************************************
  * Private Functions
@@ -204,14 +207,13 @@ static int nsh_waiter(int argc, char *argv[])
 #ifdef NSH_HAVE_MMCSD_CDINT
 static int nsh_cdinterrupt(int irq, void *context, void *arg)
 {
-  static bool inserted = 0xff; /* Impossible value */
   bool present;
 
   present = !lpc17_40_gpioread(GPIO_SD_CD);
-  if (present != inserted)
+  if (present != g_sd_inserted)
     {
       sdio_mediachange(g_sdiodev, present);
-      inserted = present;
+      g_sd_inserted = present;
     }
 
   return OK;
@@ -273,7 +275,8 @@ static int nsh_sdinitialize(void)
    */
 
 #ifdef NSH_HAVE_MMCSD_CD
-  sdio_mediachange(g_sdiodev, !lpc17_40_gpioread(GPIO_SD_CD));
+  g_sd_inserted = !lpc17_40_gpioread(GPIO_SD_CD);
+  sdio_mediachange(g_sdiodev, g_sd_inserted);
 #else
   sdio_mediachange(g_sdiodev, true);
 #endif
diff --git a/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_nsh.c 
b/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_nsh.c
index f0840073fb..235923e8cd 100644
--- a/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_nsh.c
+++ b/boards/arm/lpc17xx_40xx/lx_cpu/src/lpc17_40_nsh.c
@@ -147,6 +147,9 @@ static struct usbhost_connection_s *g_usbconn;
 #ifdef NSH_HAVE_MMCSD
 static struct sdio_dev_s *g_sdiodev;
 #endif
+#ifdef NSH_HAVE_MMCSD_CD
+static bool g_sd_inserted;
+#endif
 
 /****************************************************************************
  * Private Functions
@@ -201,14 +204,13 @@ static int nsh_waiter(int argc, char *argv[])
 #ifdef NSH_HAVE_MMCSD_CDINT
 static int nsh_cdinterrupt(int irq, void *context)
 {
-  static bool inserted = 0xff; /* Impossible value */
   bool present;
 
   present = !lpc17_40_gpioread(GPIO_SD_CD);
-  if (present != inserted)
+  if (present != g_sd_inserted)
     {
       sdio_mediachange(g_sdiodev, present);
-      inserted = present;
+      g_sd_inserted = present;
     }
 
   return OK;
@@ -270,7 +272,8 @@ static int nsh_sdinitialize(void)
    */
 
 #ifdef NSH_HAVE_MMCSD_CD
-  sdio_mediachange(g_sdiodev, !lpc17_40_gpioread(GPIO_SD_CD));
+  g_sd_inserted = !lpc17_40_gpioread(GPIO_SD_CD);
+  sdio_mediachange(g_sdiodev, g_sd_inserted);
 #else
   sdio_mediachange(g_sdiodev, true);
 #endif
diff --git a/boards/arm/lpc17xx_40xx/open1788/src/lpc17_40_bringup.c 
b/boards/arm/lpc17xx_40xx/open1788/src/lpc17_40_bringup.c
index 63688f8aa0..4f76aad9b6 100644
--- a/boards/arm/lpc17xx_40xx/open1788/src/lpc17_40_bringup.c
+++ b/boards/arm/lpc17xx_40xx/open1788/src/lpc17_40_bringup.c
@@ -150,6 +150,9 @@ static struct usbhost_connection_s *g_usbconn;
 #ifdef NSH_HAVE_MMCSD
 static struct sdio_dev_s *g_sdiodev;
 #endif
+#ifdef NSH_HAVE_MMCSD_CD
+static bool g_sd_inserted;
+#endif
 
 /****************************************************************************
  * Private Functions
@@ -204,14 +207,13 @@ static int nsh_waiter(int argc, char *argv[])
 #ifdef NSH_HAVE_MMCSD_CDINT
 static int nsh_cdinterrupt(int irq, void *context, void *arg)
 {
-  static bool inserted = 0xff; /* Impossible value */
   bool present;
 
   present = !lpc17_40_gpioread(GPIO_SD_CD);
-  if (present != inserted)
+  if (present != g_sd_inserted)
     {
       sdio_mediachange(g_sdiodev, present);
-      inserted = present;
+      g_sd_inserted = present;
     }
 
   return OK;
@@ -274,7 +276,8 @@ static int nsh_sdinitialize(void)
    */
 
 #ifdef NSH_HAVE_MMCSD_CD
-  sdio_mediachange(g_sdiodev, !lpc17_40_gpioread(GPIO_SD_CD));
+  g_sd_inserted = !lpc17_40_gpioread(GPIO_SD_CD);
+  sdio_mediachange(g_sdiodev, g_sd_inserted);
 #else
   sdio_mediachange(g_sdiodev, true);
 #endif
diff --git a/boards/arm/stm32/axoloti/src/stm32_sdio.c 
b/boards/arm/stm32/axoloti/src/stm32_sdio.c
index 6d51212fc1..5b6ed6b407 100644
--- a/boards/arm/stm32/axoloti/src/stm32_sdio.c
+++ b/boards/arm/stm32/axoloti/src/stm32_sdio.c
@@ -54,7 +54,7 @@
 
 static struct sdio_dev_s *g_sdio_dev;
 #ifdef HAVE_NCD
-static bool g_sd_inserted = 0xff;       /* Impossible value */
+static bool g_sd_inserted;
 #endif
 
 /****************************************************************************
@@ -102,8 +102,6 @@ int stm32_sdio_initialize(void)
   int ret;
 
 #ifdef HAVE_NCD
-  bool cd_status;
-
   /* Configure the card detect GPIO */
 
   stm32_configgpio(GPIO_SDIO_NCD);
@@ -112,7 +110,6 @@ int stm32_sdio_initialize(void)
 
   stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true,
                      stm32_ncd_interrupt, NULL);
-
 #endif
 
   /* Mount the SDIO-based MMC/SD block driver.
@@ -142,9 +139,9 @@ int stm32_sdio_initialize(void)
 #ifdef HAVE_NCD
   /* Use SD card detect pin to check if a card is g_sd_inserted */
 
-  cd_status = !stm32_gpioread(GPIO_SDIO_NCD);
-  finfo("Card detect : %d\n", cd_status);
-  sdio_mediachange(g_sdio_dev, cd_status);
+  g_sd_inserted = !stm32_gpioread(GPIO_SDIO_NCD);
+  finfo("Card detect : %d\n", g_sd_inserted);
+  sdio_mediachange(g_sdio_dev, g_sd_inserted);
 #else
   /* Assume that the SD card is inserted.  What choice do we have? */
 
diff --git a/boards/arm/stm32/hymini-stm32v/src/stm32_appinit.c 
b/boards/arm/stm32/hymini-stm32v/src/stm32_appinit.c
index 444bac8cdd..97dd73b5b9 100644
--- a/boards/arm/stm32/hymini-stm32v/src/stm32_appinit.c
+++ b/boards/arm/stm32/hymini-stm32v/src/stm32_appinit.c
@@ -95,6 +95,7 @@
 
 #ifdef CONFIG_MMCSD
 static struct sdio_dev_s *g_sdiodev;
+static bool g_sd_inserted;
 #endif
 
 /****************************************************************************
@@ -112,14 +113,13 @@ static struct sdio_dev_s *g_sdiodev;
 #ifdef NSH_HAVEMMCSD
 static int nsh_cdinterrupt(int irq, void *context, void *arg)
 {
-  static bool inserted = 0xff; /* Impossible value */
   bool present;
 
   present = !stm32_gpioread(GPIO_SD_CD);
-  if (present != inserted)
+  if (present != g_sd_inserted)
     {
       sdio_mediachange(g_sdiodev, present);
-      inserted = present;
+      g_sd_inserted = present;
     }
 
   return OK;
@@ -158,10 +158,6 @@ int board_app_initialize(uintptr_t arg)
   int ret;
 
 #ifdef NSH_HAVEMMCSD
-  /* Card detect */
-
-  bool cd_status;
-
   /* Configure the card detect GPIO */
 
   stm32_configgpio(GPIO_SD_CD);
@@ -203,10 +199,10 @@ int board_app_initialize(uintptr_t arg)
 
   /* Use SD card detect pin to check if a card is inserted */
 
-  cd_status = !stm32_gpioread(GPIO_SD_CD);
-  _info("Card detect : %hhu\n", cd_status);
+  g_sd_inserted = !stm32_gpioread(GPIO_SD_CD);
+  _info("Card detect : %hhu\n", g_sd_inserted);
 
-  sdio_mediachange(g_sdiodev, cd_status);
+  sdio_mediachange(g_sdiodev, g_sd_inserted);
 #endif
 
 #ifdef CONFIG_INPUT
diff --git a/boards/arm/stm32/nucleo-f429zi/src/stm32_sdio.c 
b/boards/arm/stm32/nucleo-f429zi/src/stm32_sdio.c
index 8d078898ac..bb9ccb98f3 100644
--- a/boards/arm/stm32/nucleo-f429zi/src/stm32_sdio.c
+++ b/boards/arm/stm32/nucleo-f429zi/src/stm32_sdio.c
@@ -58,7 +58,7 @@
 
 static struct sdio_dev_s *g_sdio_dev;
 #ifdef HAVE_NCD
-static bool g_sd_inserted = 0xff; /* Impossible value */
+static bool g_sd_inserted;
 #endif
 
 /****************************************************************************
@@ -106,10 +106,6 @@ int stm32_sdio_initialize(void)
   int ret;
 
 #ifdef HAVE_NCD
-  /* Card detect */
-
-  bool cd_status;
-
   /* Configure the card detect GPIO */
 
   stm32_configgpio(GPIO_SDMMC1_NCD);
@@ -149,10 +145,10 @@ int stm32_sdio_initialize(void)
 #ifdef HAVE_NCD
   /* Use SD card detect pin to check if a card is g_sd_inserted */
 
-  cd_status = !stm32_gpioread(GPIO_SDMMC1_NCD);
-  finfo("Card detect : %d\n", cd_status);
+  g_sd_inserted = !stm32_gpioread(GPIO_SDMMC1_NCD);
+  finfo("Card detect : %d\n", g_sd_inserted);
 
-  sdio_mediachange(g_sdio_dev, cd_status);
+  sdio_mediachange(g_sdio_dev, g_sd_inserted);
 #else
   /* Assume that the SD card is inserted.  What choice do we have? */
 
diff --git a/boards/arm/stm32/olimex-stm32-h407/src/stm32_sdio.c 
b/boards/arm/stm32/olimex-stm32-h407/src/stm32_sdio.c
index dba5a0f3f3..5a22fff6a9 100644
--- a/boards/arm/stm32/olimex-stm32-h407/src/stm32_sdio.c
+++ b/boards/arm/stm32/olimex-stm32-h407/src/stm32_sdio.c
@@ -56,7 +56,7 @@
 
 static struct sdio_dev_s *g_sdio_dev;
 #ifdef HAVE_NCD
-static bool g_sd_inserted = 0xff; /* Impossible value */
+static bool g_sd_inserted;
 #endif
 
 /****************************************************************************
@@ -104,10 +104,6 @@ int stm32_sdio_initialize(void)
   int ret;
 
 #ifdef HAVE_NCD
-  /* Card detect */
-
-  bool cd_status;
-
   /* Configure the card detect GPIO */
 
   stm32_configgpio(GPIO_SDIO_NCD);
@@ -147,10 +143,10 @@ int stm32_sdio_initialize(void)
 #ifdef HAVE_NCD
   /* Use SD card detect pin to check if a card is g_sd_inserted */
 
-  cd_status = !stm32_gpioread(GPIO_SDIO_NCD);
-  finfo("Card detect : %d\n", cd_status);
+  g_sd_inserted = !stm32_gpioread(GPIO_SDIO_NCD);
+  finfo("Card detect : %d\n", g_sd_inserted);
 
-  sdio_mediachange(g_sdio_dev, cd_status);
+  sdio_mediachange(g_sdio_dev, g_sd_inserted);
 #else
   /* Assume that the SD card is inserted.  What choice do we have? */
 
diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_sdio.c 
b/boards/arm/stm32/stm32f4discovery/src/stm32_sdio.c
index 81f55ecdb5..e98d493668 100644
--- a/boards/arm/stm32/stm32f4discovery/src/stm32_sdio.c
+++ b/boards/arm/stm32/stm32f4discovery/src/stm32_sdio.c
@@ -56,7 +56,7 @@
 
 static struct sdio_dev_s *g_sdio_dev;
 #ifdef HAVE_NCD
-static bool g_sd_inserted = 0xff; /* Impossible value */
+static bool g_sd_inserted;
 #endif
 
 /****************************************************************************
@@ -104,10 +104,6 @@ int stm32_sdio_initialize(void)
   int ret;
 
 #ifdef HAVE_NCD
-  /* Card detect */
-
-  bool cd_status;
-
   /* Configure the card detect GPIO */
 
   stm32_configgpio(GPIO_SDIO_NCD);
@@ -147,10 +143,10 @@ int stm32_sdio_initialize(void)
 #ifdef HAVE_NCD
   /* Use SD card detect pin to check if a card is g_sd_inserted */
 
-  cd_status = !stm32_gpioread(GPIO_SDIO_NCD);
-  finfo("Card detect : %d\n", cd_status);
+  g_sd_inserted = !stm32_gpioread(GPIO_SDIO_NCD);
+  finfo("Card detect : %d\n", g_sd_inserted);
 
-  sdio_mediachange(g_sdio_dev, cd_status);
+  sdio_mediachange(g_sdio_dev, g_sd_inserted);
 #else
   /* Assume that the SD card is inserted.  What choice do we have? */
 
diff --git a/boards/arm/stm32f7/nucleo-144/src/stm32_sdio.c 
b/boards/arm/stm32f7/nucleo-144/src/stm32_sdio.c
index f8c7ff43f3..f385dc6657 100644
--- a/boards/arm/stm32f7/nucleo-144/src/stm32_sdio.c
+++ b/boards/arm/stm32f7/nucleo-144/src/stm32_sdio.c
@@ -58,7 +58,7 @@
 
 static struct sdio_dev_s *g_sdio_dev;
 #ifdef HAVE_NCD
-static bool g_sd_inserted = 0xff; /* Impossible value */
+static bool g_sd_inserted;
 #endif
 
 /****************************************************************************
@@ -106,10 +106,6 @@ int stm32_sdio_initialize(void)
   int ret;
 
 #ifdef HAVE_NCD
-  /* Card detect */
-
-  bool cd_status;
-
   /* Configure the card detect GPIO */
 
   stm32_configgpio(GPIO_SDMMC1_NCD);
@@ -149,10 +145,10 @@ int stm32_sdio_initialize(void)
 #ifdef HAVE_NCD
   /* Use SD card detect pin to check if a card is g_sd_inserted */
 
-  cd_status = !stm32_gpioread(GPIO_SDMMC1_NCD);
-  finfo("Card detect : %d\n", cd_status);
+  g_sd_inserted = !stm32_gpioread(GPIO_SDMMC1_NCD);
+  finfo("Card detect : %d\n", g_sd_inserted);
 
-  sdio_mediachange(g_sdio_dev, cd_status);
+  sdio_mediachange(g_sdio_dev, g_sd_inserted);
 #else
   /* Assume that the SD card is inserted.  What choice do we have? */
 
diff --git a/boards/arm/stm32f7/stm32f746-ws/src/stm32_sdmmc.c 
b/boards/arm/stm32f7/stm32f746-ws/src/stm32_sdmmc.c
index 8e0ef27255..67a6405c3e 100644
--- a/boards/arm/stm32f7/stm32f746-ws/src/stm32_sdmmc.c
+++ b/boards/arm/stm32f7/stm32f746-ws/src/stm32_sdmmc.c
@@ -54,7 +54,7 @@
 
 static struct sdio_dev_s *g_sdio_dev;
 #ifdef HAVE_NCD
-static bool g_sd_inserted = 0xff; /* Impossible value */
+static bool g_sd_inserted;
 #endif
 
 /****************************************************************************
@@ -102,10 +102,6 @@ int stm32_sdio_initialize(void)
   int ret;
 
 #ifdef HAVE_NCD
-  /* Card detect */
-
-  bool cd_status;
-
   /* Configure the card detect GPIO */
 
   stm32_configgpio(GPIO_SDIO_NCD);
@@ -145,10 +141,10 @@ int stm32_sdio_initialize(void)
 #ifdef HAVE_NCD
   /* Use SD card detect pin to check if a card is g_sd_inserted */
 
-  cd_status = !stm32_gpioread(GPIO_SDIO_NCD);
-  finfo("Card detect : %d\n", cd_status);
+  g_sd_inserted = !stm32_gpioread(GPIO_SDIO_NCD);
+  finfo("Card detect : %d\n", g_sd_inserted);
 
-  sdio_mediachange(g_sdio_dev, cd_status);
+  sdio_mediachange(g_sdio_dev, g_sd_inserted);
 #else
   /* Assume that the SD card is inserted.  What choice do we have? */
 
diff --git a/boards/arm/stm32f7/stm32f746g-disco/src/stm32_sdmmc.c 
b/boards/arm/stm32f7/stm32f746g-disco/src/stm32_sdmmc.c
index f042b37ed4..ca0d57d2fd 100644
--- a/boards/arm/stm32f7/stm32f746g-disco/src/stm32_sdmmc.c
+++ b/boards/arm/stm32f7/stm32f746g-disco/src/stm32_sdmmc.c
@@ -55,7 +55,7 @@
 
 static struct sdio_dev_s *g_sdio_dev;
 #ifdef HAVE_NCD
-static bool g_sd_inserted = 0xff; /* Impossible value */
+static bool g_sd_inserted;
 #endif
 
 /****************************************************************************
@@ -103,10 +103,6 @@ int stm32_sdio_initialize(void)
   int ret;
 
 #ifdef HAVE_NCD
-  /* Card detect */
-
-  bool cd_status;
-
   /* Configure the card detect GPIO */
 
   stm32_configgpio(GPIO_SDIO_NCD);
@@ -146,10 +142,10 @@ int stm32_sdio_initialize(void)
 #ifdef HAVE_NCD
   /* Use SD card detect pin to check if a card is g_sd_inserted */
 
-  cd_status = !stm32_gpioread(GPIO_SDIO_NCD);
-  finfo("Card detect : %d\n", cd_status);
+  g_sd_inserted = !stm32_gpioread(GPIO_SDIO_NCD);
+  finfo("Card detect : %d\n", g_sd_inserted);
 
-  sdio_mediachange(g_sdio_dev, cd_status);
+  sdio_mediachange(g_sdio_dev, g_sd_inserted);
 #else
   /* Assume that the SD card is inserted.  What choice do we have? */
 
diff --git a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c 
b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c
index f897baf384..3a044a5a03 100644
--- a/boards/arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c
+++ b/boards/arm/stm32h7/stm32h747i-disco/src/stm32_sdmmc.c
@@ -55,7 +55,7 @@
 
 static struct sdio_dev_s *g_sdio_dev;
 #ifdef HAVE_NCD
-static bool g_sd_inserted = 0xff; /* Impossible value */
+static bool g_sd_inserted;
 #endif
 
 /****************************************************************************
@@ -103,10 +103,6 @@ int stm32_sdio_initialize(void)
   int ret;
 
 #ifdef HAVE_NCD
-  /* Card detect */
-
-  bool cd_status;
-
   /* Configure the card detect GPIO */
 
   stm32_configgpio(GPIO_SDIO_NCD);
@@ -146,10 +142,10 @@ int stm32_sdio_initialize(void)
 #ifdef HAVE_NCD
   /* Use SD card detect pin to check if a card is g_sd_inserted */
 
-  cd_status = !stm32_gpioread(GPIO_SDIO_NCD);
-  finfo("Card detect : %d\n", cd_status);
+  g_sd_inserted = !stm32_gpioread(GPIO_SDIO_NCD);
+  finfo("Card detect : %d\n", g_sd_inserted);
 
-  sdio_mediachange(g_sdio_dev, cd_status);
+  sdio_mediachange(g_sdio_dev, g_sd_inserted);
 #else
   /* Assume that the SD card is inserted.  What choice do we have? */
 
diff --git a/boards/arm/stm32l4/nucleo-l496zg/src/stm32_sdio.c 
b/boards/arm/stm32l4/nucleo-l496zg/src/stm32_sdio.c
index 6c160f1649..8b19da0e30 100644
--- a/boards/arm/stm32l4/nucleo-l496zg/src/stm32_sdio.c
+++ b/boards/arm/stm32l4/nucleo-l496zg/src/stm32_sdio.c
@@ -58,7 +58,7 @@
 
 static struct sdio_dev_s *g_sdio_dev;
 #ifdef HAVE_NCD
-static bool g_sd_inserted = 0xff; /* Impossible value */
+static bool g_sd_inserted;
 #endif
 
 /****************************************************************************
@@ -106,10 +106,6 @@ int stm32l4_sdio_initialize(void)
   int ret;
 
 #ifdef HAVE_NCD
-  /* Card detect */
-
-  bool cd_status;
-
   /* Configure the card detect GPIO */
 
   stm32l4_configgpio(GPIO_SDMMC1_NCD);
@@ -149,10 +145,10 @@ int stm32l4_sdio_initialize(void)
 #ifdef HAVE_NCD
   /* Use SD card detect pin to check if a card is g_sd_inserted */
 
-  cd_status = !stm32l4_gpioread(GPIO_SDMMC1_NCD);
-  finfo("Card detect : %d\n", cd_status);
+  g_sd_inserted = !stm32l4_gpioread(GPIO_SDMMC1_NCD);
+  finfo("Card detect : %d\n", g_sd_inserted);
 
-  sdio_mediachange(g_sdio_dev, cd_status);
+  sdio_mediachange(g_sdio_dev, g_sd_inserted);
 #else
   /* Assume that the SD card is inserted.  What choice do we have? */
 

Reply via email to