You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/10/29 13:09:18 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 opened a new pull request, #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and NXSEM_INITIALIZER

xiaoxiang781216 opened a new pull request, #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472

   ## Summary
   
   ## Impact
   Code refactor
   
   ## Testing
   Pass CI
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1008894823


##########
arch/arm/src/cxd56xx/cxd56_dmac.c:
##########
@@ -328,22 +332,25 @@ static struct dmac_register_map *get_device(int ch)
     case 2: return (struct dmac_register_map *)DMAC2_REG_BASE;
     case 3: return (struct dmac_register_map *)DMAC3_REG_BASE;
     }
+
     return NULL;
 }
 
 static struct dmac_ch_register_map *get_channel(int ch)
 {
   struct dmac_register_map *dev = get_device(ch);
   if (dev == NULL)
-     return NULL;
+    {
+      return NULL;
+    }
 
   if (is_dmac(2, dev))
     {
-        return &dev->channel[ch - 7];
+      return &dev->channel[ch - 7];

Review Comment:
   Done, the style change separate to a new patch



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] masayuki2009 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1015974954


##########
arch/arm/src/stm32h7/stm32_i2c.c:
##########
@@ -2805,7 +2805,6 @@ int stm32_i2cbus_uninitialize(struct i2c_master_s *dev)
   if (--priv->refs)
     {
       nxmutex_unlock(&priv->lock);
-      kmm_free(dev);
       return OK;

Review Comment:
   @xiaoxiang781216 
   Does this change relate to `Don't check nxsem_init and nxmutex_init ` ?
   



##########
arch/arm/src/stm32/stm32_i2c_v2.c:
##########
@@ -2804,7 +2804,6 @@ int stm32_i2cbus_uninitialize(struct i2c_master_s *dev)
   if (--priv->refs)
     {
       nxmutex_unlock(&priv->lock);
-      kmm_free(dev);
       return OK;

Review Comment:
   @xiaoxiang781216 
   Does this change relate to `Don't check nxsem_init and nxmutex_init ` ?
   



##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -77,7 +77,6 @@ struct cxd56_spidev_s
   uint8_t          port;        /* Port number */
   int              initialized; /* Initialized flag */
 #ifdef CONFIG_CXD56_DMAC
-  bool             dmaenable;   /* Use DMA or not */

Review Comment:
   @xiaoxiang781216 
   Does this change relate to `Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER` ?
   



##########
arch/arm/src/stm32l4/stm32l4_1wire.c:
##########
@@ -1247,7 +1247,6 @@ int stm32l4_1wireuninitialize(struct onewire_dev_s *dev)
   if (--priv->refs)
     {
       nxmutex_unlock(&priv->lock);
-      kmm_free(priv);
       return OK;

Review Comment:
   @xiaoxiang781216 
   Does this change relate to `Don't check nxsem_init and nxmutex_init ` ?
   



##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -1328,25 +1336,13 @@ void cxd56_spi_dmaconfig(int port, int chtype, DMA_HANDLE handle,
 
           priv->txdmach = handle;
           memcpy(&priv->txconfig, conf, sizeof(dma_config_t));
-
-          if (!priv->dmaenable)
-            {
-              nxsem_init(&priv->dmasem, 0, 0);
-              priv->dmaenable = true;
-            }
         }

Review Comment:
   @xiaoxiang781216 
   Does this change relate to `Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER` ?
   



##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -1328,25 +1336,13 @@ void cxd56_spi_dmaconfig(int port, int chtype, DMA_HANDLE handle,
 
           priv->txdmach = handle;
           memcpy(&priv->txconfig, conf, sizeof(dma_config_t));
-
-          if (!priv->dmaenable)
-            {
-              nxsem_init(&priv->dmasem, 0, 0);
-              priv->dmaenable = true;
-            }
         }
       else if ((chtype == CXD56_SPI_DMAC_CHTYPE_RX) && (!priv->rxdmach))
         {
           /* RX DMA setting */
 
           priv->rxdmach = handle;
           memcpy(&priv->rxconfig, conf, sizeof(dma_config_t));
-
-          if (!priv->dmaenable)
-            {
-              nxsem_init(&priv->dmasem, 0, 0);
-              priv->dmaenable = true;
-            }
         }

Review Comment:
   @xiaoxiang781216 
   Does this change relate to `Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER` ?
   



##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -863,15 +878,13 @@ static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer,
                          void *rxbuffer, size_t nwords)
 {
 #ifdef CONFIG_CXD56_DMAC
-  struct cxd56_spidev_s *priv = (struct cxd56_spidev_s *)dev;
-
 #ifdef CONFIG_CXD56_SPI_DMATHRESHOLD
   size_t dmath = CONFIG_CXD56_SPI_DMATHRESHOLD;
 #else
   size_t dmath = 0;
 #endif
 
-  if (priv->dmaenable && dmath < nwords)

Review Comment:
   @xiaoxiang781216 
   Does this change relate to `Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER` ?
   



##########
arch/arm/src/stm32f0l0g0/stm32_i2c.c:
##########
@@ -2803,7 +2803,6 @@ int stm32_i2cbus_uninitialize(struct i2c_master_s *dev)
   if (--priv->refs)
     {
       nxmutex_unlock(&priv->lock);
-      kmm_free(dev);

Review Comment:
   @xiaoxiang781216 
   Does this change relate to `Don't check nxsem_init and nxmutex_init ` ?
   



##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -1204,7 +1217,6 @@ struct spi_dev_s *cxd56_spibus_initialize(int port)
   /* DMA settings */
 
 #ifdef CONFIG_CXD56_DMAC
-  priv->dmaenable = false;

Review Comment:
   @xiaoxiang781216 
   Does this change relate to `Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER` ?
   



##########
arch/arm/src/stm32f7/stm32_i2c.c:
##########
@@ -2842,7 +2842,6 @@ int stm32_i2cbus_uninitialize(struct i2c_master_s *dev)
   if (--priv->refs)
     {
       nxmutex_unlock(&priv->lock);
-      kmm_free(dev);
       return OK;

Review Comment:
   @xiaoxiang781216 
   Does this change relate to `Don't check nxsem_init and nxmutex_init ` ?
   



##########
arch/arm/src/stm32l4/stm32l4_i2c.c:
##########
@@ -3007,7 +3007,6 @@ int stm32l4_i2cbus_uninitialize(struct i2c_master_s *dev)
   if (--priv->refs)
     {
       nxmutex_unlock(&priv->lock);
-      kmm_free(dev);
       return OK;

Review Comment:
   @xiaoxiang781216 
   Does this change relate to `Don't check nxsem_init and nxmutex_init ` ?
   



##########
arch/risc-v/src/bl602/bl602_spi.c:
##########
@@ -1671,7 +1671,7 @@ struct spi_dev_s *bl602_spibus_initialize(int port)
   nxmutex_lock(&priv->lock);
   if (priv->refs != 0)
     {
-      priv->refs--;
+      priv->refs++;
       nxmutex_unlock(&priv->lock);

Review Comment:
   @xiaoxiang781216 
   Does this change relate to `Don't check nxsem_init and nxmutex_init ` ?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011969249


##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -1020,7 +1018,7 @@ static inline struct sam_chan_s *sam_tc_initialize(int channel)
 
       /* Enable clocking to the timer counter */
 
-      sam_enableperiph0(tcconfig->pid);
+      sam_enableperiph0(tc->pid);

Review Comment:
   yes



##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -1008,7 +1006,7 @@ static inline struct sam_chan_s *sam_tc_initialize(int channel)
 
       /* Set the maximum TC peripheral clock frequency */
 
-      regval  = PMC_PCR_PID(tcconfig->pid) | PMC_PCR_CMD | PMC_PCR_EN;
+      regval  = PMC_PCR_PID(tc->pid) | PMC_PCR_CMD | PMC_PCR_EN;

Review Comment:
   yes



##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -954,19 +960,11 @@ static inline struct sam_chan_s *sam_tc_initialize(int channel)
   flags = enter_critical_section();
   if (!tc->initialized)
     {
-      /* Initialize the timer counter data structure. */
-
-      memset(tc, 0, sizeof(struct sam_tc_s));
-      nxmutex_init(&tc->lock);
-      tc->base = tcconfig->base;
-      tc->tc   = channel < 3 ? 0 : 1;
-      tc->pid  = tcconfig->pid;
-
       /* Initialize the channels */
 
       for (i = 0, ch = tcconfig->chfirst; i < SAM_TC_NCHANNELS; i++)
         {
-          tmrerr("ERROR: Initializing TC%d channel %d\n", tcconfig->tc, ch);
+          tmrerr("ERROR: Initializing TC%d channel %d\n", tc->tc, ch);

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1017907163


##########
arch/arm/src/stm32l4/stm32l4_i2c.c:
##########
@@ -3007,7 +3007,6 @@ int stm32l4_i2cbus_uninitialize(struct i2c_master_s *dev)
   if (--priv->refs)
     {
       nxmutex_unlock(&priv->lock);
-      kmm_free(dev);
       return OK;

Review Comment:
   move to new patch



##########
arch/arm/src/stm32h7/stm32_i2c.c:
##########
@@ -2805,7 +2805,6 @@ int stm32_i2cbus_uninitialize(struct i2c_master_s *dev)
   if (--priv->refs)
     {
       nxmutex_unlock(&priv->lock);
-      kmm_free(dev);
       return OK;

Review Comment:
   move to new patch



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1013544975


##########
boards/arm/stm32/mikroe-stm32f4/src/stm32_touchscreen.c:
##########
@@ -1350,10 +1350,10 @@ static int tc_ioctl(struct file *filep, int cmd, unsigned long arg)
 static int tc_poll(struct file *filep, struct pollfd *fds,
                         bool setup)

Review Comment:
   Done.



##########
boards/mips/pic32mx/pic32mx7mmb/src/pic32_touchscreen.c:
##########
@@ -1227,10 +1227,10 @@ static int tc_ioctl(struct file *filep, int cmd, unsigned long arg)
 static int tc_poll(struct file *filep, struct pollfd *fds,
                         bool setup)

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011152558


##########
arch/arm/src/sama5/sam_dmac.c:
##########
@@ -1471,7 +1459,7 @@ static void sam_freelinklist(struct sam_dmach_s *dmach)
        */
 
       memset(desc, 0, sizeof(struct dma_linklist_s));
-      sam_givedsem(dmac);
+      nxsem_post(&dmac->dsem);

Review Comment:
   move to next patch



##########
arch/arm/src/sama5/sam_ehci.c:
##########
@@ -5020,7 +5020,6 @@ struct usbhost_connection_s *sam_ehci_initialize(int controller)
    *  first port is reset (and enabled)."
    */
 
-  memset(&g_asynchead, 0, sizeof(struct sam_qh_s));

Review Comment:
   move to next patch



##########
arch/arm/src/sama5/sam_ehci.c:
##########
@@ -5044,7 +5043,6 @@ struct usbhost_connection_s *sam_ehci_initialize(int controller)
    * Head (g_intrhead).
    */
 
-  memset(&g_intrhead, 0, sizeof(struct sam_qh_s));

Review Comment:
   move to next patch



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011105975


##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -77,7 +77,6 @@ struct cxd56_spidev_s
   uint8_t          port;        /* Port number */
   int              initialized; /* Initialized flag */
 #ifdef CONFIG_CXD56_DMAC
-  bool             dmaenable;   /* Use DMA or not */
   DMA_HANDLE       rxdmach;     /* RX DMA channel handle */

Review Comment:
   Yes, because txdmach and rxdmach doesn't initialize at runtime anymore, so dmaenable which is used to identify the initialization result doesn't need too.



##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -77,7 +77,6 @@ struct cxd56_spidev_s
   uint8_t          port;        /* Port number */
   int              initialized; /* Initialized flag */
 #ifdef CONFIG_CXD56_DMAC
-  bool             dmaenable;   /* Use DMA or not */
   DMA_HANDLE       rxdmach;     /* RX DMA channel handle */

Review Comment:
   No, because txdmach and rxdmach doesn't initialize at runtime anymore, so dmaenable which is used to identify the initialization result doesn't need too.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011969646


##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -411,15 +399,33 @@ static const struct sam_tcconfig_s g_tc678config =
 /* Timer/counter state */
 
 #ifdef CONFIG_SAMA5_TC0
-static struct sam_tc_s g_tc012;
+static struct sam_tc_s g_tc012 =
+{
+  .lock = NXMUTEX_INITIALIZER,
+  .base = SAM_TC012_VBASE,
+  .pid  = SAM_PID_TC0,
+  .tc   = 0,
+};
 #endif
 
 #ifdef CONFIG_SAMA5_TC1
-static struct sam_tc_s g_tc345;
+static struct sam_tc_s g_tc345 =
+{
+  .lock = NXMUTEX_INITIALIZER,
+  .base = SAM_TC345_VBASE,
+  .pid  = SAM_PID_TC1,
+  .tc   = 1,
+};
 #endif
 
 #ifdef CONFIG_SAMA5_TC2
-static struct sam_tc_s g_tc678;
+static struct sam_tc_s g_tc678 =
+{
+  .lock = NXMUTEX_INITIALIZER,
+  .base = SAM_TC678_VBASE,
+  .pid  = SAM_PID_TC2,
+  .tc   = 2,
+};

Review Comment:
   yes



##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -411,15 +399,33 @@ static const struct sam_tcconfig_s g_tc678config =
 /* Timer/counter state */
 
 #ifdef CONFIG_SAMA5_TC0
-static struct sam_tc_s g_tc012;
+static struct sam_tc_s g_tc012 =
+{
+  .lock = NXMUTEX_INITIALIZER,
+  .base = SAM_TC012_VBASE,
+  .pid  = SAM_PID_TC0,
+  .tc   = 0,
+};
 #endif
 
 #ifdef CONFIG_SAMA5_TC1
-static struct sam_tc_s g_tc345;
+static struct sam_tc_s g_tc345 =
+{
+  .lock = NXMUTEX_INITIALIZER,
+  .base = SAM_TC345_VBASE,
+  .pid  = SAM_PID_TC1,
+  .tc   = 1,
+};

Review Comment:
   yes



##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -411,15 +399,33 @@ static const struct sam_tcconfig_s g_tc678config =
 /* Timer/counter state */
 
 #ifdef CONFIG_SAMA5_TC0
-static struct sam_tc_s g_tc012;
+static struct sam_tc_s g_tc012 =
+{
+  .lock = NXMUTEX_INITIALIZER,
+  .base = SAM_TC012_VBASE,
+  .pid  = SAM_PID_TC0,
+  .tc   = 0,
+};

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011974458


##########
arch/arm/src/sam34/sam_twi.c:
##########
@@ -891,12 +913,7 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
 #ifdef CONFIG_SAM34_TWIM0
   if (bus == 0)
     {
-      /* Set up TWI0 register base address and IRQ number */
-
-      priv       = &g_twi0;
-      priv->base = SAM_TWI0_BASE;
-      priv->irq  = SAM_IRQ_TWI0;
-      priv->twi  = 0;
+      priv = &g_twi0;

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] masayuki2009 merged pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
masayuki2009 merged PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011122178


##########
arch/arm/src/lpc43xx/lpc43_ehci.c:
##########
@@ -5087,7 +5087,6 @@ struct usbhost_connection_s *lpc43_ehci_initialize(int controller)
    *  first port is reset (and enabled)."
    */
 
-  memset(&g_asynchead, 0, sizeof(struct lpc43_qh_s));

Review Comment:
   move to new patch



##########
arch/arm/src/lpc43xx/lpc43_ehci.c:
##########
@@ -5108,7 +5107,6 @@ struct usbhost_connection_s *lpc43_ehci_initialize(int controller)
    * Head (g_intrhead).
    */
 
-  memset(&g_intrhead, 0, sizeof(struct lpc43_qh_s));

Review Comment:
   move to new patch



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011121996


##########
arch/arm/src/lpc17xx_40xx/lpc17_40_usbhost.c:
##########
@@ -3826,11 +3825,9 @@ struct usbhost_connection_s *lpc17_40_usbhost_initialize(int controller)
         LPC17_40_IOBUFFERS * CONFIG_LPC17_40_USBHOST_IOBUFSIZE);
 #endif
 
-  /* Initialize all the TDs, EDs and HCCA to 0 */
-
-  memset((void *)HCCA,   0, sizeof(struct ohci_hcca_s));
-  memset((void *)TDTAIL, 0, sizeof(struct ohci_gtd_s));
-  memset((void *)EDCTRL, 0, sizeof(struct lpc17_40_ed_s));

Review Comment:
   restore



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011144704


##########
arch/arm/src/sam34/sam_twi.c:
##########
@@ -917,12 +934,7 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
 #ifdef CONFIG_SAM34_TWIM1
   if (bus == 1)
     {
-      /* Set up TWI1 register base address and IRQ number */
-
-      priv       = &g_twi1;
-      priv->base = SAM_TWI1_BASE;
-      priv->irq  = SAM_IRQ_TWI1;
-      priv->twi  = 1;
+      priv = &g_twi1;

Review Comment:
   Yes, since the initial value is set at definition place.



##########
arch/arm/src/sam34/sam_twi.c:
##########
@@ -946,15 +958,6 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
       return NULL;
     }
 
-  /* Initialize the device structure */
-
-  priv->dev.ops = &g_twiops;

Review Comment:
   Yes, since the initial value is set at definition place.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011146474


##########
arch/arm/src/sama5/sam_adc.c:
##########
@@ -497,11 +497,20 @@ static const struct adc_ops_s g_adcops =
 
 /* ADC internal state */
 
-static struct sam_adc_s g_adcpriv;
+static struct sam_adc_s g_adcpriv =
+{
+  .lock        = NXMUTEX_INITIALIZER,
+};
 
 /* ADC device instance */
 
-static struct adc_dev_s g_adcdev;
+static struct adc_dev_s g_adcdev =
+{
+#ifdef SAMA5_ADC_HAVE_CHANNELS
+  .ad_ops      = &g_adcops,
+#endif
+  .ad_priv     = &g_adcpriv,
+};

Review Comment:
   Yes, since the initialization is done in the definition



##########
arch/arm/src/sama5/sam_adc.c:
##########
@@ -2041,17 +2050,9 @@ struct adc_dev_s *sam_adc_initialize(void)
       /* Initialize the public ADC device data structure */
 
 #ifdef SAMA5_ADC_HAVE_CHANNELS
-      g_adcdev.ad_ops  = &g_adcops;
       priv->dev = &g_adcdev;
 #endif
 
-      g_adcdev.ad_priv = priv;

Review Comment:
   Yes, since the initialization is done in the definition



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1013545420


##########
drivers/usbhost/usbhost_xboxcontroller.c:
##########
@@ -1901,10 +1901,10 @@ static int usbhost_close(FAR struct file *filep)
 static ssize_t usbhost_read(FAR struct file *filep, FAR char *buffer,
                             size_t len)
 {
-  FAR struct inode                          *inode;
-  FAR struct usbhost_state_s                *priv;
-  FAR struct xbox_controller_buttonstate_s  sample;
-  int                                       ret;
+  FAR struct inode                         *inode;
+  FAR struct usbhost_state_s               *priv;
+  FAR struct xbox_controller_buttonstate_s sample;

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1013546093


##########
arch/arm/src/sam34/sam_twi.c:
##########
@@ -174,7 +174,7 @@ static void twi_startmessage(struct twi_dev_s *priv, struct i2c_msg_s *msg);
 static int twi_transfer(struct i2c_master_s *dev,
           struct i2c_msg_s *msgs, int count);

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011118793


##########
arch/arm/src/kinetis/kinetis_usbhshost.c:
##########
@@ -5406,10 +5400,6 @@ struct usbhost_connection_s *kinetis_ehci_initialize(int controller)
 
   usbhost_vtrace1(EHCI_VTRACE1_INIITIALIZED, 0);
 
-  /* Initialize and return the connection interface */
-
-  g_ehciconn.wait = kinetis_wait;
-  g_ehciconn.enumerate = kinetis_enumerate;

Review Comment:
   move to new patch



##########
arch/arm/src/kinetis/kinetis_usbhshost.c:
##########
@@ -5272,7 +5268,6 @@ struct usbhost_connection_s *kinetis_ehci_initialize(int controller)
    * port is reset (and enabled)."
    */
 
-  memset(&g_asynchead, 0, sizeof(struct kinetis_qh_s));

Review Comment:
   move to new patch



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011117069


##########
arch/arm/src/kinetis/kinetis_edma.c:
##########
@@ -721,18 +707,12 @@ void weak_function arm_dma_initialize(void)
 
   /* Initialize data structures */
 
-  memset(&g_edma, 0, sizeof(struct kinetis_edma_s));

Review Comment:
   Yes, this change avoid the initial sem_t/mutex_t is destroyed by memset.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011965828


##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -323,7 +358,16 @@ static const struct i2c_attr_s g_i2c3attr =
   .base      = SAM_SERCOM3_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c3;
+static struct sam_i2c_dev_s g_i2c3 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c3attr,

Review Comment:
   yes



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -305,7 +331,16 @@ static const struct i2c_attr_s g_i2c2attr =
   .base      = SAM_SERCOM2_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c2;
+static struct sam_i2c_dev_s g_i2c2 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c2attr,

Review Comment:
   yes



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -287,7 +304,16 @@ static const struct i2c_attr_s g_i2c1attr =
   .base      = SAM_SERCOM1_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c1;
+static struct sam_i2c_dev_s g_i2c1 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c1attr,

Review Comment:
   yes



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -270,7 +278,16 @@ static const struct i2c_attr_s g_i2c0attr =
   .base      = SAM_SERCOM0_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c0;
+static struct sam_i2c_dev_s g_i2c0 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c0attr,

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011966134


##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -255,6 +255,14 @@ static void i2c_pad_configure(struct sam_i2c_dev_s *priv);
  * Private Data
  ****************************************************************************/
 
+static const struct i2c_ops_s g_i2cops =
+{
+  .transfer = sam_i2c_transfer,
+#ifdef CONFIG_I2C_RESET
+  .reset = sam_i2c_reset,
+#endif
+};
+

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1017206738


##########
arch/arm/src/stm32f0l0g0/stm32_dma_v1.c:
##########
@@ -100,62 +100,74 @@ static struct stm32_dma_s g_dma[DMA_NCHANNELS] =
   {
     .chan     = 0,
     .irq      = STM32_IRQ_DMA1CH1,
+    .sem      = SEM_INITIALIZER(0),

Review Comment:
   ```suggestion
       .sem      = SEM_INITIALIZER(1),
   ```
   here and in other places in this file



##########
arch/renesas/src/rx65n/rx65n_usbhost.c:
##########
@@ -496,9 +500,9 @@ typedef struct usb_pipe_table
     uint16_t    pipe_peri;
 } usb_pipe_table_t;
 
-usb_pipe_table_t    g_usb_pipe_table [USB_MAX_PIPE_NUM + 1];
+usb_pipe_table_t    g_usb_pipe_table[USB_MAX_PIPE_NUM + 1];

Review Comment:
   ```suggestion
   usb_pipe_table_t g_usb_pipe_table[USB_MAX_PIPE_NUM + 1];
   ```



##########
arch/xtensa/src/esp32s2/esp32s2_i2s.c:
##########
@@ -396,34 +391,16 @@ static struct esp32s2_i2s_s esp32s2_i2s0_priv =
         {
           .ops = &g_i2sops
         },

Review Comment:
   ```suggestion
       {
         .ops = &g_i2sops
       },
   ```



##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -229,6 +229,14 @@ static void twi_hw_initialize(struct twi_dev_s *priv, uint32_t frequency);
  * Private Data
  ****************************************************************************/
 
+static const struct i2c_ops_s g_twiops =
+{
+  .transfer = twi_transfer
+#ifdef CONFIG_I2C_RESET
+  , .reset  = twi_reset

Review Comment:
   ```suggestion
     .transfer = twi_transfer,
   #ifdef CONFIG_I2C_RESET
     .reset  = twi_reset
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011961333


##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -1275,111 +1347,79 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
 #ifdef SAMD5E5_HAVE_I2C0_MASTER
   if (bus == 0)
     {
-      /* Select up I2C0 and setup invariant attributes */
+      /* Select up I2C0 and the (initial) I2C frequency */
 
       priv = &g_i2c0;
-      priv->attr = &g_i2c0attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C0_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C1_MASTER
   if (bus == 1)
     {
-      /* Select up I2C1 and setup invariant attributes */
+      /* Select up I2C1 and the (initial) I2C frequency */
 
       priv = &g_i2c1;
-      priv->attr = &g_i2c1attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C1_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C2_MASTER
   if (bus == 2)
     {
-      /* Select up I2C2 and setup invariant attributes */
+      /* Select up I2C2 and the (initial) I2C frequency */
 
       priv = &g_i2c2;
-      priv->attr = &g_i2c2attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C2_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C3_MASTER
   if (bus == 3)
     {
-      /* Select up I2C3 and setup invariant attributes */
+      /* Select up I2C3 and the (initial) I2C frequency */
 
       priv = &g_i2c3;
-      priv->attr = &g_i2c3attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C3_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C4_MASTER
   if (bus == 4)
     {
-      /* Select up I2C4 and setup invariant attributes */
+      /* Select up I2C4 and the (initial) I2C frequency */
 
       priv = &g_i2c4;
-      priv->attr = &g_i2c4attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C4_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C5_MASTER
   if (bus == 5)
     {
-      /* Select up I2C5 and setup invariant attributes */
+      /* Select up I2C5 and the (initial) I2C frequency */
 
       priv = &g_i2c5;
-      priv->attr = &g_i2c5attr;

Review Comment:
   yes



##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -1275,111 +1347,79 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
 #ifdef SAMD5E5_HAVE_I2C0_MASTER
   if (bus == 0)
     {
-      /* Select up I2C0 and setup invariant attributes */
+      /* Select up I2C0 and the (initial) I2C frequency */
 
       priv = &g_i2c0;
-      priv->attr = &g_i2c0attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C0_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C1_MASTER
   if (bus == 1)
     {
-      /* Select up I2C1 and setup invariant attributes */
+      /* Select up I2C1 and the (initial) I2C frequency */
 
       priv = &g_i2c1;
-      priv->attr = &g_i2c1attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C1_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C2_MASTER
   if (bus == 2)
     {
-      /* Select up I2C2 and setup invariant attributes */
+      /* Select up I2C2 and the (initial) I2C frequency */
 
       priv = &g_i2c2;
-      priv->attr = &g_i2c2attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C2_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C3_MASTER
   if (bus == 3)
     {
-      /* Select up I2C3 and setup invariant attributes */
+      /* Select up I2C3 and the (initial) I2C frequency */
 
       priv = &g_i2c3;
-      priv->attr = &g_i2c3attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C3_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C4_MASTER
   if (bus == 4)
     {
-      /* Select up I2C4 and setup invariant attributes */
+      /* Select up I2C4 and the (initial) I2C frequency */
 
       priv = &g_i2c4;
-      priv->attr = &g_i2c4attr;

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011966979


##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -1177,55 +1213,39 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
 #ifdef CONFIG_SAMA5_TWI0
   if (bus == 0)
     {
-      /* Select up TWI0 and setup invariant attributes */
-
-      priv       = &g_twi0;
-      priv->attr = &g_twi0attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI0 and the (initial) TWI frequency */
 
+      priv      = &g_twi0;

Review Comment:
   yes



##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -282,16 +317,17 @@ static const struct twi_attr_s g_twi3attr =
   .base    = SAM_TWI3_VBASE,
 };
 
-static struct twi_dev_s g_twi3;
-#endif
-
-static const struct i2c_ops_s g_twiops =
+static struct twi_dev_s g_twi3 =
 {
-  .transfer = twi_transfer
-#ifdef CONFIG_I2C_RESET
-  , .reset  = twi_reset
-#endif
+  .dev     =
+  {
+    .ops   = &g_twiops,
+  },
+  .attr    = &g_twi3attr,

Review Comment:
   yes



##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -268,7 +294,16 @@ static const struct twi_attr_s g_twi2attr =
   .base    = SAM_TWI2_VBASE,
 };
 
-static struct twi_dev_s g_twi2;
+static struct twi_dev_s g_twi2 =
+{
+  .dev     =
+  {
+    .ops   = &g_twiops,
+  },
+  .attr    = &g_twi2attr,

Review Comment:
   yes



##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -254,7 +271,16 @@ static const struct twi_attr_s g_twi1attr =
   .base    = SAM_TWI1_VBASE,
 };
 
-static struct twi_dev_s g_twi1;
+static struct twi_dev_s g_twi1 =
+{
+  .dev     =
+  {
+    .ops   = &g_twiops,
+  },
+  .attr    = &g_twi1attr,

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011125332


##########
arch/arm/src/s32k1xx/s32k1xx_edma.c:
##########
@@ -706,18 +692,12 @@ void weak_function arm_dma_initialize(void)
 
   /* Initialize data structures */
 
-  memset(&g_edma, 0, sizeof(struct s32k1xx_edma_s));

Review Comment:
   Yes, relate



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] masayuki2009 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1010159691


##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -1248,15 +1268,6 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
       goto errout_with_lock;
     }
 
-  /* Initialize the TWI driver structure */
-
-  priv->dev.ops = &g_twiops;

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_xdmac.c:
##########
@@ -732,24 +738,6 @@ static struct sam_xdmac_s g_xdmac1 =
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: sam_takedsem() and sam_givedsem()
- *
- * Description:
- *   Used to wait for availability of descriptors in the descriptor table.
- *
- ****************************************************************************/
-
-static int sam_takedsem(struct sam_xdmac_s *xdmac)
-{
-  return nxsem_wait_uninterruptible(&xdmac->dsem);
-}
-
-static inline void sam_givedsem(struct sam_xdmac_s *xdmac)
-{
-  nxsem_post(&xdmac->dsem);
-}
-

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/samd2l2/sam_dmac.c:
##########
@@ -158,26 +154,6 @@ static struct dma_desc_s g_dma_desc[CONFIG_SAMD2L2_DMAC_NDESC]
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: sam_takedsem() and sam_givedsem()
- *
- * Description:
- *   Used to wait for availability of descriptors in the descriptor table.
- *
- ****************************************************************************/
-
-#if CONFIG_SAMD2L2_DMAC_NDESC > 0
-static void sam_takedsem(void)
-{
-  nxsem_wait_uninterruptible(&g_dsem);
-}
-
-static inline void sam_givedsem(void)
-{
-  nxsem_post(&g_dsem);
-}
-#endif
-

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_xdmac.c:
##########
@@ -1407,7 +1395,7 @@ sam_allocdesc(struct sam_xdmach_s *xdmach, struct chnext_view1_s *prev,
       ret = nxmutex_lock(&xdmac->chlock);
       if (ret < 0)
         {
-          sam_givedsem(xdmac);
+          nxsem_post(&xdmac->dsem);

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?



##########
arch/arm/src/sama5/sam_xdmac.c:
##########
@@ -1392,7 +1380,7 @@ sam_allocdesc(struct sam_xdmach_s *xdmach, struct chnext_view1_s *prev,
        * there is at least one free descriptor in the table and it is ours.
        */
 
-      ret = sam_takedsem(xdmac);
+      ret = nxsem_wait_uninterruptible(&xdmac->dsem);

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?



##########
arch/arm/src/samd2l2/sam_dmac.c:
##########
@@ -99,10 +99,6 @@ struct sam_dmach_s
  * Private Function Prototypes
  ****************************************************************************/
 
-#if CONFIG_SAMD2L2_DMAC_NDESC > 0
-static void   sam_takedsem(void);
-static inline void sam_givedsem(void);
-#endif

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/samd2l2/sam_dmac.c:
##########
@@ -512,7 +488,7 @@ static void sam_free_desc(struct sam_dmach_s *dmach)
 
       next = (struct dma_desc_s *)desc->descaddr;
       memset(desc, 0, sizeof(struct dma_desc_s));
-      sam_givedsem();
+      nxsem_post(&g_dsem);

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -287,7 +304,16 @@ static const struct i2c_attr_s g_i2c1attr =
   .base      = SAM_SERCOM1_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c1;
+static struct sam_i2c_dev_s g_i2c1 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c1attr,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the mutex/sem initialization?
   



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -323,7 +358,16 @@ static const struct i2c_attr_s g_i2c3attr =
   .base      = SAM_SERCOM3_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c3;
+static struct sam_i2c_dev_s g_i2c3 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c3attr,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the mutex/sem initialization?



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -305,7 +331,16 @@ static const struct i2c_attr_s g_i2c2attr =
   .base      = SAM_SERCOM2_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c2;
+static struct sam_i2c_dev_s g_i2c2 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c2attr,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the mutex/sem initialization?



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -255,6 +255,14 @@ static void i2c_pad_configure(struct sam_i2c_dev_s *priv);
  * Private Data
  ****************************************************************************/
 
+static const struct i2c_ops_s g_i2cops =
+{
+  .transfer = sam_i2c_transfer,
+#ifdef CONFIG_I2C_RESET
+  .reset = sam_i2c_reset,
+#endif
+};
+

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -270,7 +278,16 @@ static const struct i2c_attr_s g_i2c0attr =
   .base      = SAM_SERCOM0_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c0;
+static struct sam_i2c_dev_s g_i2c0 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c0attr,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the mutex/sem initialization?
   



##########
arch/arm/src/samd2l2/sam_dmac.c:
##########
@@ -356,7 +332,7 @@ static struct dma_desc_s *sam_alloc_desc(struct sam_dmach_s *dmach)
        * it is ours.
        */
 
-      sam_takedsem();
+      nxsem_wait_uninterruptible(&g_dsem);

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -359,16 +412,17 @@ static const struct i2c_attr_s g_i2c5attr =
   .base      = SAM_SERCOM5_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c5;
-#endif
-
-struct i2c_ops_s g_i2cops =
+static struct sam_i2c_dev_s g_i2c5 =
 {
-  .transfer = sam_i2c_transfer,
-#ifdef CONFIG_I2C_RESET
-  .reset = sam_i2c_reset,
-#endif
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c5attr,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the mutex/sem initialization?
   



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -1253,83 +1307,59 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
 #ifdef SAMD2L2_HAVE_I2C0
   if (bus == 0)
     {
-      /* Select up I2C0 and setup invariant attributes */
+      /* Select up I2C0 and the (initial) I2C frequency */
 
       priv = &g_i2c0;
-      priv->attr = &g_i2c0attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C0_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C1
   if (bus == 1)
     {
-      /* Select up I2C1 and setup invariant attributes */
+      /* Select up I2C1 and the (initial) I2C frequency */
 
       priv = &g_i2c1;
-      priv->attr = &g_i2c1attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C1_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C2
   if (bus == 2)
     {
-      /* Select up I2C2 and setup invariant attributes */
+      /* Select up I2C2 and the (initial) I2C frequency */
 
       priv = &g_i2c2;
-      priv->attr = &g_i2c2attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C2_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C3
   if (bus == 3)
     {
-      /* Select up I2C3 and setup invariant attributes */
+      /* Select up I2C3 and the (initial) I2C frequency */
 
       priv = &g_i2c3;
-      priv->attr = &g_i2c3attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C3_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C4
   if (bus == 4)
     {
-      /* Select up I2C4 and setup invariant attributes */
+      /* Select up I2C4 and the (initial) I2C frequency */
 
       priv = &g_i2c4;
-      priv->attr = &g_i2c4attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C4_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C5
   if (bus == 5)
     {
-      /* Select up I2C5 and setup invariant attributes */
+      /* Select up I2C5 and the (initial) I2C frequency */
 
       priv = &g_i2c5;
-      priv->attr = &g_i2c5attr;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -341,7 +385,16 @@ static const struct i2c_attr_s g_i2c4attr =
   .base      = SAM_SERCOM4_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c4;
+static struct sam_i2c_dev_s g_i2c4 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c4attr,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the mutex/sem initialization?
   



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -1353,14 +1383,6 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
       return NULL;
     }
 
-  /* Initialize the I2C driver structure */
-
-  priv->dev.ops = &g_i2cops;
-  priv->flags = 0;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -1253,83 +1307,59 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
 #ifdef SAMD2L2_HAVE_I2C0
   if (bus == 0)
     {
-      /* Select up I2C0 and setup invariant attributes */
+      /* Select up I2C0 and the (initial) I2C frequency */
 
       priv = &g_i2c0;
-      priv->attr = &g_i2c0attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C0_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C1
   if (bus == 1)
     {
-      /* Select up I2C1 and setup invariant attributes */
+      /* Select up I2C1 and the (initial) I2C frequency */
 
       priv = &g_i2c1;
-      priv->attr = &g_i2c1attr;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?



##########
arch/arm/src/samd5e5/sam_dmac.c:
##########
@@ -157,26 +153,6 @@ static struct dma_desc_s g_dma_desc[CONFIG_SAMD5E5_DMAC_NDESC]
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: sam_takedsem() and sam_givedsem()
- *
- * Description:
- *   Used to wait for availability of descriptors in the descriptor table.
- *
- ****************************************************************************/
-
-#if CONFIG_SAMD5E5_DMAC_NDESC > 0
-static void sam_takedsem(void)
-{
-  nxsem_wait_uninterruptible(&g_dsem);
-}
-
-static inline void sam_givedsem(void)
-{
-  nxsem_post(&g_dsem);
-}
-#endif

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -1253,83 +1307,59 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
 #ifdef SAMD2L2_HAVE_I2C0
   if (bus == 0)
     {
-      /* Select up I2C0 and setup invariant attributes */
+      /* Select up I2C0 and the (initial) I2C frequency */
 
       priv = &g_i2c0;
-      priv->attr = &g_i2c0attr;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -1253,83 +1307,59 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
 #ifdef SAMD2L2_HAVE_I2C0
   if (bus == 0)
     {
-      /* Select up I2C0 and setup invariant attributes */
+      /* Select up I2C0 and the (initial) I2C frequency */
 
       priv = &g_i2c0;
-      priv->attr = &g_i2c0attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C0_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C1
   if (bus == 1)
     {
-      /* Select up I2C1 and setup invariant attributes */
+      /* Select up I2C1 and the (initial) I2C frequency */
 
       priv = &g_i2c1;
-      priv->attr = &g_i2c1attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C1_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C2
   if (bus == 2)
     {
-      /* Select up I2C2 and setup invariant attributes */
+      /* Select up I2C2 and the (initial) I2C frequency */
 
       priv = &g_i2c2;
-      priv->attr = &g_i2c2attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C2_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C3
   if (bus == 3)
     {
-      /* Select up I2C3 and setup invariant attributes */
+      /* Select up I2C3 and the (initial) I2C frequency */
 
       priv = &g_i2c3;
-      priv->attr = &g_i2c3attr;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -243,6 +243,14 @@ static void i2c_pad_configure(struct sam_i2c_dev_s *priv);
  * Private Data
  ****************************************************************************/
 
+static static struct i2c_ops_s g_i2cops =
+{
+  .transfer = sam_i2c_transfer,
+#ifdef CONFIG_I2C_RESET
+  .reset = sam_i2c_reset,
+#endif
+};
+

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?



##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -276,7 +293,16 @@ static const struct i2c_attr_s g_i2c1attr =
   .base      = SAM_SERCOM1_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c1;
+static struct sam_i2c_dev_s g_i2c1 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c1attr,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -1253,83 +1307,59 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
 #ifdef SAMD2L2_HAVE_I2C0
   if (bus == 0)
     {
-      /* Select up I2C0 and setup invariant attributes */
+      /* Select up I2C0 and the (initial) I2C frequency */
 
       priv = &g_i2c0;
-      priv->attr = &g_i2c0attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C0_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C1
   if (bus == 1)
     {
-      /* Select up I2C1 and setup invariant attributes */
+      /* Select up I2C1 and the (initial) I2C frequency */
 
       priv = &g_i2c1;
-      priv->attr = &g_i2c1attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C1_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C2
   if (bus == 2)
     {
-      /* Select up I2C2 and setup invariant attributes */
+      /* Select up I2C2 and the (initial) I2C frequency */
 
       priv = &g_i2c2;
-      priv->attr = &g_i2c2attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C2_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C3
   if (bus == 3)
     {
-      /* Select up I2C3 and setup invariant attributes */
+      /* Select up I2C3 and the (initial) I2C frequency */
 
       priv = &g_i2c3;
-      priv->attr = &g_i2c3attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C3_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C4
   if (bus == 4)
     {
-      /* Select up I2C4 and setup invariant attributes */
+      /* Select up I2C4 and the (initial) I2C frequency */
 
       priv = &g_i2c4;
-      priv->attr = &g_i2c4attr;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/samd5e5/sam_dmac.c:
##########
@@ -328,7 +304,7 @@ static struct dma_desc_s *sam_alloc_desc(struct sam_dmach_s *dmach)
        * it is ours.
        */
 
-      sam_takedsem();
+      nxsem_wait_uninterruptible(&g_dsem);

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?



##########
arch/arm/src/samd5e5/sam_dmac.c:
##########
@@ -100,10 +100,6 @@ struct sam_dmach_s
  * Private Function Prototypes
  ****************************************************************************/
 
-#if CONFIG_SAMD5E5_DMAC_NDESC > 0
-static void   sam_takedsem(void);
-static inline void sam_givedsem(void);
-#endif

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -258,7 +266,16 @@ static const struct i2c_attr_s g_i2c0attr =
   .base      = SAM_SERCOM0_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c0;
+static struct sam_i2c_dev_s g_i2c0 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c0attr,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?



##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -312,7 +347,16 @@ static const struct i2c_attr_s g_i2c3attr =
   .base      = SAM_SERCOM3_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c3;
+static struct sam_i2c_dev_s g_i2c3 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c3attr,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?



##########
arch/arm/src/samd5e5/sam_dmac.c:
##########
@@ -484,7 +460,7 @@ static void sam_free_desc(struct sam_dmach_s *dmach)
 
       next = (struct dma_desc_s *)desc->descaddr;
       memset(desc, 0, sizeof(struct dma_desc_s));
-      sam_givedsem();
+      nxsem_post(&g_dsem);

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?



##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -294,7 +320,16 @@ static const struct i2c_attr_s g_i2c2attr =
   .base      = SAM_SERCOM2_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c2;
+static struct sam_i2c_dev_s g_i2c2 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c2attr,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?



##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -330,7 +374,16 @@ static const struct i2c_attr_s g_i2c4attr =
   .base      = SAM_SERCOM4_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c4;
+static struct sam_i2c_dev_s g_i2c4 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c4attr,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011119132


##########
arch/arm/src/kinetis/kinetis_usbhshost.c:
##########
@@ -5295,7 +5290,6 @@ struct usbhost_connection_s *kinetis_ehci_initialize(int controller)
    * to point to the Interrupt Queue Head (g_intrhead).
    */
 
-  memset(&g_intrhead, 0, sizeof(struct kinetis_qh_s));

Review Comment:
   move to new patch



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011127817


##########
arch/arm/src/s32k3xx/s32k3xx_edma.c:
##########
@@ -459,7 +445,7 @@ static struct s32k3xx_edmatcd_s *s32k3xx_tcd_alloc(void)
    */
 
   flags = enter_critical_section();
-  s32k3xx_takedsem();
+  nxsem_wait_uninterruptible(&g_edma.dsem);

Review Comment:
   move to new patch



##########
arch/arm/src/s32k3xx/s32k3xx_edma.c:
##########
@@ -416,26 +422,6 @@ const struct peripheral_clock_config_s edma_clockconfig[] =
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: s32k3xx_takedsem() and s32k3xx_givedsem()
- *
- * Description:
- *   Used to wait for availability of descriptors in the descriptor table.
- *
- ****************************************************************************/
-
-#if CONFIG_S32K3XX_EDMA_NTCD > 0
-static void s32k3xx_takedsem(void)
-{
-  nxsem_wait_uninterruptible(&g_edma.dsem);
-}
-
-static inline void s32k3xx_givedsem(void)
-{
-  nxsem_post(&g_edma.dsem);
-}
-#endif
-

Review Comment:
   move to new patch



##########
arch/arm/src/s32k3xx/s32k3xx_edma.c:
##########
@@ -491,7 +477,7 @@ static void s32k3xx_tcd_free(struct s32k3xx_edmatcd_s *tcd)
 
   flags = spin_lock_irqsave(NULL);
   sq_addlast((sq_entry_t *)tcd, &g_tcd_free);
-  s32k3xx_givedsem();
+  nxsem_post(&g_edma.dsem);

Review Comment:
   move to new patch



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] gustavonihei commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1013425999


##########
arch/xtensa/src/esp32s2/esp32s2_spi.c:
##########
@@ -1432,8 +1432,6 @@ static void esp32s2_spi_init(struct spi_dev_s *dev)
 
 #if defined(CONFIG_ESP32S2_SPI2_DMA) || defined(CONFIG_ESP32S2_SPI3_DMA)
   nxsem_init(&priv->sem_isr, 0, 0);

Review Comment:
   Shouldn't this be removed?
   ```suggestion
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1013548253


##########
crypto/random_pool.c:
##########
@@ -89,7 +89,10 @@ enum
  * Private Data
  ****************************************************************************/
 
-static struct rng_s g_rng;
+static struct rng_s g_rng =
+{
+  .rd_lock = NXMUTEX_INITIALIZER,

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1018612614


##########
arch/renesas/src/rx65n/rx65n_usbhost.c:
##########
@@ -3001,14 +3003,14 @@ uint16_t usb_hstd_get_pipe_peri_value (uint8_t binterval)
       work2 = 0;
       for (; work1 != 0; work2++ )
         {
-                  work1 = (uint16_t)(work1 >> 1);
+                  work1 >>= 1;

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011163335


##########
arch/arm/src/sama5/sam_hsmci.c:
##########
@@ -3271,11 +3349,6 @@ struct sdio_dev_s *sdio_initialize(int slotno)
 
       priv = &g_hsmci2;
 
-      /* HSMCI2 Initialization */
-
-      priv->base  = SAM_HSMCI2_VBASE;
-      priv->hsmci = 2;

Review Comment:
   Yes, it's better to use the same method to initialize all field



##########
arch/arm/src/sama5/sam_hsmci.c:
##########
@@ -3312,16 +3385,6 @@ struct sdio_dev_s *sdio_initialize(int slotno)
          " hsmci: %d dmac: %d pid: %" PRId32 "\n",
          priv, priv->base, priv->hsmci, dmac, pid);
 
-  /* Initialize the HSMCI slot structure */
-
-  /* Initialize semaphores */
-
-  nxsem_init(&priv->waitsem, 0, 0);
-
-  /* Initialize the callbacks */
-
-  memcpy(&priv->dev, &g_callbacks, sizeof(struct sdio_dev_s));

Review Comment:
   Yes, it's better to use the same method to initialize all field



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011162928


##########
arch/arm/src/sama5/sam_ehci.c:
##########
@@ -435,11 +435,20 @@ static int sam_reset(void);
  * global instance.
  */
 
-static struct sam_ehci_s g_ehci;
+static struct sam_ehci_s g_ehci =
+{
+  .lock = NXMUTEX_INITIALIZER,
+  .pscsem = SEM_INITIALIZER(0),
+  .ep0.iocsem = SEM_INITIALIZER(1),
+};
 
 /* This is the connection/enumeration interface */
 
-static struct usbhost_connection_s g_ehciconn;
+static struct usbhost_connection_s g_ehciconn =
+{
+  .wait = sam_wait,
+  .enumerate = sam_enumerate,
+};

Review Comment:
   move to next patch



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011122542


##########
arch/arm/src/lpc43xx/lpc43_ehci.c:
##########
@@ -5240,10 +5238,6 @@ struct usbhost_connection_s *lpc43_ehci_initialize(int controller)
   up_enable_irq(LPC43M4_IRQ_USB0); /* enable USB interrupt */
   usbhost_vtrace1(EHCI_VTRACE1_INIITIALIZED, 0);
 
-  /* Initialize and return the connection interface */
-
-  g_ehciconn.wait      = lpc43_wait;
-  g_ehciconn.enumerate = lpc43_enumerate;

Review Comment:
   move to new patch



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011966630


##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -1248,15 +1268,6 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
       goto errout_with_lock;
     }
 
-  /* Initialize the TWI driver structure */
-
-  priv->dev.ops = &g_twiops;

Review Comment:
   yes



##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -1177,55 +1213,39 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
 #ifdef CONFIG_SAMA5_TWI0
   if (bus == 0)
     {
-      /* Select up TWI0 and setup invariant attributes */
-
-      priv       = &g_twi0;
-      priv->attr = &g_twi0attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI0 and the (initial) TWI frequency */
 
+      priv      = &g_twi0;
       frequency = CONFIG_SAMA5_TWI0_FREQUENCY;
     }
   else
 #endif
 #ifdef CONFIG_SAMA5_TWI1
   if (bus == 1)
     {
-      /* Select up TWI1 and setup invariant attributes */
-
-      priv       = &g_twi1;
-      priv->attr = &g_twi1attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI1 and the (initial) TWI frequency */
 
+      priv      = &g_twi1;
       frequency = CONFIG_SAMA5_TWI1_FREQUENCY;
     }
   else
 #endif
 #ifdef CONFIG_SAMA5_TWI2
   if (bus == 2)
     {
-      /* Select up TWI2 and setup invariant attributes */
-
-      priv       = &g_twi2;
-      priv->attr = &g_twi2attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI2 and the (initial) TWI frequency */
 
+      priv      = &g_twi2;
       frequency = CONFIG_SAMA5_TWI2_FREQUENCY;
     }
   else
 #endif
 #ifdef CONFIG_SAMA5_TWI3
   if (bus == 3)
     {
-      /* Select up TWI3 and setup invariant attributes */
-
-      priv       = &g_twi3;
-      priv->attr = &g_twi3attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI3 and the (initial) TWI frequency */
 
+      priv      = &g_twi3;

Review Comment:
   yes



##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -1177,55 +1213,39 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
 #ifdef CONFIG_SAMA5_TWI0
   if (bus == 0)
     {
-      /* Select up TWI0 and setup invariant attributes */
-
-      priv       = &g_twi0;
-      priv->attr = &g_twi0attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI0 and the (initial) TWI frequency */
 
+      priv      = &g_twi0;
       frequency = CONFIG_SAMA5_TWI0_FREQUENCY;
     }
   else
 #endif
 #ifdef CONFIG_SAMA5_TWI1
   if (bus == 1)
     {
-      /* Select up TWI1 and setup invariant attributes */
-
-      priv       = &g_twi1;
-      priv->attr = &g_twi1attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI1 and the (initial) TWI frequency */
 
+      priv      = &g_twi1;
       frequency = CONFIG_SAMA5_TWI1_FREQUENCY;
     }
   else
 #endif
 #ifdef CONFIG_SAMA5_TWI2
   if (bus == 2)
     {
-      /* Select up TWI2 and setup invariant attributes */
-
-      priv       = &g_twi2;
-      priv->attr = &g_twi2attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI2 and the (initial) TWI frequency */
 
+      priv      = &g_twi2;

Review Comment:
   yes



##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -1177,55 +1213,39 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
 #ifdef CONFIG_SAMA5_TWI0
   if (bus == 0)
     {
-      /* Select up TWI0 and setup invariant attributes */
-
-      priv       = &g_twi0;
-      priv->attr = &g_twi0attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI0 and the (initial) TWI frequency */
 
+      priv      = &g_twi0;
       frequency = CONFIG_SAMA5_TWI0_FREQUENCY;
     }
   else
 #endif
 #ifdef CONFIG_SAMA5_TWI1
   if (bus == 1)
     {
-      /* Select up TWI1 and setup invariant attributes */
-
-      priv       = &g_twi1;
-      priv->attr = &g_twi1attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI1 and the (initial) TWI frequency */
 
+      priv      = &g_twi1;

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011122729


##########
arch/arm/src/nrf52/nrf52_radio.c:
##########
@@ -1149,22 +1151,11 @@ nrf52_radio_initialize(int intf, struct nrf52_radio_board_s *board)
         }
     }
 
-  /* Reset some data */
-
-  memset(&dev->pktcfg, 0, sizeof(struct nrf52_radio_pktcfg_s));
-  memset(dev->rxbuf, 0, NRF52_RADIO_RXBUFFER);
-  memset(dev->txbuf, 0, NRF52_RADIO_TXBUFFER);

Review Comment:
   move to new patch



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011149329


##########
arch/arm/src/sama5/sam_can.c:
##########
@@ -287,8 +287,17 @@ static const struct sam_config_s g_can0const =
   },
 };
 
-static struct sam_can_s g_can0priv;
-static struct can_dev_s g_can0dev;
+static struct sam_can_s g_can0priv =
+{
+  .config           = &g_can0const,
+  .freemb           = CAN_ALL_MAILBOXES,
+  .lock             = NXMUTEX_INITIALIZER,
+};
+static struct can_dev_s g_can0dev =
+{
+  .cd_ops           = &g_canops,
+  .cd_priv          = &g_can0priv,
+};

Review Comment:
   Yes, since all field initialization in the same(definition) place



##########
arch/arm/src/sama5/sam_can.c:
##########
@@ -287,8 +287,17 @@ static const struct sam_config_s g_can0const =
   },
 };
 
-static struct sam_can_s g_can0priv;
-static struct can_dev_s g_can0dev;
+static struct sam_can_s g_can0priv =
+{
+  .config           = &g_can0const,
+  .freemb           = CAN_ALL_MAILBOXES,
+  .lock             = NXMUTEX_INITIALIZER,
+};
+static struct can_dev_s g_can0dev =
+{
+  .cd_ops           = &g_canops,
+  .cd_priv          = &g_can0priv,
+};

Review Comment:
   Yes, since all field initialization in the same(definition) place



##########
arch/arm/src/sama5/sam_can.c:
##########
@@ -322,8 +331,17 @@ static const struct sam_config_s g_can1const =
   },
 };
 
-static struct sam_can_s g_can1priv;
-static struct can_dev_s g_can1dev;
+static struct sam_can_s g_can1priv =
+{
+  .config           = &g_can1const,
+  .freemb           = CAN_ALL_MAILBOXES,
+  .lock             = NXMUTEX_INITIALIZER,
+};
+static struct can_dev_s g_can1dev =
+{
+  .cd_ops           = &g_canops,
+  .cd_priv          = &g_can1priv,
+};

Review Comment:
   Yes, since all field initialization in the same(definition) place



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#issuecomment-1302697931

   @gustavonihei could you please review ESP32 related files?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1017455522


##########
arch/xtensa/src/esp32s2/esp32s2_i2s.c:
##########
@@ -396,34 +391,16 @@ static struct esp32s2_i2s_s esp32s2_i2s0_priv =
         {
           .ops = &g_i2sops
         },

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011962166


##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -1275,111 +1347,79 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
 #ifdef SAMD5E5_HAVE_I2C0_MASTER
   if (bus == 0)
     {
-      /* Select up I2C0 and setup invariant attributes */
+      /* Select up I2C0 and the (initial) I2C frequency */
 
       priv = &g_i2c0;
-      priv->attr = &g_i2c0attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C0_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C1_MASTER
   if (bus == 1)
     {
-      /* Select up I2C1 and setup invariant attributes */
+      /* Select up I2C1 and the (initial) I2C frequency */
 
       priv = &g_i2c1;
-      priv->attr = &g_i2c1attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C1_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C2_MASTER
   if (bus == 2)
     {
-      /* Select up I2C2 and setup invariant attributes */
+      /* Select up I2C2 and the (initial) I2C frequency */
 
       priv = &g_i2c2;
-      priv->attr = &g_i2c2attr;

Review Comment:
   yes



##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -1275,111 +1347,79 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
 #ifdef SAMD5E5_HAVE_I2C0_MASTER
   if (bus == 0)
     {
-      /* Select up I2C0 and setup invariant attributes */
+      /* Select up I2C0 and the (initial) I2C frequency */
 
       priv = &g_i2c0;
-      priv->attr = &g_i2c0attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C0_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C1_MASTER
   if (bus == 1)
     {
-      /* Select up I2C1 and setup invariant attributes */
+      /* Select up I2C1 and the (initial) I2C frequency */
 
       priv = &g_i2c1;
-      priv->attr = &g_i2c1attr;

Review Comment:
   yes



##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -1275,111 +1347,79 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
 #ifdef SAMD5E5_HAVE_I2C0_MASTER
   if (bus == 0)
     {
-      /* Select up I2C0 and setup invariant attributes */
+      /* Select up I2C0 and the (initial) I2C frequency */
 
       priv = &g_i2c0;
-      priv->attr = &g_i2c0attr;

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011962768


##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -384,16 +455,17 @@ static const struct i2c_attr_s g_i2c7attr =
   .base      = SAM_SERCOM7_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c7;
-#endif
-
-struct i2c_ops_s g_i2cops =
+static struct sam_i2c_dev_s g_i2c7 =
 {
-  .transfer = sam_i2c_transfer,
-#ifdef CONFIG_I2C_RESET
-  .reset = sam_i2c_reset,
-#endif
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c7attr,

Review Comment:
   yes



##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -366,7 +428,16 @@ static const struct i2c_attr_s g_i2c6attr =
   .base      = SAM_SERCOM6_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c6;
+static struct sam_i2c_dev_s g_i2c6 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c6attr,

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011964822


##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -243,6 +243,14 @@ static void i2c_pad_configure(struct sam_i2c_dev_s *priv);
  * Private Data
  ****************************************************************************/
 
+static static struct i2c_ops_s g_i2cops =
+{
+  .transfer = sam_i2c_transfer,
+#ifdef CONFIG_I2C_RESET
+  .reset = sam_i2c_reset,
+#endif
+};
+

Review Comment:
   Yes



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -1353,14 +1383,6 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
       return NULL;
     }
 
-  /* Initialize the I2C driver structure */
-
-  priv->dev.ops = &g_i2cops;
-  priv->flags = 0;

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011099572


##########
arch/arm/src/cxd56xx/cxd56_hostif.c:
##########
@@ -379,8 +382,6 @@ static int hif_initialize(struct hostif_buff_s *buffer)
 
   DEBUGASSERT(buffer);
 
-  memset(drv, 0, sizeof(struct cxd56_hifdrv_s));
-

Review Comment:
   No, it's relate because memset will destroy the initial value at the definition place.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011149572


##########
arch/arm/src/sama5/sam_can.c:
##########
@@ -1943,16 +1958,8 @@ struct can_dev_s *sam_caninitialize(int port)
     {
       /* Yes, then perform one time data initialization */
 
-      memset(priv, 0, sizeof(struct sam_can_s));
-      priv->config      = config;
-      priv->freemb      = CAN_ALL_MAILBOXES;

Review Comment:
   Yes, since all field initialization in the same(definition) place



##########
arch/arm/src/sama5/sam_can.c:
##########
@@ -1943,16 +1958,8 @@ struct can_dev_s *sam_caninitialize(int port)
     {
       /* Yes, then perform one time data initialization */
 
-      memset(priv, 0, sizeof(struct sam_can_s));
-      priv->config      = config;
-      priv->freemb      = CAN_ALL_MAILBOXES;
       priv->initialized = true;
 
-      nxmutex_init(&priv->lock);
-
-      dev->cd_ops       = &g_canops;
-      dev->cd_priv      = (void *)priv;

Review Comment:
   Yes, since all field initialization in the same(definition) place



##########
arch/arm/src/sama5/sam_dmac.c:
##########
@@ -463,24 +469,6 @@ static struct sam_dmac_s g_dmac1 =
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: sam_takedsem() and sam_givedsem()
- *
- * Description:
- *   Used to wait for availability of descriptors in the descriptor table.
- *
- ****************************************************************************/
-
-static int sam_takedsem(struct sam_dmac_s *dmac)
-{
-  return nxsem_wait_uninterruptible(&dmac->dsem);
-}
-
-static inline void sam_givedsem(struct sam_dmac_s *dmac)
-{
-  nxsem_post(&dmac->dsem);
-}
-

Review Comment:
   move to next patch



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011163715


##########
arch/arm/src/sama5/sam_ohci.c:
##########
@@ -4202,10 +4201,6 @@ struct usbhost_connection_s *sam_ohci_initialize(int controller)
 
   usbhost_vtrace1(OHCI_VTRACE1_INITIALIZED, 0);
 
-  /* Initialize and return the connection interface */
-
-  g_ohciconn.wait      = sam_wait;
-  g_ohciconn.enumerate = sam_enumerate;

Review Comment:
   next patch



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011122056


##########
arch/arm/src/lpc31xx/lpc31_ehci.c:
##########
@@ -5279,7 +5279,6 @@ struct usbhost_connection_s *lpc31_ehci_initialize(int controller)
    *  first port is reset (and enabled)."
    */
 
-  memset(&g_asynchead, 0, sizeof(struct lpc31_qh_s));

Review Comment:
   move to new patch



##########
arch/arm/src/lpc31xx/lpc31_ehci.c:
##########
@@ -5303,7 +5302,6 @@ struct usbhost_connection_s *lpc31_ehci_initialize(int controller)
    * Head (g_intrhead).
    */
 
-  memset(&g_intrhead, 0, sizeof(struct lpc31_qh_s));

Review Comment:
   move to new patch



##########
arch/arm/src/lpc31xx/lpc31_ehci.c:
##########
@@ -5440,10 +5438,6 @@ struct usbhost_connection_s *lpc31_ehci_initialize(int controller)
   up_enable_irq(LPC31_IRQ_USBOTG); /* enable USB interrupt */
   usbhost_vtrace1(EHCI_VTRACE1_INIITIALIZED, 0);
 
-  /* Initialize and return the connection interface */
-
-  g_ehciconn.wait      = lpc31_wait;
-  g_ehciconn.enumerate = lpc31_enumerate;

Review Comment:
   move to new patch



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011967771


##########
arch/arm/src/sama5/sam_tsd.c:
##########
@@ -245,7 +245,12 @@ static const struct file_operations g_tsdops =
 
 /* The driver state structure is pre-allocated. */
 
-static struct sam_tsd_s g_tsd;
+static struct sam_tsd_s g_tsd =
+{
+  .threshx = INVALID_THRESHOLD,
+  .threshy = INVALID_THRESHOLD,
+  .waitsem = SEM_INITIALIZER(0),

Review Comment:
   yes



##########
arch/arm/src/sama5/sam_tsd.c:
##########
@@ -1650,11 +1655,7 @@ int sam_tsd_register(struct sam_adc_s *adc, int minor)
 
   /* Initialize the touchscreen device driver instance */
 
-  memset(priv, 0, sizeof(struct sam_tsd_s));
-  priv->adc     = adc;               /* Save the ADC device handle */
-  priv->threshx = INVALID_THRESHOLD; /* Initialize thresholding logic */
-  priv->threshy = INVALID_THRESHOLD; /* Initialize thresholding logic */

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1016100505


##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -1204,7 +1217,6 @@ struct spi_dev_s *cxd56_spibus_initialize(int port)
   /* DMA settings */
 
 #ifdef CONFIG_CXD56_DMAC
-  priv->dmaenable = false;

Review Comment:
   Yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1017455022


##########
arch/arm/src/stm32f0l0g0/stm32_dma_v1.c:
##########
@@ -100,62 +100,74 @@ static struct stm32_dma_s g_dma[DMA_NCHANNELS] =
   {
     .chan     = 0,
     .irq      = STM32_IRQ_DMA1CH1,
+    .sem      = SEM_INITIALIZER(0),

Review Comment:
   Done.



##########
arch/renesas/src/rx65n/rx65n_usbhost.c:
##########
@@ -496,9 +500,9 @@ typedef struct usb_pipe_table
     uint16_t    pipe_peri;
 } usb_pipe_table_t;
 
-usb_pipe_table_t    g_usb_pipe_table [USB_MAX_PIPE_NUM + 1];
+usb_pipe_table_t    g_usb_pipe_table[USB_MAX_PIPE_NUM + 1];

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011124101


##########
arch/arm/src/nrf52/nrf52_rng.c:
##########
@@ -124,13 +128,6 @@ static int nrf52_rng_initialize(void)
 
   first_flag = false;
 
-  _info("Initializing RNG\n");
-
-  memset(&g_rngdev, 0, sizeof(struct rng_dev_s));

Review Comment:
   Yes, the change avoid memset destroy the initial value.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011960995


##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -1411,14 +1451,6 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
       return NULL;
     }
 
-  /* Initialize the I2C driver structure */
-
-  priv->dev.ops = &g_i2cops;
-  priv->flags = 0;

Review Comment:
   Yes



##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -1275,111 +1347,79 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
 #ifdef SAMD5E5_HAVE_I2C0_MASTER
   if (bus == 0)
     {
-      /* Select up I2C0 and setup invariant attributes */
+      /* Select up I2C0 and the (initial) I2C frequency */
 
       priv = &g_i2c0;
-      priv->attr = &g_i2c0attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C0_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C1_MASTER
   if (bus == 1)
     {
-      /* Select up I2C1 and setup invariant attributes */
+      /* Select up I2C1 and the (initial) I2C frequency */
 
       priv = &g_i2c1;
-      priv->attr = &g_i2c1attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C1_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C2_MASTER
   if (bus == 2)
     {
-      /* Select up I2C2 and setup invariant attributes */
+      /* Select up I2C2 and the (initial) I2C frequency */
 
       priv = &g_i2c2;
-      priv->attr = &g_i2c2attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C2_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C3_MASTER
   if (bus == 3)
     {
-      /* Select up I2C3 and setup invariant attributes */
+      /* Select up I2C3 and the (initial) I2C frequency */
 
       priv = &g_i2c3;
-      priv->attr = &g_i2c3attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C3_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C4_MASTER
   if (bus == 4)
     {
-      /* Select up I2C4 and setup invariant attributes */
+      /* Select up I2C4 and the (initial) I2C frequency */
 
       priv = &g_i2c4;
-      priv->attr = &g_i2c4attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C4_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C5_MASTER
   if (bus == 5)
     {
-      /* Select up I2C5 and setup invariant attributes */
+      /* Select up I2C5 and the (initial) I2C frequency */
 
       priv = &g_i2c5;
-      priv->attr = &g_i2c5attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C5_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C6_MASTER
   if (bus == 6)
     {
-      /* Select up I2C6 and setup invariant attributes */
+      /* Select up I2C6 and the (initial) I2C frequency */
 
       priv = &g_i2c6;
-      priv->attr = &g_i2c6attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C6_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C7_MASTER
   if (bus == 7)
     {
-      /* Select up I2C7 and setup invariant attributes */
+      /* Select up I2C7 and the (initial) I2C frequency */
 
       priv = &g_i2c7;
-      priv->attr = &g_i2c7attr;

Review Comment:
   Yes



##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -1275,111 +1347,79 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
 #ifdef SAMD5E5_HAVE_I2C0_MASTER
   if (bus == 0)
     {
-      /* Select up I2C0 and setup invariant attributes */
+      /* Select up I2C0 and the (initial) I2C frequency */
 
       priv = &g_i2c0;
-      priv->attr = &g_i2c0attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C0_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C1_MASTER
   if (bus == 1)
     {
-      /* Select up I2C1 and setup invariant attributes */
+      /* Select up I2C1 and the (initial) I2C frequency */
 
       priv = &g_i2c1;
-      priv->attr = &g_i2c1attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C1_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C2_MASTER
   if (bus == 2)
     {
-      /* Select up I2C2 and setup invariant attributes */
+      /* Select up I2C2 and the (initial) I2C frequency */
 
       priv = &g_i2c2;
-      priv->attr = &g_i2c2attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C2_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C3_MASTER
   if (bus == 3)
     {
-      /* Select up I2C3 and setup invariant attributes */
+      /* Select up I2C3 and the (initial) I2C frequency */
 
       priv = &g_i2c3;
-      priv->attr = &g_i2c3attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C3_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C4_MASTER
   if (bus == 4)
     {
-      /* Select up I2C4 and setup invariant attributes */
+      /* Select up I2C4 and the (initial) I2C frequency */
 
       priv = &g_i2c4;
-      priv->attr = &g_i2c4attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C4_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C5_MASTER
   if (bus == 5)
     {
-      /* Select up I2C5 and setup invariant attributes */
+      /* Select up I2C5 and the (initial) I2C frequency */
 
       priv = &g_i2c5;
-      priv->attr = &g_i2c5attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C5_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C6_MASTER
   if (bus == 6)
     {
-      /* Select up I2C6 and setup invariant attributes */
+      /* Select up I2C6 and the (initial) I2C frequency */
 
       priv = &g_i2c6;
-      priv->attr = &g_i2c6attr;

Review Comment:
   Yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011142297


##########
arch/arm/src/sam34/sam_twi.c:
##########
@@ -187,14 +187,6 @@ static void twi_hw_initialize(struct twi_dev_s *priv, unsigned int pid,
  * Private Data
  ****************************************************************************/
 
-#ifdef CONFIG_SAM34_TWIM0
-static struct twi_dev_s g_twi0;
-#endif
-
-#ifdef CONFIG_SAM34_TWIM1
-static struct twi_dev_s g_twi1;
-#endif
-

Review Comment:
   Yes, we need put the initial value to g_twi1



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011961935


##########
arch/arm/src/samd5e5/sam_tc.c:
##########
@@ -85,8 +85,9 @@ static const struct tc_attr_s g_tc0attr =
 };
 static struct sam_tc_dev_s g_tc0 =
 {
-  .initialized = false,
-  .inuse = false,
+  .attr      = &g_tc0attr,

Review Comment:
   yes



##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -1275,111 +1347,79 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
 #ifdef SAMD5E5_HAVE_I2C0_MASTER
   if (bus == 0)
     {
-      /* Select up I2C0 and setup invariant attributes */
+      /* Select up I2C0 and the (initial) I2C frequency */
 
       priv = &g_i2c0;
-      priv->attr = &g_i2c0attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C0_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C1_MASTER
   if (bus == 1)
     {
-      /* Select up I2C1 and setup invariant attributes */
+      /* Select up I2C1 and the (initial) I2C frequency */
 
       priv = &g_i2c1;
-      priv->attr = &g_i2c1attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C1_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C2_MASTER
   if (bus == 2)
     {
-      /* Select up I2C2 and setup invariant attributes */
+      /* Select up I2C2 and the (initial) I2C frequency */
 
       priv = &g_i2c2;
-      priv->attr = &g_i2c2attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C2_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD5E5_HAVE_I2C3_MASTER
   if (bus == 3)
     {
-      /* Select up I2C3 and setup invariant attributes */
+      /* Select up I2C3 and the (initial) I2C frequency */
 
       priv = &g_i2c3;
-      priv->attr = &g_i2c3attr;

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011963009


##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -348,7 +401,16 @@ static const struct i2c_attr_s g_i2c5attr =
   .base      = SAM_SERCOM5_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c5;
+static struct sam_i2c_dev_s g_i2c5 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c5attr,

Review Comment:
   yes



##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -330,7 +374,16 @@ static const struct i2c_attr_s g_i2c4attr =
   .base      = SAM_SERCOM4_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c4;
+static struct sam_i2c_dev_s g_i2c4 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c4attr,

Review Comment:
   yes



##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -312,7 +347,16 @@ static const struct i2c_attr_s g_i2c3attr =
   .base      = SAM_SERCOM3_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c3;
+static struct sam_i2c_dev_s g_i2c3 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c3attr,

Review Comment:
   yes



##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -294,7 +320,16 @@ static const struct i2c_attr_s g_i2c2attr =
   .base      = SAM_SERCOM2_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c2;
+static struct sam_i2c_dev_s g_i2c2 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c2attr,

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011163584


##########
arch/arm/src/sama5/sam_hsmci.c:
##########
@@ -596,57 +596,145 @@ static void sam_callback(void *arg);
  * Private Data
  ****************************************************************************/
 
-/* Callbacks */
+/* Pre-allocate memory for each HSMCI device */
 
-static const struct sdio_dev_s g_callbacks =
+#ifdef CONFIG_SAMA5_HSMCI0
+static struct sam_dev_s g_hsmci0 =
 {
-  .reset            = sam_reset,
-  .capabilities     = sam_capabilities,
-  .status           = sam_status,
-  .widebus          = sam_widebus,
-  .clock            = sam_clock,
-  .attach           = sam_attach,
-  .sendcmd          = sam_sendcmd,
-  .blocksetup       = sam_blocksetup,
-  .recvsetup        = sam_recvsetup,
-  .sendsetup        = sam_sendsetup,
-  .cancel           = sam_cancel,
-  .waitresponse     = sam_waitresponse,
-  .recv_r1          = sam_recvshort,
-  .recv_r2          = sam_recvlong,
-  .recv_r3          = sam_recvshort,
-  .recv_r4          = sam_recvnotimpl,
-  .recv_r5          = sam_recvnotimpl,
-  .recv_r6          = sam_recvshort,
-  .recv_r7          = sam_recvshort,
-  .waitenable       = sam_waitenable,
-  .eventwait        = sam_eventwait,
-  .callbackenable   = sam_callbackenable,
-  .registercallback = sam_registercallback,
+  .dev                =
+  {
+    .reset            = sam_reset,
+    .capabilities     = sam_capabilities,
+    .status           = sam_status,
+    .widebus          = sam_widebus,
+    .clock            = sam_clock,
+    .attach           = sam_attach,
+    .sendcmd          = sam_sendcmd,
+    .blocksetup       = sam_blocksetup,
+    .recvsetup        = sam_recvsetup,
+    .sendsetup        = sam_sendsetup,
+    .cancel           = sam_cancel,
+    .waitresponse     = sam_waitresponse,
+    .recv_r1          = sam_recvshort,
+    .recv_r2          = sam_recvlong,
+    .recv_r3          = sam_recvshort,
+    .recv_r4          = sam_recvnotimpl,
+    .recv_r5          = sam_recvnotimpl,
+    .recv_r6          = sam_recvshort,
+    .recv_r7          = sam_recvshort,
+    .waitenable       = sam_waitenable,
+    .eventwait        = sam_eventwait,
+    .callbackenable   = sam_callbackenable,
+    .registercallback = sam_registercallback,
 #ifdef CONFIG_SDIO_DMA
 #ifndef HSCMI_NORXDMA
-  .dmarecvsetup     = sam_dmarecvsetup,
+    .dmarecvsetup     = sam_dmarecvsetup,
 #else
-  .dmarecvsetup     = sam_recvsetup,
+    .dmarecvsetup     = sam_recvsetup,
 #endif
 #ifndef HSCMI_NOTXDMA
-  .dmasendsetup     = sam_dmasendsetup,
+    .dmasendsetup     = sam_dmasendsetup,
 #else
-  .dmasendsetup     = sam_sendsetup,
+    .dmasendsetup     = sam_sendsetup,
 #endif
 #endif
+  },
+  .waitsem            = SEM_INITIALIZER(0),
+  .base               = SAM_HSMCI0_VBASE,
+  .hsmci              = 0,
 };
-
-/* Pre-allocate memory for each HSMCI device */
-
-#ifdef CONFIG_SAMA5_HSMCI0
-static struct sam_dev_s g_hsmci0;
 #endif
 #ifdef CONFIG_SAMA5_HSMCI1
-static struct sam_dev_s g_hsmci1;
+static struct sam_dev_s g_hsmci1 =
+{
+  .dev                =
+  {
+    .reset            = sam_reset,
+    .capabilities     = sam_capabilities,
+    .status           = sam_status,
+    .widebus          = sam_widebus,
+    .clock            = sam_clock,
+    .attach           = sam_attach,
+    .sendcmd          = sam_sendcmd,
+    .blocksetup       = sam_blocksetup,
+    .recvsetup        = sam_recvsetup,
+    .sendsetup        = sam_sendsetup,
+    .cancel           = sam_cancel,
+    .waitresponse     = sam_waitresponse,
+    .recv_r1          = sam_recvshort,
+    .recv_r2          = sam_recvlong,
+    .recv_r3          = sam_recvshort,
+    .recv_r4          = sam_recvnotimpl,
+    .recv_r5          = sam_recvnotimpl,
+    .recv_r6          = sam_recvshort,
+    .recv_r7          = sam_recvshort,
+    .waitenable       = sam_waitenable,
+    .eventwait        = sam_eventwait,
+    .callbackenable   = sam_callbackenable,
+    .registercallback = sam_registercallback,
+#ifdef CONFIG_SDIO_DMA
+#ifndef HSCMI_NORXDMA
+    .dmarecvsetup     = sam_dmarecvsetup,
+#else
+    .dmarecvsetup     = sam_recvsetup,
+#endif
+#ifndef HSCMI_NOTXDMA
+    .dmasendsetup     = sam_dmasendsetup,
+#else
+    .dmasendsetup     = sam_sendsetup,
+#endif
+#endif
+  },
+  .waitsem            = SEM_INITIALIZER(0),
+  .base               = SAM_HSMCI0_VBASE,
+  .hsmci              = 0,
+};
 #endif
 #ifdef CONFIG_SAMA5_HSMCI2
-static struct sam_dev_s g_hsmci2;
+static struct sam_dev_s g_hsmci2 =
+{
+  .dev                =
+  {
+    .reset            = sam_reset,
+    .capabilities     = sam_capabilities,
+    .status           = sam_status,
+    .widebus          = sam_widebus,
+    .clock            = sam_clock,
+    .attach           = sam_attach,
+    .sendcmd          = sam_sendcmd,
+    .blocksetup       = sam_blocksetup,
+    .recvsetup        = sam_recvsetup,
+    .sendsetup        = sam_sendsetup,
+    .cancel           = sam_cancel,
+    .waitresponse     = sam_waitresponse,
+    .recv_r1          = sam_recvshort,
+    .recv_r2          = sam_recvlong,
+    .recv_r3          = sam_recvshort,
+    .recv_r4          = sam_recvnotimpl,
+    .recv_r5          = sam_recvnotimpl,
+    .recv_r6          = sam_recvshort,
+    .recv_r7          = sam_recvshort,
+    .waitenable       = sam_waitenable,
+    .eventwait        = sam_eventwait,
+    .callbackenable   = sam_callbackenable,
+    .registercallback = sam_registercallback,

Review Comment:
   Yes, it's better to use the same method to initialize all field



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011147988


##########
arch/arm/src/sama5/sam_adc.c:
##########
@@ -2041,17 +2050,9 @@ struct adc_dev_s *sam_adc_initialize(void)
       /* Initialize the public ADC device data structure */
 
 #ifdef SAMA5_ADC_HAVE_CHANNELS
-      g_adcdev.ad_ops  = &g_adcops;
       priv->dev = &g_adcdev;
 #endif
 
-      g_adcdev.ad_priv = priv;
-
-      /* Initialize the private ADC device data structure */
-
-      nxmutex_init(&priv->lock);
-      priv->cb  = NULL;

Review Comment:
   Yes, since all field initialization in the same(definition) place



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#issuecomment-1301089046

   @masayuki2009 please review again.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] masayuki2009 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1010081631


##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -179,15 +178,19 @@ static const struct spi_ops_s g_spi4ops =
 static struct cxd56_spidev_s g_spi4dev =
 {
   .spidev            =
-                        {
-                         &g_spi4ops
-                        },
+  {
+    .ops             = &g_spi4ops,
+  },
   .spibase           = CXD56_IMG_SPI_BASE,

Review Comment:
   @xiaoxiang781216 
   I think it would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -264,15 +271,19 @@ static const struct spi_ops_s g_spi0ops =
 static struct cxd56_spidev_s g_spi0dev =
 {
   .spidev            =
-                        {
-                         &g_spi0ops
-                        },
+  {
+    .ops             = &g_spi0ops,
+  },
   .spibase           = CXD56_SPIM_BASE,

Review Comment:
   @xiaoxiang781216
   I think it would be better to move the style change to the 3rd commit.



##########
arch/arm/src/cxd56xx/cxd56_hostif.c:
##########
@@ -379,8 +382,6 @@ static int hif_initialize(struct hostif_buff_s *buffer)
 
   DEBUGASSERT(buffer);
 
-  memset(drv, 0, sizeof(struct cxd56_hifdrv_s));
-

Review Comment:
   @xiaoxiang781216 
   I think this change does not relate to the global mutex/sem initialization.
   



##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -306,15 +317,19 @@ static const struct spi_ops_s g_spi3ops =
 static struct cxd56_spidev_s g_spi3dev =
 {
   .spidev            =
-                        {
-                         &g_spi3ops
-                        },
+  {
+    .ops             = &g_spi3ops,
+  },
   .spibase           = CXD56_SCU_SPI_BASE,

Review Comment:
   @xiaoxiang781216
   I think it would be better to move the style change to the 3rd commit.



##########
arch/arm/src/efm32/efm32_usbhost.c:
##########
@@ -5259,29 +5263,20 @@ static inline void efm32_sw_initialize(struct efm32_usbhost_s *priv)
 
   usbhost_devaddr_initialize(&priv->rhport);
 
-  /* Initialize semaphores & mutex */
-
-  nxsem_init(&priv->pscsem,  0, 0);
-  nxmutex_init(&priv->lock);
-
   /* Initialize the driver state data */
 
   priv->smstate   = SMSTATE_DETACHED;
   priv->connected = false;
   priv->change    = false;
 
-  /* Put all of the channels back in their initial, allocated state */
-
-  memset(priv->chan, 0, EFM32_MAX_TX_FIFOS * sizeof(struct efm32_chan_s));
-

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/rem initialization?
   



##########
arch/arm/src/cxd56xx/cxd56_emmc.c:
##########
@@ -932,17 +935,11 @@ static int cxd56_emmc_geometry(struct inode *inode,
 
 int cxd56_emmcinitialize(void)
 {
-  struct cxd56_emmc_state_s *priv;
+  struct cxd56_emmc_state_s *priv = &g_emmcdev;
   uint8_t *buf;
   struct emmc_dma_desc_s *descs;
   int ret;
 
-  priv = &g_emmcdev;
-

Review Comment:
   @xiaoxiang781216 
   I think this is a kind of style change.
   



##########
arch/arm/src/efm32/efm32_usbhost.c:
##########
@@ -5259,29 +5263,20 @@ static inline void efm32_sw_initialize(struct efm32_usbhost_s *priv)
 
   usbhost_devaddr_initialize(&priv->rhport);
 
-  /* Initialize semaphores & mutex */
-
-  nxsem_init(&priv->pscsem,  0, 0);
-  nxmutex_init(&priv->lock);
-
   /* Initialize the driver state data */
 
   priv->smstate   = SMSTATE_DETACHED;
   priv->connected = false;
   priv->change    = false;
 
-  /* Put all of the channels back in their initial, allocated state */
-
-  memset(priv->chan, 0, EFM32_MAX_TX_FIFOS * sizeof(struct efm32_chan_s));
-
   /* Initialize each channel */
 
   for (i = 0; i < EFM32_MAX_TX_FIFOS; i++)
     {
       struct efm32_chan_s *chan = &priv->chan[i];
 
       chan->chidx = i;
-      nxsem_init(&chan->waitsem,  0, 0);
+      nxsem_init(&chan->waitsem, 0, 0);
     }

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -77,7 +77,6 @@ struct cxd56_spidev_s
   uint8_t          port;        /* Port number */
   int              initialized; /* Initialized flag */
 #ifdef CONFIG_CXD56_DMAC
-  bool             dmaenable;   /* Use DMA or not */
   DMA_HANDLE       rxdmach;     /* RX DMA channel handle */

Review Comment:
   @xiaoxiang781216 
   I don not think removing `dmaenable` does not relte to the global/mutex/sem initialization.
   



##########
arch/arm/src/imxrt/imxrt_flexspi.c:
##########
@@ -112,7 +112,8 @@ static struct imxrt_flexspidev_s g_flexspi0dev =
   {
     .ops = &g_flexspi0ops,
   },
-  .base = (struct flexspi_type_s *) IMXRT_FLEXSPIC_BASE,
+  .base = (struct flexspi_type_s *)IMXRT_FLEXSPIC_BASE,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/imxrt/imxrt_rtc_lowerhalf.c:
##########
@@ -128,7 +128,8 @@ static const struct rtc_ops_s g_rtc_ops =
 
 static struct imxrt_lowerhalf_s g_rtc_lowerhalf =
 {
-  .ops         = &g_rtc_ops,
+  .ops     = &g_rtc_ops,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/kinetis/kinetis_spi.c:
##########
@@ -221,12 +221,13 @@ static const struct spi_ops_s g_spi0ops =
 
 static struct kinetis_spidev_s g_spi0dev =
 {
-  .spidev            =
+  .spidev   =
   {
     &g_spi0ops
   },
-  .spibase           = KINETIS_SPI0_BASE,
-  .ctarsel           = KINETIS_SPI_CTAR0_OFFSET,
+  .spibase  = KINETIS_SPI0_BASE,
+  .lock     = NXMUTEX_INITIALIZER,
+  .ctarsel  = KINETIS_SPI_CTAR0_OFFSET,
 #ifdef CONFIG_KINETIS_SPI_DMA

Review Comment:
   @xiaoxiang781216 
   It would be better to moe the style changes to the 3rd commit.
   



##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -222,15 +225,19 @@ static const struct spi_ops_s g_spi5ops =
 static struct cxd56_spidev_s g_spi5dev =
 {
   .spidev            =
-                        {
-                         &g_spi5ops
-                        },
+  {
+    .ops             = &g_spi5ops,
+  },

Review Comment:
   @xiaoxiang781216
   I think it would be better to move the style change to the 3rd commit.



##########
arch/arm/src/cxd56xx/cxd56_uart0.c:
##########
@@ -231,17 +231,7 @@ static ssize_t uart0_write(struct file *filep,
 
 int cxd56_uart0initialize(const char *devname)
 {
-  int ret;
-
-  nxmutex_init(&g_lock);
-
-  ret = register_driver(devname, &g_uart0fops, 0666, NULL);
-  if (ret != 0)
-    {
-      return ERROR;
-    }
-
-  return OK;
+  return register_driver(devname, &g_uart0fops, 0666, NULL);
 }

Review Comment:
   @xiaoxiang781216 
   Removing `nxmutex_init(&g_lock);` is OK to be included in the first commit.
   However, removing `ret` does not relate to the global mutex/sem initialization.
   



##########
arch/arm/src/kinetis/kinetis_usbhshost.c:
##########
@@ -5272,7 +5268,6 @@ struct usbhost_connection_s *kinetis_ehci_initialize(int controller)
    * port is reset (and enabled)."
    */
 
-  memset(&g_asynchead, 0, sizeof(struct kinetis_qh_s));

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -1201,14 +1216,6 @@ struct spi_dev_s *cxd56_spibus_initialize(int port)
   cxd56_spi_clock_enable(port);
   priv->spibasefreq = cxd56_get_spi_baseclock(port);
 
-  /* DMA settings */
-
-#ifdef CONFIG_CXD56_DMAC
-  priv->dmaenable = false;
-  priv->txdmach   = NULL;
-  priv->rxdmach   = NULL;
-#endif
-

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/cxd56xx/cxd56_hostif.c:
##########
@@ -441,11 +442,7 @@ static int hif_initialize(struct hostif_buff_s *buffer)
 
   cxd56_iccinit(CXD56_PROTO_HOSTIF);
 
-  nxsem_init(&drv->sync, 0, 0);
-
-  ret = cxd56_iccregisterhandler(CXD56_PROTO_HOSTIF, hif_rxhandler, NULL);
-
-  return ret;
+  return cxd56_iccregisterhandler(CXD56_PROTO_HOSTIF, hif_rxhandler, NULL);
 }

Review Comment:
   @xiaoxiang781216 
   I think this change does not relate to the global mutex/sem initialization.
   



##########
arch/arm/src/efm32/efm32_usbhost.c:
##########
@@ -484,14 +484,18 @@ static inline int efm32_hw_initialize(struct efm32_usbhost_s *priv);
  * single global instance.
  */
 
-static struct efm32_usbhost_s g_usbhost;
+static struct efm32_usbhost_s g_usbhost =
+{
+  .lock = NXMUTEX_INITIALIZER,
+  .pscsem = SEM_INITIALIZER(0),
+};
 
 /* This is the connection/enumeration interface */
 
 static struct usbhost_connection_s g_usbconn =
 {
-  .wait             = efm32_wait,
-  .enumerate        = efm32_enumerate,
+  .wait      = efm32_wait,
+  .enumerate = efm32_enumerate,
 };

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -871,7 +886,7 @@ static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer,
   size_t dmath = 0;
 #endif
 
-  if (priv->dmaenable && dmath < nwords)
+  if (priv->txdmach && priv->rxdmach && dmath < nwords)
     {

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/lpc17xx_40xx/lpc17_40_spi.c:
##########
@@ -139,9 +139,10 @@ static const struct spi_ops_s g_spiops =
 static struct lpc17_40_spidev_s g_spidev =
 {
   .spidev            =
-    {
-      &g_spiops
-    },
+  {
+    .ops             = &g_spiops,
+  },

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/lc823450/lc823450_usbdev.c:
##########
@@ -1722,14 +1720,13 @@ void usbdev_msc_read_enter()
   privep->epcmd &= ~USB_EPCMD_EMPTY_EN;
   epcmd_write(CONFIG_USBMSC_EPBULKIN, (privep->epcmd));
   lc823450_dmareauest_dir(g_hdma, DMA_REQUEST_USBDEV, 1);
-  nxsem_init(&dma_wait, 0, 0);
 }
 
 /****************************************************************************
  * Name: usbdev_msc_read_exit
  ****************************************************************************/
 
-void usbdev_msc_read_exit()
+void usbdev_msc_read_exit(void)

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/lc823450/lc823450_serial.c:
##########
@@ -1100,7 +1111,7 @@ static void uart_rxdma_callback(DMA_HANDLE hdma, void *arg, int result)
  * Name: up_hs_dmasetup
  ****************************************************************************/
 
-static void  up_hs_dmasetup()
+static void  up_hs_dmasetup(void)

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/lc823450/lc823450_spi.c:
##########
@@ -127,9 +127,15 @@ static const struct spi_ops_s g_spiops =
 static struct lc823450_spidev_s g_spidev =
 {
   .spidev            =
-    {
-      &g_spiops
-    },
+  {
+    .ops             = &g_spiops
+  },

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/lc823450/lc823450_spi.c:
##########
@@ -73,7 +73,7 @@ struct lc823450_spidev_s
 #endif
 #ifdef CONFIG_LC823450_SPI_DMA
   DMA_HANDLE       hdma;
-  sem_t dma_wait;
+  sem_t            dma_wait;

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/lpc17xx_40xx/lpc17_40_ssp.c:
##########
@@ -212,13 +213,14 @@ static const struct spi_ops_s g_spi1ops =
 static struct lpc17_40_sspdev_s g_ssp1dev =
 {
   .spidev            =
-    {
-      &g_spi1ops
-    },
+  {
+    .ops             = &g_spi1ops,
+  },

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/lpc17xx_40xx/lpc17_40_usbhost.c:
##########
@@ -3826,11 +3825,9 @@ struct usbhost_connection_s *lpc17_40_usbhost_initialize(int controller)
         LPC17_40_IOBUFFERS * CONFIG_LPC17_40_USBHOST_IOBUFSIZE);
 #endif
 
-  /* Initialize all the TDs, EDs and HCCA to 0 */
-
-  memset((void *)HCCA,   0, sizeof(struct ohci_hcca_s));
-  memset((void *)TDTAIL, 0, sizeof(struct ohci_gtd_s));
-  memset((void *)EDCTRL, 0, sizeof(struct lpc17_40_ed_s));

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/lpc17xx_40xx/lpc17_40_ssp.c:
##########
@@ -247,13 +249,14 @@ static const struct spi_ops_s g_spi2ops =
 static struct lpc17_40_sspdev_s g_ssp2dev =
 {
   .spidev            =
-    {
-      &g_spi2ops
-    },
+  {
+    .ops             = &g_spi2ops,
+  },
   .sspbase           = LPC17_40_SSP2_BASE,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/imx1/imx_spi.c:
##########
@@ -207,19 +207,23 @@ static struct imx_spidev_s g_spidev[] =
 {
 #ifdef CONFIG_IMX1_SPI1
   {
-    .ops  = &g_spiops,
-    .base = IMX_CSPI1_VBASE,
+    .ops     = &g_spiops,
+    .base    = IMX_CSPI1_VBASE,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/lpc17xx_40xx/lpc17_40_ssp.c:
##########
@@ -177,13 +177,14 @@ static const struct spi_ops_s g_spi0ops =
 static struct lpc17_40_sspdev_s g_ssp0dev =
 {
   .spidev            =
-    {
-      &g_spi0ops
-    },
+  {
+    .ops             = &g_spi0ops,
+  },

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/imxrt/imxrt_ehci.c:
##########
@@ -5202,7 +5202,6 @@ struct usbhost_connection_s *imxrt_ehci_initialize(int controller)
    * port is reset (and enabled)."
    */
 
-  memset(&g_asynchead, 0, sizeof(struct imxrt_qh_s));

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/imx1/imx_spi.c:
##########
@@ -207,19 +207,23 @@ static struct imx_spidev_s g_spidev[] =
 {
 #ifdef CONFIG_IMX1_SPI1
   {
-    .ops  = &g_spiops,
-    .base = IMX_CSPI1_VBASE,
+    .ops     = &g_spiops,
+    .base    = IMX_CSPI1_VBASE,
+    .lock    = NXMUTEX_INITIALIZER,
 #ifndef CONFIG_SPI_POLLWAIT
-    .irq  = IMX_IRQ_CSPI1,
+    .waitsem = SEM_INITIALIZER(0),
+    .irq     = IMX_IRQ_CSPI1,
 #endif

Review Comment:
   @xiaoxiang781216 
   The line including `.irq` is a kind of style change.
   



##########
arch/arm/src/imxrt/imxrt_ehci.c:
##########
@@ -5225,7 +5224,6 @@ struct usbhost_connection_s *imxrt_ehci_initialize(int controller)
    * to point to the Interrupt Queue Head (g_intrhead).
    */
 
-  memset(&g_intrhead, 0, sizeof(struct imxrt_qh_s));

Review Comment:
   @xiaoxiang781216
   Does this change relate to the global mutex/sem initialization?



##########
arch/arm/src/imxrt/imxrt_ehci.c:
##########
@@ -5336,10 +5334,6 @@ struct usbhost_connection_s *imxrt_ehci_initialize(int controller)
 
   usbhost_vtrace1(EHCI_VTRACE1_INIITIALIZED, 0);
 
-  /* Initialize and return the connection interface */
-
-  g_ehciconn.wait = imxrt_wait;
-  g_ehciconn.enumerate = imxrt_enumerate;

Review Comment:
   @xiaoxiang781216
   Does this change relate to the global mutex/sem initialization?



##########
arch/arm/src/lpc2378/lpc23xx_spi.c:
##########
@@ -158,9 +158,10 @@ static const struct spi_ops_s g_spiops =
 static struct lpc23xx_spidev_s g_spidev =
 {
   .spidev            =
-    {
-      &g_spiops
-    },
+  {
+    .ops             = &g_spiops,
+  },

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/imxrt/imxrt_flexspi.c:
##########
@@ -606,8 +607,6 @@ void imxrt_flexspi_get_default_config(struct flexspi_config_s *config)
   config->ahb_config.ahb_grant_timeout_cycle  = 0xff;
   config->ahb_config.ahb_bus_timeout_cycle    = 0xffff;
   config->ahb_config.resume_wait_cycle        = 0x20;
-  memset(config->ahb_config.buffer, 0,
-         sizeof(config->ahb_config.buffer));

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/imxrt/imxrt_lpspi.c:
##########
@@ -334,15 +340,18 @@ static struct imxrt_lpspidev_s g_lpspi3dev =
 {
   .spidev       =
   {
-    &g_spi3ops
+    .ops        = &g_spi3ops,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/gd32f4/gd32f4xx_spi.c:
##########
@@ -293,11 +293,12 @@ static uint8_t g_spi0_rxbuf[SPI0_DMA_BUFSIZE_ADJ] SPI_DMA_BUFEER_ALIGN;
 static struct gd32_spidev_s g_spi0dev =
 {
   .spidev   =
-              {
-               &g_spi0ops
-              },
+  {
+    .ops    = &g_spi0ops
+  },

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/imxrt/imxrt_lpspi.c:
##########
@@ -380,15 +389,18 @@ static struct imxrt_lpspidev_s g_lpspi4dev =
 {
   .spidev       =
   {
-    &g_spi4ops
+    .ops        = &g_spi4ops,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/kinetis/kinetis_edma.c:
##########
@@ -721,18 +707,12 @@ void weak_function arm_dma_initialize(void)
 
   /* Initialize data structures */
 
-  memset(&g_edma, 0, sizeof(struct kinetis_edma_s));

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/kinetis/kinetis_spi.c:
##########
@@ -319,12 +325,13 @@ static const struct spi_ops_s g_spi2ops =
 
 static struct kinetis_spidev_s g_spi2dev =
 {
-  .spidev            =
+  .spidev   =
   {
     &g_spi2ops
   },
-  .spibase           = KINETIS_SPI2_BASE,
-  .ctarsel           = KINETIS_SPI_CTAR0_OFFSET,
+  .spibase  = KINETIS_SPI2_BASE,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/kinetis/kinetis_spi.c:
##########
@@ -270,12 +273,13 @@ static const struct spi_ops_s g_spi1ops =
 
 static struct kinetis_spidev_s g_spi1dev =
 {
-  .spidev            =
+  .spidev   =
   {
     &g_spi1ops
   },
-  .spibase           = KINETIS_SPI1_BASE,
-  .ctarsel           = KINETIS_SPI_CTAR0_OFFSET,
+  .spibase  = KINETIS_SPI1_BASE,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/imx1/imx_spi.c:
##########
@@ -207,19 +207,23 @@ static struct imx_spidev_s g_spidev[] =
 {
 #ifdef CONFIG_IMX1_SPI1
   {
-    .ops  = &g_spiops,
-    .base = IMX_CSPI1_VBASE,
+    .ops     = &g_spiops,
+    .base    = IMX_CSPI1_VBASE,
+    .lock    = NXMUTEX_INITIALIZER,
 #ifndef CONFIG_SPI_POLLWAIT
-    .irq  = IMX_IRQ_CSPI1,
+    .waitsem = SEM_INITIALIZER(0),
+    .irq     = IMX_IRQ_CSPI1,
 #endif
   },
 #endif
 #ifdef CONFIG_IMX1_SPI2
   {
-    .ops  = &g_spiops,
-    .base = IMX_CSPI2_VBASE,
+    .ops     = &g_spiops,
+    .base    = IMX_CSPI2_VBASE,
+    .lock    = NXMUTEX_INITIALIZER,
 #ifndef CONFIG_SPI_POLLWAIT
-    .irq  = IMX_IRQ_CSPI2,
+    .waitsem = SEM_INITIALIZER(0),
+    .irq     = IMX_IRQ_CSPI2,
 #endif

Review Comment:
   @xiaoxiang781216 
   The lines including `.ops`, `.base` and `.irq` are a kind of style changes.
   



##########
arch/arm/src/imxrt/imxrt_lpspi.c:
##########
@@ -242,15 +242,18 @@ static struct imxrt_lpspidev_s g_lpspi1dev =
 {
   .spidev       =
   {
-    &g_spi1ops
+    .ops        = &g_spi1ops,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/kinetis/kinetis_usbhshost.c:
##########
@@ -5295,7 +5290,6 @@ struct usbhost_connection_s *kinetis_ehci_initialize(int controller)
    * to point to the Interrupt Queue Head (g_intrhead).
    */
 
-  memset(&g_intrhead, 0, sizeof(struct kinetis_qh_s));

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/kl/kl_spi.c:
##########
@@ -154,10 +155,11 @@ static const struct spi_ops_s g_spi1ops =
 static struct kl_spidev_s g_spi1dev =
 {
   .spidev            =
-    {
-      &g_spi1ops
-    },
+  {
+    .ops             = &g_spi1ops
+  },

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/kinetis/kinetis_usbhshost.c:
##########
@@ -5406,10 +5400,6 @@ struct usbhost_connection_s *kinetis_ehci_initialize(int controller)
 
   usbhost_vtrace1(EHCI_VTRACE1_INIITIALIZED, 0);
 
-  /* Initialize and return the connection interface */
-
-  g_ehciconn.wait = kinetis_wait;
-  g_ehciconn.enumerate = kinetis_enumerate;

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/kl/kl_spi.c:
##########
@@ -122,10 +122,11 @@ static const struct spi_ops_s g_spi0ops =
 static struct kl_spidev_s g_spi0dev =
 {
   .spidev            =
-    {
-      &g_spi0ops
-    },
+  {
+    .ops             = &g_spi0ops
+  },

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit
   



##########
arch/arm/src/lc823450/lc823450_dma.c:
##########
@@ -303,7 +306,7 @@ static void dma_done(DMA_HANDLE handle, void *arg, int result)
   test_done = 1;
 }
 
-void lc823450_dma_test()
+void lc823450_dma_test(void)

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/lpc31xx/lpc31_ehci.c:
##########
@@ -5279,7 +5279,6 @@ struct usbhost_connection_s *lpc31_ehci_initialize(int controller)
    *  first port is reset (and enabled)."
    */
 
-  memset(&g_asynchead, 0, sizeof(struct lpc31_qh_s));

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/lpc31xx/lpc31_ehci.c:
##########
@@ -5303,7 +5302,6 @@ struct usbhost_connection_s *lpc31_ehci_initialize(int controller)
    * Head (g_intrhead).
    */
 
-  memset(&g_intrhead, 0, sizeof(struct lpc31_qh_s));

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/lpc31xx/lpc31_ehci.c:
##########
@@ -5440,10 +5438,6 @@ struct usbhost_connection_s *lpc31_ehci_initialize(int controller)
   up_enable_irq(LPC31_IRQ_USBOTG); /* enable USB interrupt */
   usbhost_vtrace1(EHCI_VTRACE1_INIITIALIZED, 0);
 
-  /* Initialize and return the connection interface */
-
-  g_ehciconn.wait      = lpc31_wait;
-  g_ehciconn.enumerate = lpc31_enumerate;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/lpc31xx/lpc31_spi.c:
##########
@@ -154,9 +154,10 @@ static const struct spi_ops_s g_spiops =
 static struct lpc31_spidev_s g_spidev =
 {
   .spidev            =
-    {
-      &g_spiops
-    },
+  {
+    .ops             = &g_spiops,
+  },

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/lpc43xx/lpc43_ehci.c:
##########
@@ -5240,10 +5238,6 @@ struct usbhost_connection_s *lpc43_ehci_initialize(int controller)
   up_enable_irq(LPC43M4_IRQ_USB0); /* enable USB interrupt */
   usbhost_vtrace1(EHCI_VTRACE1_INIITIALIZED, 0);
 
-  /* Initialize and return the connection interface */
-
-  g_ehciconn.wait      = lpc43_wait;
-  g_ehciconn.enumerate = lpc43_enumerate;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/lpc43xx/lpc43_spi.c:
##########
@@ -130,9 +130,10 @@ static const struct spi_ops_s g_spiops =
 static struct lpc43_spidev_s g_spidev =
 {
   .spidev            =
-    {
-      &g_spiops
-    },
+  {
+    .ops             = &g_spiops,
+  },

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/lpc43xx/lpc43_ehci.c:
##########
@@ -5108,7 +5107,6 @@ struct usbhost_connection_s *lpc43_ehci_initialize(int controller)
    * Head (g_intrhead).
    */
 
-  memset(&g_intrhead, 0, sizeof(struct lpc43_qh_s));

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/lpc43xx/lpc43_ssp.c:
##########
@@ -144,14 +144,15 @@ static const struct spi_ops_s g_spi0ops =
 static struct lpc43_sspdev_s g_ssp0dev =
 {
   .spidev            =
-    {
-      &g_spi0ops
-    },
+  {
+    .ops             = &g_spi0ops,
+  },

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/lpc43xx/lpc43_ehci.c:
##########
@@ -5087,7 +5087,6 @@ struct usbhost_connection_s *lpc43_ehci_initialize(int controller)
    *  first port is reset (and enabled)."
    */
 
-  memset(&g_asynchead, 0, sizeof(struct lpc43_qh_s));

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/lpc43xx/lpc43_ssp.c:
##########
@@ -184,14 +185,15 @@ static const struct spi_ops_s g_spi1ops =
 static struct lpc43_sspdev_s g_ssp1dev =
 {
   .spidev            =
-    {
-      &g_spi1ops
-    },
+  {
+    .ops             = &g_spi1ops,
+  },

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/lpc54xx/lpc54_rtc_lowerhalf.c:
##########
@@ -145,7 +145,8 @@ static const struct rtc_ops_s g_rtc_ops =
 
 static struct lpc54_lowerhalf_s g_rtc_lowerhalf =
 {
-  .ops           = &g_rtc_ops,
+  .ops     = &g_rtc_ops,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/lpc54xx/lpc54_usb0_ohci.c:
##########
@@ -3904,11 +3903,9 @@ struct usbhost_connection_s *lpc54_usbhost_initialize(int controller)
         LPC54_IOFREE_BASE, LPC54_IOBUFFERS * CONFIG_LPC54_OHCI_IOBUFSIZE);
 #endif
 
-  /* Initialize all the TDs, EDs and HCCA to 0 */
-
-  memset((void *)HCCA,   0, sizeof(struct ohci_hcca_s));
-  memset((void *)TDTAIL, 0, sizeof(struct ohci_gtd_s));
-  memset((void *)EDCTRL, 0, sizeof(struct lpc54_ed_s));

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/nrf52/nrf52_radio.c:
##########
@@ -1149,22 +1151,11 @@ nrf52_radio_initialize(int intf, struct nrf52_radio_board_s *board)
         }
     }
 
-  /* Reset some data */
-
-  memset(&dev->pktcfg, 0, sizeof(struct nrf52_radio_pktcfg_s));
-  memset(dev->rxbuf, 0, NRF52_RADIO_RXBUFFER);
-  memset(dev->txbuf, 0, NRF52_RADIO_TXBUFFER);

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/nrf52/nrf52_spi.c:
##########
@@ -198,11 +198,13 @@ static struct nrf52_spidev_s g_spi0dev =
 {
   .spidev    =
   {
-    &g_spi0ops
+    .ops     = &g_spi0ops,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/max326xx/common/max326_rtc_lowerhalf.c:
##########
@@ -151,7 +151,8 @@ static const struct rtc_ops_s g_rtc_ops =
 
 static struct max326_lowerhalf_s g_rtc_lowerhalf =
 {
-  .ops        = &g_rtc_ops,
+  .ops     = &g_rtc_ops,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/max326xx/max32660/max32660_spim.c:
##########
@@ -232,10 +232,11 @@ static const struct spi_ops_s g_sp0iops =
 static struct max326_spidev_s g_spi0dev =
 {
   .dev      =
-    {
-      &g_sp0iops
-    },
+  {
+    .ops    = &g_sp0iops,
+  },

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/nrf52/nrf52_rng.c:
##########
@@ -124,13 +128,6 @@ static int nrf52_rng_initialize(void)
 
   first_flag = false;
 
-  _info("Initializing RNG\n");
-
-  memset(&g_rngdev, 0, sizeof(struct rng_dev_s));

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/nrf52/nrf52_spi.c:
##########
@@ -249,11 +251,13 @@ static struct nrf52_spidev_s g_spi1dev =
 {
   .spidev    =
   {
-    &g_spi1ops
+    .ops     = &g_spi1ops,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/nrf52/nrf52_spi.c:
##########
@@ -300,11 +304,13 @@ static struct nrf52_spidev_s g_spi2dev =
 {
   .spidev    =
   {
-    &g_spi2ops
+    .ops     = &g_spi2ops,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/rp2040/rp2040_flash_mtd.c:
##########
@@ -165,10 +165,11 @@ static struct rp2040_flash_dev_s my_dev =
 #endif
       rp2040_flash_ioctl,
       "rp_flash"
-    }
+  },
+  .lock = NXMUTEX_INITIALIZER,
 };
 
-static bool initialized = false;
+static bool initialized;

Review Comment:
   @xiaoxiang781216 
   Do this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/rp2040/rp2040_spi.c:
##########
@@ -222,15 +226,19 @@ static const struct spi_ops_s g_spi1ops =
 static struct rp2040_spidev_s g_spi1dev =
 {
   .spidev            =
-                        {
-                          &g_spi1ops
-                        },
+  {
+    .ops             = &g_spi1ops,
+  },

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/s32k1xx/s32k1xx_lpspi.c:
##########
@@ -255,12 +255,13 @@ static struct s32k1xx_lpspidev_s g_lpspi0dev =
 {
   .spidev       =
   {
-    &g_spi0ops
+    .ops        = &g_spi0ops,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/s32k1xx/s32k1xx_edma.c:
##########
@@ -706,18 +692,12 @@ void weak_function arm_dma_initialize(void)
 
   /* Initialize data structures */
 
-  memset(&g_edma, 0, sizeof(struct s32k1xx_edma_s));

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/s32k1xx/s32k1xx_edma.c:
##########
@@ -215,7 +201,7 @@ static struct s32k1xx_edmatcd_s *s32k1xx_tcd_alloc(void)
    */
 
   flags = enter_critical_section();
-  s32k1xx_takedsem();
+  nxsem_wait_uninterruptible(&g_edma.dsem);

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/rp2040/rp2040_spi.c:
##########
@@ -177,15 +177,19 @@ static const struct spi_ops_s g_spi0ops =
 static struct rp2040_spidev_s g_spi0dev =
 {
   .spidev            =
-                        {
-                          &g_spi0ops
-                        },
+  {
+    .ops             = &g_spi0ops,
+  },

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/s32k1xx/s32k1xx_edma.c:
##########
@@ -247,7 +233,7 @@ static void s32k1xx_tcd_free(struct s32k1xx_edmatcd_s *tcd)
 
   flags = spin_lock_irqsave(NULL);
   sq_addlast((sq_entry_t *)tcd, &g_tcd_free);
-  s32k1xx_givedsem();
+  nxsem_post(&g_edma.dsem);

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/s32k1xx/s32k1xx_edma.c:
##########
@@ -172,26 +178,6 @@ static struct s32k1xx_edmatcd_s g_tcd_pool[CONFIG_S32K1XX_EDMA_NTCD]
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: s32k1xx_takedsem() and s32k1xx_givedsem()
- *
- * Description:
- *   Used to wait for availability of descriptors in the descriptor table.
- *
- ****************************************************************************/
-
-#if CONFIG_S32K1XX_EDMA_NTCD > 0
-static void s32k1xx_takedsem(void)
-{
-  nxsem_wait_uninterruptible(&g_edma.dsem);
-}
-
-static inline void s32k1xx_givedsem(void)
-{
-  nxsem_post(&g_edma.dsem);
-}
-#endif
-

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/s32k1xx/s32k1xx_lpspi.c:
##########
@@ -305,12 +306,13 @@ static struct s32k1xx_lpspidev_s g_lpspi1dev =
 {
   .spidev       =
   {
-    &g_spi1ops
+    .ops        = &g_spi1ops,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/s32k1xx/s32k1xx_lpspi.c:
##########
@@ -355,12 +357,13 @@ static struct s32k1xx_lpspidev_s g_lpspi2dev =
 {
   .spidev       =
   {
-    &g_spi2ops
+    .ops        = &g_spi2ops,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/s32k3xx/s32k3xx_edma.c:
##########
@@ -416,26 +422,6 @@ const struct peripheral_clock_config_s edma_clockconfig[] =
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: s32k3xx_takedsem() and s32k3xx_givedsem()
- *
- * Description:
- *   Used to wait for availability of descriptors in the descriptor table.
- *
- ****************************************************************************/
-
-#if CONFIG_S32K3XX_EDMA_NTCD > 0
-static void s32k3xx_takedsem(void)
-{
-  nxsem_wait_uninterruptible(&g_edma.dsem);
-}
-
-static inline void s32k3xx_givedsem(void)
-{
-  nxsem_post(&g_edma.dsem);
-}
-#endif
-

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/s32k3xx/s32k3xx_edma.c:
##########
@@ -916,18 +902,12 @@ void weak_function arm_dma_initialize(void)
 
   /* Initialize data structures */
 
-  memset(&g_edma, 0, sizeof(struct s32k3xx_edma_s));

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/s32k3xx/s32k3xx_lpspi.c:
##########
@@ -246,15 +246,18 @@ static struct s32k3xx_lpspidev_s g_lpspi0dev =
 {
   .spidev       =
   {
-    &g_spi0ops
+    .ops        = &g_spi0ops,
   },

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/s32k3xx/s32k3xx_lpspi.c:
##########
@@ -293,15 +296,18 @@ static struct s32k3xx_lpspidev_s g_lpspi1dev =
 {
   .spidev       =
   {
-    &g_spi1ops
+    .ops        = &g_spi1ops,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/s32k3xx/s32k3xx_lpspi.c:
##########
@@ -340,15 +346,18 @@ static struct s32k3xx_lpspidev_s g_lpspi2dev =
 {
   .spidev       =
   {
-    &g_spi2ops
+    .ops        = &g_spi2ops,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/s32k3xx/s32k3xx_edma.c:
##########
@@ -491,7 +477,7 @@ static void s32k3xx_tcd_free(struct s32k3xx_edmatcd_s *tcd)
 
   flags = spin_lock_irqsave(NULL);
   sq_addlast((sq_entry_t *)tcd, &g_tcd_free);
-  s32k3xx_givedsem();
+  nxsem_post(&g_edma.dsem);

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/s32k3xx/s32k3xx_lpspi.c:
##########
@@ -434,15 +446,18 @@ static struct s32k3xx_lpspidev_s g_lpspi4dev =
 {
   .spidev       =
   {
-    &g_spi4ops
+    .ops        = &g_spi4ops,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/sam34/sam_aes.c:
##########
@@ -59,8 +59,8 @@
  * Private Data
  ****************************************************************************/
 
-static mutex_t g_samaes_lock;
-static bool    g_samaes_initdone = false;

Review Comment:
   @xiaoxiang781216 
   Does this change (removing `= false`) relate to the global mutex/sem initialization?
   



##########
arch/arm/src/s32k3xx/s32k3xx_edma.c:
##########
@@ -459,7 +445,7 @@ static struct s32k3xx_edmatcd_s *s32k3xx_tcd_alloc(void)
    */
 
   flags = enter_critical_section();
-  s32k3xx_takedsem();
+  nxsem_wait_uninterruptible(&g_edma.dsem);

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/s32k3xx/s32k3xx_lpspi.c:
##########
@@ -387,15 +396,18 @@ static struct s32k3xx_lpspidev_s g_lpspi3dev =
 {
   .spidev       =
   {
-    &g_spi3ops
+    .ops        = &g_spi3ops,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/s32k3xx/s32k3xx_qspi.c:
##########
@@ -221,19 +221,23 @@ static const struct qspi_ops_s g_qspi0ops =
 
 static struct s32k3xx_qspidev_s g_qspi0dev =
 {
-  .qspi            =
+  .qspi              =

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/sam34/sam_spi.c:
##########
@@ -1857,12 +1859,7 @@ struct spi_dev_s *sam_spibus_initialize(int port)
       spi_getreg(spi, SAM_SPI_SR_OFFSET);
       spi_getreg(spi, SAM_SPI_RDR_OFFSET);
 
-      /* Initialize the SPI mutex that enforces mutually exclusive
-       * access to the SPI registers.
-       */
-
-      nxmutex_init(&spi->spilock);
-      spi->initialized = true;
+       spi->initialized = true;

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/sam34/sam_twi.c:
##########
@@ -725,7 +747,7 @@ static int twi_transfer(struct i2c_master_s *dev,
  ****************************************************************************/
 
 #ifdef CONFIG_I2C_RESET
-static int twi_reset(struct i2c_master_s * dev)
+static int twi_reset(struct i2c_master_s *dev)

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/sam34/sam_twi.c:
##########
@@ -917,12 +934,7 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
 #ifdef CONFIG_SAM34_TWIM1
   if (bus == 1)
     {
-      /* Set up TWI1 register base address and IRQ number */
-
-      priv       = &g_twi1;
-      priv->base = SAM_TWI1_BASE;
-      priv->irq  = SAM_IRQ_TWI1;
-      priv->twi  = 1;
+      priv = &g_twi1;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sam34/sam_twi.c:
##########
@@ -891,12 +913,7 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
 #ifdef CONFIG_SAM34_TWIM0
   if (bus == 0)
     {
-      /* Set up TWI0 register base address and IRQ number */
-
-      priv       = &g_twi0;
-      priv->base = SAM_TWI0_BASE;
-      priv->irq  = SAM_IRQ_TWI0;
-      priv->twi  = 0;
+      priv = &g_twi0;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sam34/sam_twi.c:
##########
@@ -187,14 +187,6 @@ static void twi_hw_initialize(struct twi_dev_s *priv, unsigned int pid,
  * Private Data
  ****************************************************************************/
 
-#ifdef CONFIG_SAM34_TWIM0
-static struct twi_dev_s g_twi0;
-#endif
-
-#ifdef CONFIG_SAM34_TWIM1
-static struct twi_dev_s g_twi1;
-#endif
-

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/s32k3xx/s32k3xx_lpspi.c:
##########
@@ -481,15 +496,18 @@ static struct s32k3xx_lpspidev_s g_lpspi5dev =
 {
   .spidev       =
   {
-    &g_spi5ops
+    .ops        = &g_spi5ops,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/sam34/sam_twi.c:
##########
@@ -946,15 +958,6 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
       return NULL;
     }
 
-  /* Initialize the device structure */
-
-  priv->dev.ops = &g_twiops;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_adc.c:
##########
@@ -2041,17 +2050,9 @@ struct adc_dev_s *sam_adc_initialize(void)
       /* Initialize the public ADC device data structure */
 
 #ifdef SAMA5_ADC_HAVE_CHANNELS
-      g_adcdev.ad_ops  = &g_adcops;
       priv->dev = &g_adcdev;
 #endif
 
-      g_adcdev.ad_priv = priv;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sam34/sam_twi.c:
##########
@@ -979,21 +982,16 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
  *
  ****************************************************************************/
 
-int sam_i2cbus_uninitialize(struct i2c_master_s * dev)
+int sam_i2cbus_uninitialize(struct i2c_master_s *dev)
 {
-  struct twi_dev_s *priv = (struct twi_dev_s *) dev;
+  struct twi_dev_s *priv = (struct twi_dev_s *)dev;
 

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/sama5/sam_adc.c:
##########
@@ -497,11 +497,20 @@ static const struct adc_ops_s g_adcops =
 
 /* ADC internal state */
 
-static struct sam_adc_s g_adcpriv;
+static struct sam_adc_s g_adcpriv =
+{
+  .lock        = NXMUTEX_INITIALIZER,
+};
 
 /* ADC device instance */
 
-static struct adc_dev_s g_adcdev;
+static struct adc_dev_s g_adcdev =
+{
+#ifdef SAMA5_ADC_HAVE_CHANNELS
+  .ad_ops      = &g_adcops,
+#endif
+  .ad_priv     = &g_adcpriv,
+};

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_can.c:
##########
@@ -1926,9 +1942,8 @@ struct can_dev_s *sam_caninitialize(int port)
     {
       /* Select the CAN1 device structure */
 
-      dev    = &g_can1dev;
-      priv   = &g_can1priv;
-      config = &g_can1const;
+      dev  = &g_can1dev;
+      priv = &g_can1priv;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_can.c:
##########
@@ -287,8 +287,17 @@ static const struct sam_config_s g_can0const =
   },
 };
 
-static struct sam_can_s g_can0priv;
-static struct can_dev_s g_can0dev;
+static struct sam_can_s g_can0priv =
+{
+  .config           = &g_can0const,
+  .freemb           = CAN_ALL_MAILBOXES,
+  .lock             = NXMUTEX_INITIALIZER,
+};
+static struct can_dev_s g_can0dev =
+{
+  .cd_ops           = &g_canops,
+  .cd_priv          = &g_can0priv,
+};

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_can.c:
##########
@@ -322,8 +331,17 @@ static const struct sam_config_s g_can1const =
   },
 };
 
-static struct sam_can_s g_can1priv;
-static struct can_dev_s g_can1dev;
+static struct sam_can_s g_can1priv =
+{
+  .config           = &g_can1const,
+  .freemb           = CAN_ALL_MAILBOXES,
+  .lock             = NXMUTEX_INITIALIZER,
+};
+static struct can_dev_s g_can1dev =
+{
+  .cd_ops           = &g_canops,
+  .cd_priv          = &g_can1priv,
+};

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_can.c:
##########
@@ -1943,16 +1958,8 @@ struct can_dev_s *sam_caninitialize(int port)
     {
       /* Yes, then perform one time data initialization */
 
-      memset(priv, 0, sizeof(struct sam_can_s));
-      priv->config      = config;
-      priv->freemb      = CAN_ALL_MAILBOXES;
       priv->initialized = true;
 
-      nxmutex_init(&priv->lock);
-
-      dev->cd_ops       = &g_canops;
-      dev->cd_priv      = (void *)priv;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_adc.c:
##########
@@ -2041,17 +2050,9 @@ struct adc_dev_s *sam_adc_initialize(void)
       /* Initialize the public ADC device data structure */
 
 #ifdef SAMA5_ADC_HAVE_CHANNELS
-      g_adcdev.ad_ops  = &g_adcops;
       priv->dev = &g_adcdev;
 #endif
 
-      g_adcdev.ad_priv = priv;
-
-      /* Initialize the private ADC device data structure */
-
-      nxmutex_init(&priv->lock);
-      priv->cb  = NULL;

Review Comment:
   @xiaoxiang781216 
   Does this change (removing `priv->cb = NULL`) relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_can.c:
##########
@@ -1902,7 +1920,6 @@ struct can_dev_s *sam_caninitialize(int port)
 {
   struct can_dev_s *dev;
   struct sam_can_s *priv;
-  const struct sam_config_s *config;

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_dmac.c:
##########
@@ -1334,7 +1322,7 @@ sam_allocdesc(struct sam_dmach_s *dmach, struct dma_linklist_s *prev,
        * there is at least one free descriptor in the table and it is ours.
        */
 
-      ret = sam_takedsem(dmac);
+      ret = nxsem_wait_uninterruptible(&dmac->dsem);

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_can.c:
##########
@@ -1915,9 +1932,8 @@ struct can_dev_s *sam_caninitialize(int port)
     {
       /* Select the CAN0 device structure */
 
-      dev    = &g_can0dev;
-      priv   = &g_can0priv;
-      config = &g_can0const;
+      dev  = &g_can0dev;
+      priv = &g_can0priv;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_can.c:
##########
@@ -1943,16 +1958,8 @@ struct can_dev_s *sam_caninitialize(int port)
     {
       /* Yes, then perform one time data initialization */
 
-      memset(priv, 0, sizeof(struct sam_can_s));
-      priv->config      = config;
-      priv->freemb      = CAN_ALL_MAILBOXES;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_ehci.c:
##########
@@ -5044,7 +5043,6 @@ struct usbhost_connection_s *sam_ehci_initialize(int controller)
    * Head (g_intrhead).
    */
 
-  memset(&g_intrhead, 0, sizeof(struct sam_qh_s));

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_dmac.c:
##########
@@ -1471,7 +1459,7 @@ static void sam_freelinklist(struct sam_dmach_s *dmach)
        */
 
       memset(desc, 0, sizeof(struct dma_linklist_s));
-      sam_givedsem(dmac);
+      nxsem_post(&dmac->dsem);

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_dmac.c:
##########
@@ -463,24 +469,6 @@ static struct sam_dmac_s g_dmac1 =
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: sam_takedsem() and sam_givedsem()
- *
- * Description:
- *   Used to wait for availability of descriptors in the descriptor table.
- *
- ****************************************************************************/
-
-static int sam_takedsem(struct sam_dmac_s *dmac)
-{
-  return nxsem_wait_uninterruptible(&dmac->dsem);
-}
-
-static inline void sam_givedsem(struct sam_dmac_s *dmac)
-{
-  nxsem_post(&dmac->dsem);
-}
-

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_ehci.c:
##########
@@ -5020,7 +5020,6 @@ struct usbhost_connection_s *sam_ehci_initialize(int controller)
    *  first port is reset (and enabled)."
    */
 
-  memset(&g_asynchead, 0, sizeof(struct sam_qh_s));

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_dmac.c:
##########
@@ -1349,7 +1337,7 @@ sam_allocdesc(struct sam_dmach_s *dmach, struct dma_linklist_s *prev,
       ret = nxmutex_lock(&dmac->chlock);
       if (ret < 0)
         {
-          sam_givedsem(dmac);
+          nxsem_post(&dmac->dsem);

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_ehci.c:
##########
@@ -435,11 +435,20 @@ static int sam_reset(void);
  * global instance.
  */
 
-static struct sam_ehci_s g_ehci;
+static struct sam_ehci_s g_ehci =
+{
+  .lock = NXMUTEX_INITIALIZER,
+  .pscsem = SEM_INITIALIZER(0),
+  .ep0.iocsem = SEM_INITIALIZER(1),
+};
 
 /* This is the connection/enumeration interface */
 
-static struct usbhost_connection_s g_ehciconn;
+static struct usbhost_connection_s g_ehciconn =
+{
+  .wait = sam_wait,
+  .enumerate = sam_enumerate,
+};

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_ehci.c:
##########
@@ -5181,10 +5179,6 @@ struct usbhost_connection_s *sam_ehci_initialize(int controller)
   up_enable_irq(SAM_IRQ_UHPHS); /* enable USB interrupt */
   usbhost_vtrace1(EHCI_VTRACE1_INIITIALIZED, 0);
 
-  /* Initialize and return the connection interface */
-
-  g_ehciconn.wait      = sam_wait;
-  g_ehciconn.enumerate = sam_enumerate;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_hsmci.c:
##########
@@ -596,57 +596,145 @@ static void sam_callback(void *arg);
  * Private Data
  ****************************************************************************/
 
-/* Callbacks */
+/* Pre-allocate memory for each HSMCI device */
 
-static const struct sdio_dev_s g_callbacks =
+#ifdef CONFIG_SAMA5_HSMCI0
+static struct sam_dev_s g_hsmci0 =
 {
-  .reset            = sam_reset,
-  .capabilities     = sam_capabilities,
-  .status           = sam_status,
-  .widebus          = sam_widebus,
-  .clock            = sam_clock,
-  .attach           = sam_attach,
-  .sendcmd          = sam_sendcmd,
-  .blocksetup       = sam_blocksetup,
-  .recvsetup        = sam_recvsetup,
-  .sendsetup        = sam_sendsetup,
-  .cancel           = sam_cancel,
-  .waitresponse     = sam_waitresponse,
-  .recv_r1          = sam_recvshort,
-  .recv_r2          = sam_recvlong,
-  .recv_r3          = sam_recvshort,
-  .recv_r4          = sam_recvnotimpl,
-  .recv_r5          = sam_recvnotimpl,
-  .recv_r6          = sam_recvshort,
-  .recv_r7          = sam_recvshort,
-  .waitenable       = sam_waitenable,
-  .eventwait        = sam_eventwait,
-  .callbackenable   = sam_callbackenable,
-  .registercallback = sam_registercallback,
+  .dev                =
+  {
+    .reset            = sam_reset,
+    .capabilities     = sam_capabilities,
+    .status           = sam_status,
+    .widebus          = sam_widebus,
+    .clock            = sam_clock,
+    .attach           = sam_attach,
+    .sendcmd          = sam_sendcmd,
+    .blocksetup       = sam_blocksetup,
+    .recvsetup        = sam_recvsetup,
+    .sendsetup        = sam_sendsetup,
+    .cancel           = sam_cancel,
+    .waitresponse     = sam_waitresponse,
+    .recv_r1          = sam_recvshort,
+    .recv_r2          = sam_recvlong,
+    .recv_r3          = sam_recvshort,
+    .recv_r4          = sam_recvnotimpl,
+    .recv_r5          = sam_recvnotimpl,
+    .recv_r6          = sam_recvshort,
+    .recv_r7          = sam_recvshort,
+    .waitenable       = sam_waitenable,
+    .eventwait        = sam_eventwait,
+    .callbackenable   = sam_callbackenable,
+    .registercallback = sam_registercallback,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/sama5/sam_hsmci.c:
##########
@@ -596,57 +596,145 @@ static void sam_callback(void *arg);
  * Private Data
  ****************************************************************************/
 
-/* Callbacks */
+/* Pre-allocate memory for each HSMCI device */
 
-static const struct sdio_dev_s g_callbacks =
+#ifdef CONFIG_SAMA5_HSMCI0
+static struct sam_dev_s g_hsmci0 =
 {
-  .reset            = sam_reset,
-  .capabilities     = sam_capabilities,
-  .status           = sam_status,
-  .widebus          = sam_widebus,
-  .clock            = sam_clock,
-  .attach           = sam_attach,
-  .sendcmd          = sam_sendcmd,
-  .blocksetup       = sam_blocksetup,
-  .recvsetup        = sam_recvsetup,
-  .sendsetup        = sam_sendsetup,
-  .cancel           = sam_cancel,
-  .waitresponse     = sam_waitresponse,
-  .recv_r1          = sam_recvshort,
-  .recv_r2          = sam_recvlong,
-  .recv_r3          = sam_recvshort,
-  .recv_r4          = sam_recvnotimpl,
-  .recv_r5          = sam_recvnotimpl,
-  .recv_r6          = sam_recvshort,
-  .recv_r7          = sam_recvshort,
-  .waitenable       = sam_waitenable,
-  .eventwait        = sam_eventwait,
-  .callbackenable   = sam_callbackenable,
-  .registercallback = sam_registercallback,
+  .dev                =
+  {
+    .reset            = sam_reset,
+    .capabilities     = sam_capabilities,
+    .status           = sam_status,
+    .widebus          = sam_widebus,
+    .clock            = sam_clock,
+    .attach           = sam_attach,
+    .sendcmd          = sam_sendcmd,
+    .blocksetup       = sam_blocksetup,
+    .recvsetup        = sam_recvsetup,
+    .sendsetup        = sam_sendsetup,
+    .cancel           = sam_cancel,
+    .waitresponse     = sam_waitresponse,
+    .recv_r1          = sam_recvshort,
+    .recv_r2          = sam_recvlong,
+    .recv_r3          = sam_recvshort,
+    .recv_r4          = sam_recvnotimpl,
+    .recv_r5          = sam_recvnotimpl,
+    .recv_r6          = sam_recvshort,
+    .recv_r7          = sam_recvshort,
+    .waitenable       = sam_waitenable,
+    .eventwait        = sam_eventwait,
+    .callbackenable   = sam_callbackenable,
+    .registercallback = sam_registercallback,
 #ifdef CONFIG_SDIO_DMA
 #ifndef HSCMI_NORXDMA
-  .dmarecvsetup     = sam_dmarecvsetup,
+    .dmarecvsetup     = sam_dmarecvsetup,
 #else
-  .dmarecvsetup     = sam_recvsetup,
+    .dmarecvsetup     = sam_recvsetup,
 #endif
 #ifndef HSCMI_NOTXDMA
-  .dmasendsetup     = sam_dmasendsetup,
+    .dmasendsetup     = sam_dmasendsetup,
 #else
-  .dmasendsetup     = sam_sendsetup,
+    .dmasendsetup     = sam_sendsetup,
 #endif
 #endif
+  },
+  .waitsem            = SEM_INITIALIZER(0),
+  .base               = SAM_HSMCI0_VBASE,
+  .hsmci              = 0,

Review Comment:
   @xiaoxiang781216 
   Do these changes (adding `.base` and `.hsmci`) relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_hsmci.c:
##########
@@ -596,57 +596,145 @@ static void sam_callback(void *arg);
  * Private Data
  ****************************************************************************/
 
-/* Callbacks */
+/* Pre-allocate memory for each HSMCI device */
 
-static const struct sdio_dev_s g_callbacks =
+#ifdef CONFIG_SAMA5_HSMCI0
+static struct sam_dev_s g_hsmci0 =
 {
-  .reset            = sam_reset,
-  .capabilities     = sam_capabilities,
-  .status           = sam_status,
-  .widebus          = sam_widebus,
-  .clock            = sam_clock,
-  .attach           = sam_attach,
-  .sendcmd          = sam_sendcmd,
-  .blocksetup       = sam_blocksetup,
-  .recvsetup        = sam_recvsetup,
-  .sendsetup        = sam_sendsetup,
-  .cancel           = sam_cancel,
-  .waitresponse     = sam_waitresponse,
-  .recv_r1          = sam_recvshort,
-  .recv_r2          = sam_recvlong,
-  .recv_r3          = sam_recvshort,
-  .recv_r4          = sam_recvnotimpl,
-  .recv_r5          = sam_recvnotimpl,
-  .recv_r6          = sam_recvshort,
-  .recv_r7          = sam_recvshort,
-  .waitenable       = sam_waitenable,
-  .eventwait        = sam_eventwait,
-  .callbackenable   = sam_callbackenable,
-  .registercallback = sam_registercallback,
+  .dev                =
+  {
+    .reset            = sam_reset,
+    .capabilities     = sam_capabilities,
+    .status           = sam_status,
+    .widebus          = sam_widebus,
+    .clock            = sam_clock,
+    .attach           = sam_attach,
+    .sendcmd          = sam_sendcmd,
+    .blocksetup       = sam_blocksetup,
+    .recvsetup        = sam_recvsetup,
+    .sendsetup        = sam_sendsetup,
+    .cancel           = sam_cancel,
+    .waitresponse     = sam_waitresponse,
+    .recv_r1          = sam_recvshort,
+    .recv_r2          = sam_recvlong,
+    .recv_r3          = sam_recvshort,
+    .recv_r4          = sam_recvnotimpl,
+    .recv_r5          = sam_recvnotimpl,
+    .recv_r6          = sam_recvshort,
+    .recv_r7          = sam_recvshort,
+    .waitenable       = sam_waitenable,
+    .eventwait        = sam_eventwait,
+    .callbackenable   = sam_callbackenable,
+    .registercallback = sam_registercallback,
 #ifdef CONFIG_SDIO_DMA
 #ifndef HSCMI_NORXDMA
-  .dmarecvsetup     = sam_dmarecvsetup,
+    .dmarecvsetup     = sam_dmarecvsetup,
 #else
-  .dmarecvsetup     = sam_recvsetup,
+    .dmarecvsetup     = sam_recvsetup,
 #endif
 #ifndef HSCMI_NOTXDMA
-  .dmasendsetup     = sam_dmasendsetup,
+    .dmasendsetup     = sam_dmasendsetup,
 #else
-  .dmasendsetup     = sam_sendsetup,
+    .dmasendsetup     = sam_sendsetup,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style changes to the 3rd commit.
   



##########
arch/arm/src/sama5/sam_hsmci.c:
##########
@@ -596,57 +596,145 @@ static void sam_callback(void *arg);
  * Private Data
  ****************************************************************************/
 
-/* Callbacks */
+/* Pre-allocate memory for each HSMCI device */
 
-static const struct sdio_dev_s g_callbacks =
+#ifdef CONFIG_SAMA5_HSMCI0
+static struct sam_dev_s g_hsmci0 =
 {
-  .reset            = sam_reset,
-  .capabilities     = sam_capabilities,
-  .status           = sam_status,
-  .widebus          = sam_widebus,
-  .clock            = sam_clock,
-  .attach           = sam_attach,
-  .sendcmd          = sam_sendcmd,
-  .blocksetup       = sam_blocksetup,
-  .recvsetup        = sam_recvsetup,
-  .sendsetup        = sam_sendsetup,
-  .cancel           = sam_cancel,
-  .waitresponse     = sam_waitresponse,
-  .recv_r1          = sam_recvshort,
-  .recv_r2          = sam_recvlong,
-  .recv_r3          = sam_recvshort,
-  .recv_r4          = sam_recvnotimpl,
-  .recv_r5          = sam_recvnotimpl,
-  .recv_r6          = sam_recvshort,
-  .recv_r7          = sam_recvshort,
-  .waitenable       = sam_waitenable,
-  .eventwait        = sam_eventwait,
-  .callbackenable   = sam_callbackenable,
-  .registercallback = sam_registercallback,
+  .dev                =
+  {
+    .reset            = sam_reset,
+    .capabilities     = sam_capabilities,
+    .status           = sam_status,
+    .widebus          = sam_widebus,
+    .clock            = sam_clock,
+    .attach           = sam_attach,
+    .sendcmd          = sam_sendcmd,
+    .blocksetup       = sam_blocksetup,
+    .recvsetup        = sam_recvsetup,
+    .sendsetup        = sam_sendsetup,
+    .cancel           = sam_cancel,
+    .waitresponse     = sam_waitresponse,
+    .recv_r1          = sam_recvshort,
+    .recv_r2          = sam_recvlong,
+    .recv_r3          = sam_recvshort,
+    .recv_r4          = sam_recvnotimpl,
+    .recv_r5          = sam_recvnotimpl,
+    .recv_r6          = sam_recvshort,
+    .recv_r7          = sam_recvshort,
+    .waitenable       = sam_waitenable,
+    .eventwait        = sam_eventwait,
+    .callbackenable   = sam_callbackenable,
+    .registercallback = sam_registercallback,
 #ifdef CONFIG_SDIO_DMA
 #ifndef HSCMI_NORXDMA
-  .dmarecvsetup     = sam_dmarecvsetup,
+    .dmarecvsetup     = sam_dmarecvsetup,
 #else
-  .dmarecvsetup     = sam_recvsetup,
+    .dmarecvsetup     = sam_recvsetup,
 #endif
 #ifndef HSCMI_NOTXDMA
-  .dmasendsetup     = sam_dmasendsetup,
+    .dmasendsetup     = sam_dmasendsetup,
 #else
-  .dmasendsetup     = sam_sendsetup,
+    .dmasendsetup     = sam_sendsetup,
 #endif
 #endif
+  },
+  .waitsem            = SEM_INITIALIZER(0),
+  .base               = SAM_HSMCI0_VBASE,
+  .hsmci              = 0,
 };
-
-/* Pre-allocate memory for each HSMCI device */
-
-#ifdef CONFIG_SAMA5_HSMCI0
-static struct sam_dev_s g_hsmci0;
 #endif
 #ifdef CONFIG_SAMA5_HSMCI1
-static struct sam_dev_s g_hsmci1;
+static struct sam_dev_s g_hsmci1 =
+{
+  .dev                =
+  {
+    .reset            = sam_reset,
+    .capabilities     = sam_capabilities,
+    .status           = sam_status,
+    .widebus          = sam_widebus,
+    .clock            = sam_clock,
+    .attach           = sam_attach,
+    .sendcmd          = sam_sendcmd,
+    .blocksetup       = sam_blocksetup,
+    .recvsetup        = sam_recvsetup,
+    .sendsetup        = sam_sendsetup,
+    .cancel           = sam_cancel,
+    .waitresponse     = sam_waitresponse,
+    .recv_r1          = sam_recvshort,
+    .recv_r2          = sam_recvlong,
+    .recv_r3          = sam_recvshort,
+    .recv_r4          = sam_recvnotimpl,
+    .recv_r5          = sam_recvnotimpl,
+    .recv_r6          = sam_recvshort,
+    .recv_r7          = sam_recvshort,
+    .waitenable       = sam_waitenable,
+    .eventwait        = sam_eventwait,
+    .callbackenable   = sam_callbackenable,
+    .registercallback = sam_registercallback,
+#ifdef CONFIG_SDIO_DMA
+#ifndef HSCMI_NORXDMA
+    .dmarecvsetup     = sam_dmarecvsetup,
+#else
+    .dmarecvsetup     = sam_recvsetup,
+#endif
+#ifndef HSCMI_NOTXDMA
+    .dmasendsetup     = sam_dmasendsetup,
+#else
+    .dmasendsetup     = sam_sendsetup,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_hsmci.c:
##########
@@ -3232,11 +3315,6 @@ struct sdio_dev_s *sdio_initialize(int slotno)
 
       priv = &g_hsmci1;
 
-      /* HSMCI1 Initialization */
-
-      priv->base  = SAM_HSMCI1_VBASE;
-      priv->hsmci = 1;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_hsmci.c:
##########
@@ -596,57 +596,145 @@ static void sam_callback(void *arg);
  * Private Data
  ****************************************************************************/
 
-/* Callbacks */
+/* Pre-allocate memory for each HSMCI device */
 
-static const struct sdio_dev_s g_callbacks =
+#ifdef CONFIG_SAMA5_HSMCI0
+static struct sam_dev_s g_hsmci0 =
 {
-  .reset            = sam_reset,
-  .capabilities     = sam_capabilities,
-  .status           = sam_status,
-  .widebus          = sam_widebus,
-  .clock            = sam_clock,
-  .attach           = sam_attach,
-  .sendcmd          = sam_sendcmd,
-  .blocksetup       = sam_blocksetup,
-  .recvsetup        = sam_recvsetup,
-  .sendsetup        = sam_sendsetup,
-  .cancel           = sam_cancel,
-  .waitresponse     = sam_waitresponse,
-  .recv_r1          = sam_recvshort,
-  .recv_r2          = sam_recvlong,
-  .recv_r3          = sam_recvshort,
-  .recv_r4          = sam_recvnotimpl,
-  .recv_r5          = sam_recvnotimpl,
-  .recv_r6          = sam_recvshort,
-  .recv_r7          = sam_recvshort,
-  .waitenable       = sam_waitenable,
-  .eventwait        = sam_eventwait,
-  .callbackenable   = sam_callbackenable,
-  .registercallback = sam_registercallback,
+  .dev                =
+  {
+    .reset            = sam_reset,
+    .capabilities     = sam_capabilities,
+    .status           = sam_status,
+    .widebus          = sam_widebus,
+    .clock            = sam_clock,
+    .attach           = sam_attach,
+    .sendcmd          = sam_sendcmd,
+    .blocksetup       = sam_blocksetup,
+    .recvsetup        = sam_recvsetup,
+    .sendsetup        = sam_sendsetup,
+    .cancel           = sam_cancel,
+    .waitresponse     = sam_waitresponse,
+    .recv_r1          = sam_recvshort,
+    .recv_r2          = sam_recvlong,
+    .recv_r3          = sam_recvshort,
+    .recv_r4          = sam_recvnotimpl,
+    .recv_r5          = sam_recvnotimpl,
+    .recv_r6          = sam_recvshort,
+    .recv_r7          = sam_recvshort,
+    .waitenable       = sam_waitenable,
+    .eventwait        = sam_eventwait,
+    .callbackenable   = sam_callbackenable,
+    .registercallback = sam_registercallback,
 #ifdef CONFIG_SDIO_DMA
 #ifndef HSCMI_NORXDMA
-  .dmarecvsetup     = sam_dmarecvsetup,
+    .dmarecvsetup     = sam_dmarecvsetup,
 #else
-  .dmarecvsetup     = sam_recvsetup,
+    .dmarecvsetup     = sam_recvsetup,
 #endif
 #ifndef HSCMI_NOTXDMA
-  .dmasendsetup     = sam_dmasendsetup,
+    .dmasendsetup     = sam_dmasendsetup,
 #else
-  .dmasendsetup     = sam_sendsetup,
+    .dmasendsetup     = sam_sendsetup,
 #endif
 #endif
+  },
+  .waitsem            = SEM_INITIALIZER(0),
+  .base               = SAM_HSMCI0_VBASE,
+  .hsmci              = 0,
 };
-
-/* Pre-allocate memory for each HSMCI device */
-
-#ifdef CONFIG_SAMA5_HSMCI0
-static struct sam_dev_s g_hsmci0;
 #endif
 #ifdef CONFIG_SAMA5_HSMCI1
-static struct sam_dev_s g_hsmci1;
+static struct sam_dev_s g_hsmci1 =
+{
+  .dev                =
+  {
+    .reset            = sam_reset,
+    .capabilities     = sam_capabilities,
+    .status           = sam_status,
+    .widebus          = sam_widebus,
+    .clock            = sam_clock,
+    .attach           = sam_attach,
+    .sendcmd          = sam_sendcmd,
+    .blocksetup       = sam_blocksetup,
+    .recvsetup        = sam_recvsetup,
+    .sendsetup        = sam_sendsetup,
+    .cancel           = sam_cancel,
+    .waitresponse     = sam_waitresponse,
+    .recv_r1          = sam_recvshort,
+    .recv_r2          = sam_recvlong,
+    .recv_r3          = sam_recvshort,
+    .recv_r4          = sam_recvnotimpl,
+    .recv_r5          = sam_recvnotimpl,
+    .recv_r6          = sam_recvshort,
+    .recv_r7          = sam_recvshort,
+    .waitenable       = sam_waitenable,
+    .eventwait        = sam_eventwait,
+    .callbackenable   = sam_callbackenable,
+    .registercallback = sam_registercallback,
+#ifdef CONFIG_SDIO_DMA
+#ifndef HSCMI_NORXDMA
+    .dmarecvsetup     = sam_dmarecvsetup,
+#else
+    .dmarecvsetup     = sam_recvsetup,
+#endif
+#ifndef HSCMI_NOTXDMA
+    .dmasendsetup     = sam_dmasendsetup,
+#else
+    .dmasendsetup     = sam_sendsetup,
+#endif
+#endif
+  },
+  .waitsem            = SEM_INITIALIZER(0),
+  .base               = SAM_HSMCI0_VBASE,
+  .hsmci              = 0,
+};
 #endif
 #ifdef CONFIG_SAMA5_HSMCI2
-static struct sam_dev_s g_hsmci2;
+static struct sam_dev_s g_hsmci2 =
+{
+  .dev                =
+  {
+    .reset            = sam_reset,
+    .capabilities     = sam_capabilities,
+    .status           = sam_status,
+    .widebus          = sam_widebus,
+    .clock            = sam_clock,
+    .attach           = sam_attach,
+    .sendcmd          = sam_sendcmd,
+    .blocksetup       = sam_blocksetup,
+    .recvsetup        = sam_recvsetup,
+    .sendsetup        = sam_sendsetup,
+    .cancel           = sam_cancel,
+    .waitresponse     = sam_waitresponse,
+    .recv_r1          = sam_recvshort,
+    .recv_r2          = sam_recvlong,
+    .recv_r3          = sam_recvshort,
+    .recv_r4          = sam_recvnotimpl,
+    .recv_r5          = sam_recvnotimpl,
+    .recv_r6          = sam_recvshort,
+    .recv_r7          = sam_recvshort,
+    .waitenable       = sam_waitenable,
+    .eventwait        = sam_eventwait,
+    .callbackenable   = sam_callbackenable,
+    .registercallback = sam_registercallback,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_ohci.c:
##########
@@ -4202,10 +4201,6 @@ struct usbhost_connection_s *sam_ohci_initialize(int controller)
 
   usbhost_vtrace1(OHCI_VTRACE1_INITIALIZED, 0);
 
-  /* Initialize and return the connection interface */
-
-  g_ohciconn.wait      = sam_wait;
-  g_ohciconn.enumerate = sam_enumerate;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_hsmci.c:
##########
@@ -3312,16 +3385,6 @@ struct sdio_dev_s *sdio_initialize(int slotno)
          " hsmci: %d dmac: %d pid: %" PRId32 "\n",
          priv, priv->base, priv->hsmci, dmac, pid);
 
-  /* Initialize the HSMCI slot structure */
-
-  /* Initialize semaphores */
-
-  nxsem_init(&priv->waitsem, 0, 0);
-
-  /* Initialize the callbacks */
-
-  memcpy(&priv->dev, &g_callbacks, sizeof(struct sdio_dev_s));

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_ohci.c:
##########
@@ -4023,10 +4026,6 @@ struct usbhost_connection_s *sam_ohci_initialize(int controller)
 
   usbhost_vtrace1(OHCI_VTRACE1_INITIALIZING, 0);
 
-  /* Initialize all the HCCA to 0 */
-
-  memset((void *)&g_hcca, 0, sizeof(struct ohci_hcca_s));

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_hsmci.c:
##########
@@ -3193,11 +3281,6 @@ struct sdio_dev_s *sdio_initialize(int slotno)
 
       priv = &g_hsmci0;
 
-      /* HSMCI0 Initialization */
-
-      priv->base  = SAM_HSMCI0_VBASE;
-      priv->hsmci = 0;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -98,10 +98,7 @@ struct sam_chconfig_s
 
 struct sam_tcconfig_s
 {
-  uintptr_t base;          /* TC register base address */
-  uint8_t pid;             /* Peripheral ID */
   uint8_t chfirst;         /* First channel number */
-  uint8_t tc;              /* Timer/counter number */

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_hsmci.c:
##########
@@ -3271,11 +3349,6 @@ struct sdio_dev_s *sdio_initialize(int slotno)
 
       priv = &g_hsmci2;
 
-      /* HSMCI2 Initialization */
-
-      priv->base  = SAM_HSMCI2_VBASE;
-      priv->hsmci = 2;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_ohci.c:
##########
@@ -3110,7 +3118,7 @@ static int sam_ctrlin(struct usbhost_driver_s *drvr, usbhost_ep_t ep0,
   struct sam_rhport_s *rhport = (struct sam_rhport_s *)drvr;
   struct sam_eplist_s *eplist = (struct sam_eplist_s *)ep0;
   uint16_t len;
-  int  ret;
+  int ret;

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -201,10 +198,7 @@ static inline struct sam_chan_s *sam_tc_initialize(int channel);
 #ifdef CONFIG_SAMA5_TC0
 static const struct sam_tcconfig_s g_tc012config =
 {
-  .base    = SAM_TC012_VBASE,
-  .pid     = SAM_PID_TC0,
   .chfirst = 0,
-  .tc      = 0,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?



##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -271,10 +265,7 @@ static const struct sam_tcconfig_s g_tc012config =
 #ifdef CONFIG_SAMA5_TC1
 static const struct sam_tcconfig_s g_tc345config =
 {
-  .base    = SAM_TC345_VBASE,
-  .pid     = SAM_PID_TC1,
   .chfirst = 3,
-  .tc      = 1,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -341,10 +332,7 @@ static const struct sam_tcconfig_s g_tc345config =
 #ifdef CONFIG_SAMA5_TC2
 static const struct sam_tcconfig_s g_tc678config =
 {
-  .base    = SAM_TC678_VBASE,
-  .pid     = SAM_PID_TC2,
   .chfirst = 6,
-  .tc      = 2,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -411,15 +399,33 @@ static const struct sam_tcconfig_s g_tc678config =
 /* Timer/counter state */
 
 #ifdef CONFIG_SAMA5_TC0
-static struct sam_tc_s g_tc012;
+static struct sam_tc_s g_tc012 =
+{
+  .lock = NXMUTEX_INITIALIZER,
+  .base = SAM_TC012_VBASE,
+  .pid  = SAM_PID_TC0,
+  .tc   = 0,
+};

Review Comment:
   @xiaoxiang781216 
   Do these changes except for `.lock` relate to the global mutex/sem initialization?
    



##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -411,15 +399,33 @@ static const struct sam_tcconfig_s g_tc678config =
 /* Timer/counter state */
 
 #ifdef CONFIG_SAMA5_TC0
-static struct sam_tc_s g_tc012;
+static struct sam_tc_s g_tc012 =
+{
+  .lock = NXMUTEX_INITIALIZER,
+  .base = SAM_TC012_VBASE,
+  .pid  = SAM_PID_TC0,
+  .tc   = 0,
+};
 #endif
 
 #ifdef CONFIG_SAMA5_TC1
-static struct sam_tc_s g_tc345;
+static struct sam_tc_s g_tc345 =
+{
+  .lock = NXMUTEX_INITIALIZER,
+  .base = SAM_TC345_VBASE,
+  .pid  = SAM_PID_TC1,
+  .tc   = 1,
+};

Review Comment:
   @xiaoxiang781216 
   Do these changes except for .lock relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_trng.c:
##########
@@ -333,15 +337,6 @@ static int sam_rng_initialize(void)
 
   finfo("Initializing TRNG hardware\n");
 
-  /* Initialize the device structure */
-
-  memset(&g_trngdev, 0, sizeof(struct trng_dev_s));

Review Comment:
   @xiaoxiang781216 
   Does this chang relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -954,19 +960,11 @@ static inline struct sam_chan_s *sam_tc_initialize(int channel)
   flags = enter_critical_section();
   if (!tc->initialized)
     {
-      /* Initialize the timer counter data structure. */
-
-      memset(tc, 0, sizeof(struct sam_tc_s));
-      nxmutex_init(&tc->lock);
-      tc->base = tcconfig->base;
-      tc->tc   = channel < 3 ? 0 : 1;
-      tc->pid  = tcconfig->pid;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -1008,7 +1006,7 @@ static inline struct sam_chan_s *sam_tc_initialize(int channel)
 
       /* Set the maximum TC peripheral clock frequency */
 
-      regval  = PMC_PCR_PID(tcconfig->pid) | PMC_PCR_CMD | PMC_PCR_EN;
+      regval  = PMC_PCR_PID(tc->pid) | PMC_PCR_CMD | PMC_PCR_EN;

Review Comment:
   @xiaoxiang781216 
   Does this chang relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -954,19 +960,11 @@ static inline struct sam_chan_s *sam_tc_initialize(int channel)
   flags = enter_critical_section();
   if (!tc->initialized)
     {
-      /* Initialize the timer counter data structure. */
-
-      memset(tc, 0, sizeof(struct sam_tc_s));
-      nxmutex_init(&tc->lock);
-      tc->base = tcconfig->base;
-      tc->tc   = channel < 3 ? 0 : 1;
-      tc->pid  = tcconfig->pid;
-
       /* Initialize the channels */
 
       for (i = 0, ch = tcconfig->chfirst; i < SAM_TC_NCHANNELS; i++)
         {
-          tmrerr("ERROR: Initializing TC%d channel %d\n", tcconfig->tc, ch);
+          tmrerr("ERROR: Initializing TC%d channel %d\n", tc->tc, ch);

Review Comment:
   @xiaoxiang781216 
   Does this chang relate to the global mutex/sem initialization?



##########
arch/arm/src/sama5/sam_tsd.c:
##########
@@ -245,7 +245,12 @@ static const struct file_operations g_tsdops =
 
 /* The driver state structure is pre-allocated. */
 
-static struct sam_tsd_s g_tsd;
+static struct sam_tsd_s g_tsd =
+{
+  .threshx = INVALID_THRESHOLD,
+  .threshy = INVALID_THRESHOLD,
+  .waitsem = SEM_INITIALIZER(0),

Review Comment:
   @xiaoxiang781216 
   Do these changes except for .waitsem relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -411,15 +399,33 @@ static const struct sam_tcconfig_s g_tc678config =
 /* Timer/counter state */
 
 #ifdef CONFIG_SAMA5_TC0
-static struct sam_tc_s g_tc012;
+static struct sam_tc_s g_tc012 =
+{
+  .lock = NXMUTEX_INITIALIZER,
+  .base = SAM_TC012_VBASE,
+  .pid  = SAM_PID_TC0,
+  .tc   = 0,
+};
 #endif
 
 #ifdef CONFIG_SAMA5_TC1
-static struct sam_tc_s g_tc345;
+static struct sam_tc_s g_tc345 =
+{
+  .lock = NXMUTEX_INITIALIZER,
+  .base = SAM_TC345_VBASE,
+  .pid  = SAM_PID_TC1,
+  .tc   = 1,
+};
 #endif
 
 #ifdef CONFIG_SAMA5_TC2
-static struct sam_tc_s g_tc678;
+static struct sam_tc_s g_tc678 =
+{
+  .lock = NXMUTEX_INITIALIZER,
+  .base = SAM_TC678_VBASE,
+  .pid  = SAM_PID_TC2,
+  .tc   = 2,
+};

Review Comment:
   @xiaoxiang781216 
   Do these changes except for .lock relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -1020,7 +1018,7 @@ static inline struct sam_chan_s *sam_tc_initialize(int channel)
 
       /* Enable clocking to the timer counter */
 
-      sam_enableperiph0(tcconfig->pid);
+      sam_enableperiph0(tc->pid);

Review Comment:
   Does this chang relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_tsd.c:
##########
@@ -1650,11 +1655,7 @@ int sam_tsd_register(struct sam_adc_s *adc, int minor)
 
   /* Initialize the touchscreen device driver instance */
 
-  memset(priv, 0, sizeof(struct sam_tsd_s));
-  priv->adc     = adc;               /* Save the ADC device handle */
-  priv->threshx = INVALID_THRESHOLD; /* Initialize thresholding logic */
-  priv->threshy = INVALID_THRESHOLD; /* Initialize thresholding logic */

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_tsd.c:
##########
@@ -1665,18 +1666,14 @@ int sam_tsd_register(struct sam_adc_s *adc, int minor)
   if (ret < 0)
     {
       ierr("ERROR: register_driver() failed: %d\n", ret);
-      goto errout_with_priv;
+      return ret;

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -1177,55 +1213,39 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
 #ifdef CONFIG_SAMA5_TWI0
   if (bus == 0)
     {
-      /* Select up TWI0 and setup invariant attributes */
-
-      priv       = &g_twi0;
-      priv->attr = &g_twi0attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI0 and the (initial) TWI frequency */
 
+      priv      = &g_twi0;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -229,6 +229,14 @@ static void twi_hw_initialize(struct twi_dev_s *priv, uint32_t frequency);
  * Private Data
  ****************************************************************************/
 
+static const struct i2c_ops_s g_twiops =
+{
+  .transfer = twi_transfer
+#ifdef CONFIG_I2C_RESET
+  , .reset  = twi_reset
+#endif
+};
+

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -1177,55 +1213,39 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
 #ifdef CONFIG_SAMA5_TWI0
   if (bus == 0)
     {
-      /* Select up TWI0 and setup invariant attributes */
-
-      priv       = &g_twi0;
-      priv->attr = &g_twi0attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI0 and the (initial) TWI frequency */
 
+      priv      = &g_twi0;
       frequency = CONFIG_SAMA5_TWI0_FREQUENCY;
     }
   else
 #endif
 #ifdef CONFIG_SAMA5_TWI1
   if (bus == 1)
     {
-      /* Select up TWI1 and setup invariant attributes */
-
-      priv       = &g_twi1;
-      priv->attr = &g_twi1attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI1 and the (initial) TWI frequency */
 
+      priv      = &g_twi1;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -254,7 +271,16 @@ static const struct twi_attr_s g_twi1attr =
   .base    = SAM_TWI1_VBASE,
 };
 
-static struct twi_dev_s g_twi1;
+static struct twi_dev_s g_twi1 =
+{
+  .dev     =
+  {
+    .ops   = &g_twiops,
+  },
+  .attr    = &g_twi1attr,

Review Comment:
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -268,7 +294,16 @@ static const struct twi_attr_s g_twi2attr =
   .base    = SAM_TWI2_VBASE,
 };
 
-static struct twi_dev_s g_twi2;
+static struct twi_dev_s g_twi2 =
+{
+  .dev     =
+  {
+    .ops   = &g_twiops,
+  },
+  .attr    = &g_twi2attr,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -1177,55 +1213,39 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
 #ifdef CONFIG_SAMA5_TWI0
   if (bus == 0)
     {
-      /* Select up TWI0 and setup invariant attributes */
-
-      priv       = &g_twi0;
-      priv->attr = &g_twi0attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI0 and the (initial) TWI frequency */
 
+      priv      = &g_twi0;
       frequency = CONFIG_SAMA5_TWI0_FREQUENCY;
     }
   else
 #endif
 #ifdef CONFIG_SAMA5_TWI1
   if (bus == 1)
     {
-      /* Select up TWI1 and setup invariant attributes */
-
-      priv       = &g_twi1;
-      priv->attr = &g_twi1attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI1 and the (initial) TWI frequency */
 
+      priv      = &g_twi1;
       frequency = CONFIG_SAMA5_TWI1_FREQUENCY;
     }
   else
 #endif
 #ifdef CONFIG_SAMA5_TWI2
   if (bus == 2)
     {
-      /* Select up TWI2 and setup invariant attributes */
-
-      priv       = &g_twi2;
-      priv->attr = &g_twi2attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI2 and the (initial) TWI frequency */
 
+      priv      = &g_twi2;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -282,16 +317,17 @@ static const struct twi_attr_s g_twi3attr =
   .base    = SAM_TWI3_VBASE,
 };
 
-static struct twi_dev_s g_twi3;
-#endif
-
-static const struct i2c_ops_s g_twiops =
+static struct twi_dev_s g_twi3 =
 {
-  .transfer = twi_transfer
-#ifdef CONFIG_I2C_RESET
-  , .reset  = twi_reset
-#endif
+  .dev     =
+  {
+    .ops   = &g_twiops,
+  },
+  .attr    = &g_twi3attr,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -240,7 +248,16 @@ static const struct twi_attr_s g_twi0attr =
   .base    = SAM_TWI0_VBASE,
 };
 
-static struct twi_dev_s g_twi0;
+static struct twi_dev_s g_twi0 =
+{
+  .dev     =
+  {
+    .ops   = &g_twiops,
+  },
+  .attr    = &g_twi0attr,

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_xdmac.c:
##########
@@ -713,13 +716,16 @@ static struct sam_xdmach_s g_xdmach1[SAM_NDMACHAN] =
 
 static struct sam_xdmac_s g_xdmac1 =
 {
+  .chlock     = NXMUTEX_INITIALIZER,
+  .dsem       = SEM_INITIALIZER(SAM_NDMACHAN),
+
   /* XDMAC 0 base address */
 
   .base       = SAM_XDMAC1_VBASE,
 
   /* This array describes the available link list descriptors */
 
-  .descr       = g_desc1,
+  .descr      = g_desc1,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/sama5/sam_xdmac.c:
##########
@@ -539,13 +539,16 @@ static struct sam_xdmach_s g_xdmach0[SAM_NDMACHAN] =
 
 static struct sam_xdmac_s g_xdmac0 =
 {
+  .chlock     = NXMUTEX_INITIALIZER,
+  .dsem       = SEM_INITIALIZER(SAM_NDMACHAN),
+
   /* XDMAC 0 base address */
 
   .base       = SAM_XDMAC0_VBASE,
 
   /* This array describes the available link list descriptors */
 
-  .descr       = g_desc0,
+  .descr      = g_desc0,

Review Comment:
   @xiaoxiang781216 
   It would be better to move the style change to the 3rd commit.
   



##########
arch/arm/src/sama5/sam_xdmac.c:
##########
@@ -1522,7 +1510,7 @@ static void sam_freelinklist(struct sam_xdmach_s *xdmach)
        */
 
       memset(descr, 0, sizeof(struct chnext_view1_s));
-      sam_givedsem(xdmac);
+      nxsem_post(&xdmac->dsem);

Review Comment:
   @xiaoxiang781216 
   Does this change relate to the global mutex/sem initialization?
   



##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -1177,55 +1213,39 @@ struct i2c_master_s *sam_i2cbus_initialize(int bus)
 #ifdef CONFIG_SAMA5_TWI0
   if (bus == 0)
     {
-      /* Select up TWI0 and setup invariant attributes */
-
-      priv       = &g_twi0;
-      priv->attr = &g_twi0attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI0 and the (initial) TWI frequency */
 
+      priv      = &g_twi0;
       frequency = CONFIG_SAMA5_TWI0_FREQUENCY;
     }
   else
 #endif
 #ifdef CONFIG_SAMA5_TWI1
   if (bus == 1)
     {
-      /* Select up TWI1 and setup invariant attributes */
-
-      priv       = &g_twi1;
-      priv->attr = &g_twi1attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI1 and the (initial) TWI frequency */
 
+      priv      = &g_twi1;
       frequency = CONFIG_SAMA5_TWI1_FREQUENCY;
     }
   else
 #endif
 #ifdef CONFIG_SAMA5_TWI2
   if (bus == 2)
     {
-      /* Select up TWI2 and setup invariant attributes */
-
-      priv       = &g_twi2;
-      priv->attr = &g_twi2attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI2 and the (initial) TWI frequency */
 
+      priv      = &g_twi2;
       frequency = CONFIG_SAMA5_TWI2_FREQUENCY;
     }
   else
 #endif
 #ifdef CONFIG_SAMA5_TWI3
   if (bus == 3)
     {
-      /* Select up TWI3 and setup invariant attributes */
-
-      priv       = &g_twi3;
-      priv->attr = &g_twi3attr;
-
-      /* Select the (initial) TWI frequency */
+      /* Select up TWI3 and the (initial) TWI frequency */
 
+      priv      = &g_twi3;

Review Comment:
   @xiaoxiang781216 
   Do these changes relate to the global mutex/sem initialization?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1008748569


##########
arch/arm/src/cxd56xx/cxd56_dmac.c:
##########
@@ -328,22 +332,25 @@ static struct dmac_register_map *get_device(int ch)
     case 2: return (struct dmac_register_map *)DMAC2_REG_BASE;
     case 3: return (struct dmac_register_map *)DMAC3_REG_BASE;
     }
+
     return NULL;
 }
 
 static struct dmac_ch_register_map *get_channel(int ch)
 {
   struct dmac_register_map *dev = get_device(ch);
   if (dev == NULL)
-     return NULL;
+    {
+      return NULL;
+    }
 
   if (is_dmac(2, dev))
     {
-        return &dev->channel[ch - 7];
+      return &dev->channel[ch - 7];

Review Comment:
   can we separate style changes into a separate commit?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#issuecomment-1312702111

   I do not have more comments. Let's wait one more day to get feedback from @masayuki2009 
   I will merge the change if there will be no more comments.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] masayuki2009 commented on pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#issuecomment-1298184771

   Hmm, it's too hard because the first commit is too big and has several changes other than the global muetx/sem initialization.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011163209


##########
arch/arm/src/sama5/sam_hsmci.c:
##########
@@ -596,57 +596,145 @@ static void sam_callback(void *arg);
  * Private Data
  ****************************************************************************/
 
-/* Callbacks */
+/* Pre-allocate memory for each HSMCI device */
 
-static const struct sdio_dev_s g_callbacks =
+#ifdef CONFIG_SAMA5_HSMCI0
+static struct sam_dev_s g_hsmci0 =
 {
-  .reset            = sam_reset,
-  .capabilities     = sam_capabilities,
-  .status           = sam_status,
-  .widebus          = sam_widebus,
-  .clock            = sam_clock,
-  .attach           = sam_attach,
-  .sendcmd          = sam_sendcmd,
-  .blocksetup       = sam_blocksetup,
-  .recvsetup        = sam_recvsetup,
-  .sendsetup        = sam_sendsetup,
-  .cancel           = sam_cancel,
-  .waitresponse     = sam_waitresponse,
-  .recv_r1          = sam_recvshort,
-  .recv_r2          = sam_recvlong,
-  .recv_r3          = sam_recvshort,
-  .recv_r4          = sam_recvnotimpl,
-  .recv_r5          = sam_recvnotimpl,
-  .recv_r6          = sam_recvshort,
-  .recv_r7          = sam_recvshort,
-  .waitenable       = sam_waitenable,
-  .eventwait        = sam_eventwait,
-  .callbackenable   = sam_callbackenable,
-  .registercallback = sam_registercallback,
+  .dev                =
+  {
+    .reset            = sam_reset,
+    .capabilities     = sam_capabilities,
+    .status           = sam_status,
+    .widebus          = sam_widebus,
+    .clock            = sam_clock,
+    .attach           = sam_attach,
+    .sendcmd          = sam_sendcmd,
+    .blocksetup       = sam_blocksetup,
+    .recvsetup        = sam_recvsetup,
+    .sendsetup        = sam_sendsetup,
+    .cancel           = sam_cancel,
+    .waitresponse     = sam_waitresponse,
+    .recv_r1          = sam_recvshort,
+    .recv_r2          = sam_recvlong,
+    .recv_r3          = sam_recvshort,
+    .recv_r4          = sam_recvnotimpl,
+    .recv_r5          = sam_recvnotimpl,
+    .recv_r6          = sam_recvshort,
+    .recv_r7          = sam_recvshort,
+    .waitenable       = sam_waitenable,
+    .eventwait        = sam_eventwait,
+    .callbackenable   = sam_callbackenable,
+    .registercallback = sam_registercallback,
 #ifdef CONFIG_SDIO_DMA
 #ifndef HSCMI_NORXDMA
-  .dmarecvsetup     = sam_dmarecvsetup,
+    .dmarecvsetup     = sam_dmarecvsetup,
 #else
-  .dmarecvsetup     = sam_recvsetup,
+    .dmarecvsetup     = sam_recvsetup,
 #endif
 #ifndef HSCMI_NOTXDMA
-  .dmasendsetup     = sam_dmasendsetup,
+    .dmasendsetup     = sam_dmasendsetup,
 #else
-  .dmasendsetup     = sam_sendsetup,
+    .dmasendsetup     = sam_sendsetup,
 #endif
 #endif
+  },
+  .waitsem            = SEM_INITIALIZER(0),
+  .base               = SAM_HSMCI0_VBASE,
+  .hsmci              = 0,
 };
-
-/* Pre-allocate memory for each HSMCI device */
-
-#ifdef CONFIG_SAMA5_HSMCI0
-static struct sam_dev_s g_hsmci0;
 #endif
 #ifdef CONFIG_SAMA5_HSMCI1
-static struct sam_dev_s g_hsmci1;
+static struct sam_dev_s g_hsmci1 =
+{
+  .dev                =
+  {
+    .reset            = sam_reset,
+    .capabilities     = sam_capabilities,
+    .status           = sam_status,
+    .widebus          = sam_widebus,
+    .clock            = sam_clock,
+    .attach           = sam_attach,
+    .sendcmd          = sam_sendcmd,
+    .blocksetup       = sam_blocksetup,
+    .recvsetup        = sam_recvsetup,
+    .sendsetup        = sam_sendsetup,
+    .cancel           = sam_cancel,
+    .waitresponse     = sam_waitresponse,
+    .recv_r1          = sam_recvshort,
+    .recv_r2          = sam_recvlong,
+    .recv_r3          = sam_recvshort,
+    .recv_r4          = sam_recvnotimpl,
+    .recv_r5          = sam_recvnotimpl,
+    .recv_r6          = sam_recvshort,
+    .recv_r7          = sam_recvshort,
+    .waitenable       = sam_waitenable,
+    .eventwait        = sam_eventwait,
+    .callbackenable   = sam_callbackenable,
+    .registercallback = sam_registercallback,
+#ifdef CONFIG_SDIO_DMA
+#ifndef HSCMI_NORXDMA
+    .dmarecvsetup     = sam_dmarecvsetup,
+#else
+    .dmarecvsetup     = sam_recvsetup,
+#endif
+#ifndef HSCMI_NOTXDMA
+    .dmasendsetup     = sam_dmasendsetup,
+#else
+    .dmasendsetup     = sam_sendsetup,

Review Comment:
   Yes, since the change destroy the previous code alignment



##########
arch/arm/src/sama5/sam_hsmci.c:
##########
@@ -3193,11 +3281,6 @@ struct sdio_dev_s *sdio_initialize(int slotno)
 
       priv = &g_hsmci0;
 
-      /* HSMCI0 Initialization */
-
-      priv->base  = SAM_HSMCI0_VBASE;
-      priv->hsmci = 0;

Review Comment:
   Yes, it's better to use the same method to initialize all field



##########
arch/arm/src/sama5/sam_hsmci.c:
##########
@@ -3232,11 +3315,6 @@ struct sdio_dev_s *sdio_initialize(int slotno)
 
       priv = &g_hsmci1;
 
-      /* HSMCI1 Initialization */
-
-      priv->base  = SAM_HSMCI1_VBASE;
-      priv->hsmci = 1;

Review Comment:
   Yes, it's better to use the same method to initialize all field



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011161226


##########
arch/arm/src/sama5/sam_hsmci.c:
##########
@@ -596,57 +596,145 @@ static void sam_callback(void *arg);
  * Private Data
  ****************************************************************************/
 
-/* Callbacks */
+/* Pre-allocate memory for each HSMCI device */
 
-static const struct sdio_dev_s g_callbacks =
+#ifdef CONFIG_SAMA5_HSMCI0
+static struct sam_dev_s g_hsmci0 =
 {
-  .reset            = sam_reset,
-  .capabilities     = sam_capabilities,
-  .status           = sam_status,
-  .widebus          = sam_widebus,
-  .clock            = sam_clock,
-  .attach           = sam_attach,
-  .sendcmd          = sam_sendcmd,
-  .blocksetup       = sam_blocksetup,
-  .recvsetup        = sam_recvsetup,
-  .sendsetup        = sam_sendsetup,
-  .cancel           = sam_cancel,
-  .waitresponse     = sam_waitresponse,
-  .recv_r1          = sam_recvshort,
-  .recv_r2          = sam_recvlong,
-  .recv_r3          = sam_recvshort,
-  .recv_r4          = sam_recvnotimpl,
-  .recv_r5          = sam_recvnotimpl,
-  .recv_r6          = sam_recvshort,
-  .recv_r7          = sam_recvshort,
-  .waitenable       = sam_waitenable,
-  .eventwait        = sam_eventwait,
-  .callbackenable   = sam_callbackenable,
-  .registercallback = sam_registercallback,
+  .dev                =
+  {
+    .reset            = sam_reset,
+    .capabilities     = sam_capabilities,
+    .status           = sam_status,
+    .widebus          = sam_widebus,
+    .clock            = sam_clock,
+    .attach           = sam_attach,
+    .sendcmd          = sam_sendcmd,
+    .blocksetup       = sam_blocksetup,
+    .recvsetup        = sam_recvsetup,
+    .sendsetup        = sam_sendsetup,
+    .cancel           = sam_cancel,
+    .waitresponse     = sam_waitresponse,
+    .recv_r1          = sam_recvshort,
+    .recv_r2          = sam_recvlong,
+    .recv_r3          = sam_recvshort,
+    .recv_r4          = sam_recvnotimpl,
+    .recv_r5          = sam_recvnotimpl,
+    .recv_r6          = sam_recvshort,
+    .recv_r7          = sam_recvshort,
+    .waitenable       = sam_waitenable,
+    .eventwait        = sam_eventwait,
+    .callbackenable   = sam_callbackenable,
+    .registercallback = sam_registercallback,
 #ifdef CONFIG_SDIO_DMA
 #ifndef HSCMI_NORXDMA
-  .dmarecvsetup     = sam_dmarecvsetup,
+    .dmarecvsetup     = sam_dmarecvsetup,
 #else
-  .dmarecvsetup     = sam_recvsetup,
+    .dmarecvsetup     = sam_recvsetup,
 #endif
 #ifndef HSCMI_NOTXDMA
-  .dmasendsetup     = sam_dmasendsetup,
+    .dmasendsetup     = sam_dmasendsetup,
 #else
-  .dmasendsetup     = sam_sendsetup,
+    .dmasendsetup     = sam_sendsetup,
 #endif
 #endif
+  },
+  .waitsem            = SEM_INITIALIZER(0),
+  .base               = SAM_HSMCI0_VBASE,
+  .hsmci              = 0,

Review Comment:
   Yes, it's better to use the same method to initialize all field



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011128126


##########
arch/arm/src/s32k3xx/s32k3xx_edma.c:
##########
@@ -916,18 +902,12 @@ void weak_function arm_dma_initialize(void)
 
   /* Initialize data structures */
 
-  memset(&g_edma, 0, sizeof(struct s32k3xx_edma_s));

Review Comment:
   Yes, avoid the initial value is destroyed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011965214


##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -1253,83 +1307,59 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
 #ifdef SAMD2L2_HAVE_I2C0
   if (bus == 0)
     {
-      /* Select up I2C0 and setup invariant attributes */
+      /* Select up I2C0 and the (initial) I2C frequency */
 
       priv = &g_i2c0;
-      priv->attr = &g_i2c0attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C0_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C1
   if (bus == 1)
     {
-      /* Select up I2C1 and setup invariant attributes */
+      /* Select up I2C1 and the (initial) I2C frequency */
 
       priv = &g_i2c1;
-      priv->attr = &g_i2c1attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C1_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C2
   if (bus == 2)
     {
-      /* Select up I2C2 and setup invariant attributes */
+      /* Select up I2C2 and the (initial) I2C frequency */
 
       priv = &g_i2c2;
-      priv->attr = &g_i2c2attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C2_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C3
   if (bus == 3)
     {
-      /* Select up I2C3 and setup invariant attributes */
+      /* Select up I2C3 and the (initial) I2C frequency */
 
       priv = &g_i2c3;
-      priv->attr = &g_i2c3attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C3_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C4
   if (bus == 4)
     {
-      /* Select up I2C4 and setup invariant attributes */
+      /* Select up I2C4 and the (initial) I2C frequency */
 
       priv = &g_i2c4;
-      priv->attr = &g_i2c4attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C4_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C5
   if (bus == 5)
     {
-      /* Select up I2C5 and setup invariant attributes */
+      /* Select up I2C5 and the (initial) I2C frequency */
 
       priv = &g_i2c5;
-      priv->attr = &g_i2c5attr;

Review Comment:
   yes



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -1253,83 +1307,59 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
 #ifdef SAMD2L2_HAVE_I2C0
   if (bus == 0)
     {
-      /* Select up I2C0 and setup invariant attributes */
+      /* Select up I2C0 and the (initial) I2C frequency */
 
       priv = &g_i2c0;
-      priv->attr = &g_i2c0attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C0_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C1
   if (bus == 1)
     {
-      /* Select up I2C1 and setup invariant attributes */
+      /* Select up I2C1 and the (initial) I2C frequency */
 
       priv = &g_i2c1;
-      priv->attr = &g_i2c1attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C1_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C2
   if (bus == 2)
     {
-      /* Select up I2C2 and setup invariant attributes */
+      /* Select up I2C2 and the (initial) I2C frequency */
 
       priv = &g_i2c2;
-      priv->attr = &g_i2c2attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C2_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C3
   if (bus == 3)
     {
-      /* Select up I2C3 and setup invariant attributes */
+      /* Select up I2C3 and the (initial) I2C frequency */
 
       priv = &g_i2c3;
-      priv->attr = &g_i2c3attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C3_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C4
   if (bus == 4)
     {
-      /* Select up I2C4 and setup invariant attributes */
+      /* Select up I2C4 and the (initial) I2C frequency */
 
       priv = &g_i2c4;
-      priv->attr = &g_i2c4attr;

Review Comment:
   yes



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -1253,83 +1307,59 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
 #ifdef SAMD2L2_HAVE_I2C0
   if (bus == 0)
     {
-      /* Select up I2C0 and setup invariant attributes */
+      /* Select up I2C0 and the (initial) I2C frequency */
 
       priv = &g_i2c0;
-      priv->attr = &g_i2c0attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C0_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C1
   if (bus == 1)
     {
-      /* Select up I2C1 and setup invariant attributes */
+      /* Select up I2C1 and the (initial) I2C frequency */
 
       priv = &g_i2c1;
-      priv->attr = &g_i2c1attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C1_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C2
   if (bus == 2)
     {
-      /* Select up I2C2 and setup invariant attributes */
+      /* Select up I2C2 and the (initial) I2C frequency */
 
       priv = &g_i2c2;
-      priv->attr = &g_i2c2attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C2_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C3
   if (bus == 3)
     {
-      /* Select up I2C3 and setup invariant attributes */
+      /* Select up I2C3 and the (initial) I2C frequency */
 
       priv = &g_i2c3;
-      priv->attr = &g_i2c3attr;

Review Comment:
   yes



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -1253,83 +1307,59 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
 #ifdef SAMD2L2_HAVE_I2C0
   if (bus == 0)
     {
-      /* Select up I2C0 and setup invariant attributes */
+      /* Select up I2C0 and the (initial) I2C frequency */
 
       priv = &g_i2c0;
-      priv->attr = &g_i2c0attr;
-
-      /* Select the (initial) I2C frequency */
-
       frequency = CONFIG_SAM_I2C0_FREQUENCY;
     }
   else
 #endif
 #ifdef SAMD2L2_HAVE_I2C1
   if (bus == 1)
     {
-      /* Select up I2C1 and setup invariant attributes */
+      /* Select up I2C1 and the (initial) I2C frequency */
 
       priv = &g_i2c1;
-      priv->attr = &g_i2c1attr;

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011967309


##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -229,6 +229,14 @@ static void twi_hw_initialize(struct twi_dev_s *priv, uint32_t frequency);
  * Private Data
  ****************************************************************************/
 
+static const struct i2c_ops_s g_twiops =
+{
+  .transfer = twi_transfer
+#ifdef CONFIG_I2C_RESET
+  , .reset  = twi_reset
+#endif
+};
+

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1016100505


##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -1204,7 +1217,6 @@ struct spi_dev_s *cxd56_spibus_initialize(int port)
   /* DMA settings */
 
 #ifdef CONFIG_CXD56_DMAC
-  priv->dmaenable = false;

Review Comment:
   reply https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1016100185



##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -1328,25 +1336,13 @@ void cxd56_spi_dmaconfig(int port, int chtype, DMA_HANDLE handle,
 
           priv->txdmach = handle;
           memcpy(&priv->txconfig, conf, sizeof(dma_config_t));
-
-          if (!priv->dmaenable)
-            {
-              nxsem_init(&priv->dmasem, 0, 0);
-              priv->dmaenable = true;
-            }
         }

Review Comment:
   ditto



##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -1328,25 +1336,13 @@ void cxd56_spi_dmaconfig(int port, int chtype, DMA_HANDLE handle,
 
           priv->txdmach = handle;
           memcpy(&priv->txconfig, conf, sizeof(dma_config_t));
-
-          if (!priv->dmaenable)
-            {
-              nxsem_init(&priv->dmasem, 0, 0);
-              priv->dmaenable = true;
-            }
         }
       else if ((chtype == CXD56_SPI_DMAC_CHTYPE_RX) && (!priv->rxdmach))
         {
           /* RX DMA setting */
 
           priv->rxdmach = handle;
           memcpy(&priv->rxconfig, conf, sizeof(dma_config_t));
-
-          if (!priv->dmaenable)
-            {
-              nxsem_init(&priv->dmasem, 0, 0);
-              priv->dmaenable = true;
-            }
         }

Review Comment:
   ditto



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1017845604


##########
arch/risc-v/src/bl602/bl602_spi.c:
##########
@@ -1671,7 +1671,7 @@ struct spi_dev_s *bl602_spibus_initialize(int port)
   nxmutex_lock(&priv->lock);
   if (priv->refs != 0)
     {
-      priv->refs--;
+      priv->refs++;
       nxmutex_unlock(&priv->lock);

Review Comment:
   ditto



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1017456904


##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -77,7 +77,6 @@ struct cxd56_spidev_s
   uint8_t          port;        /* Port number */
   int              initialized; /* Initialized flag */
 #ifdef CONFIG_CXD56_DMAC
-  bool             dmaenable;   /* Use DMA or not */

Review Comment:
   Yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1018612831


##########
arch/renesas/src/rx65n/rx65n_usbhost.c:
##########
@@ -3352,7 +3354,7 @@ void usb_hstd_bus_reset (void)
       /* DeviceStateControlRegister - ResetHandshakeStatusCheck */
 
       buf = hw_usb_read_dvstctr();
-      buf = (uint16_t) (buf & RX65N_USB_DVSTCTR0_RHST);
+      buf &= RX65N_USB_DVSTCTR0_RHST;

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011101420


##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -871,7 +886,7 @@ static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer,
   size_t dmath = 0;
 #endif
 
-  if (priv->dmaenable && dmath < nwords)
+  if (priv->txdmach && priv->rxdmach && dmath < nwords)
     {

Review Comment:
   Yes, because txdmach and rxdmach doesn't initialize at runtime anymore, so dmaenable which is used to identify the initialization result doesn't need too.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011149480


##########
arch/arm/src/sama5/sam_can.c:
##########
@@ -1902,7 +1920,6 @@ struct can_dev_s *sam_caninitialize(int port)
 {
   struct can_dev_s *dev;
   struct sam_can_s *priv;
-  const struct sam_config_s *config;

Review Comment:
   Yes, since all field initialization in the same(definition) place



##########
arch/arm/src/sama5/sam_can.c:
##########
@@ -1915,9 +1932,8 @@ struct can_dev_s *sam_caninitialize(int port)
     {
       /* Select the CAN0 device structure */
 
-      dev    = &g_can0dev;
-      priv   = &g_can0priv;
-      config = &g_can0const;
+      dev  = &g_can0dev;
+      priv = &g_can0priv;

Review Comment:
   Yes, since all field initialization in the same(definition) place



##########
arch/arm/src/sama5/sam_can.c:
##########
@@ -1926,9 +1942,8 @@ struct can_dev_s *sam_caninitialize(int port)
     {
       /* Select the CAN1 device structure */
 
-      dev    = &g_can1dev;
-      priv   = &g_can1priv;
-      config = &g_can1const;
+      dev  = &g_can1dev;
+      priv = &g_can1priv;

Review Comment:
   Yes, since all field initialization in the same(definition) place



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011969868


##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -341,10 +332,7 @@ static const struct sam_tcconfig_s g_tc345config =
 #ifdef CONFIG_SAMA5_TC2
 static const struct sam_tcconfig_s g_tc678config =
 {
-  .base    = SAM_TC678_VBASE,
-  .pid     = SAM_PID_TC2,
   .chfirst = 6,
-  .tc      = 2,

Review Comment:
   yes



##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -271,10 +265,7 @@ static const struct sam_tcconfig_s g_tc012config =
 #ifdef CONFIG_SAMA5_TC1
 static const struct sam_tcconfig_s g_tc345config =
 {
-  .base    = SAM_TC345_VBASE,
-  .pid     = SAM_PID_TC1,
   .chfirst = 3,
-  .tc      = 1,

Review Comment:
   yes



##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -201,10 +198,7 @@ static inline struct sam_chan_s *sam_tc_initialize(int channel);
 #ifdef CONFIG_SAMA5_TC0
 static const struct sam_tcconfig_s g_tc012config =
 {
-  .base    = SAM_TC012_VBASE,
-  .pid     = SAM_PID_TC0,
   .chfirst = 0,
-  .tc      = 0,

Review Comment:
   yes



##########
arch/arm/src/sama5/sam_tc.c:
##########
@@ -98,10 +98,7 @@ struct sam_chconfig_s
 
 struct sam_tcconfig_s
 {
-  uintptr_t base;          /* TC register base address */
-  uint8_t pid;             /* Peripheral ID */
   uint8_t chfirst;         /* First channel number */
-  uint8_t tc;              /* Timer/counter number */

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011968883


##########
arch/arm/src/sama5/sam_tsd.c:
##########
@@ -1665,18 +1666,14 @@ int sam_tsd_register(struct sam_adc_s *adc, int minor)
   if (ret < 0)
     {
       ierr("ERROR: register_driver() failed: %d\n", ret);
-      goto errout_with_priv;
+      return ret;

Review Comment:
   yes



##########
arch/arm/src/sama5/sam_trng.c:
##########
@@ -333,15 +337,6 @@ static int sam_rng_initialize(void)
 
   finfo("Initializing TRNG hardware\n");
 
-  /* Initialize the device structure */
-
-  memset(&g_trngdev, 0, sizeof(struct trng_dev_s));

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] masayuki2009 commented on pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#issuecomment-1306503180

   @xiaoxiang781216 
   Please rebase this PR to the latest master.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011963356


##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -276,7 +293,16 @@ static const struct i2c_attr_s g_i2c1attr =
   .base      = SAM_SERCOM1_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c1;
+static struct sam_i2c_dev_s g_i2c1 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c1attr,

Review Comment:
   yes



##########
arch/arm/src/samd5e5/sam_i2c_master.c:
##########
@@ -258,7 +266,16 @@ static const struct i2c_attr_s g_i2c0attr =
   .base      = SAM_SERCOM0_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c0;
+static struct sam_i2c_dev_s g_i2c0 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c0attr,

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1009731942


##########
arch/arm/src/sam34/sam_spi.c:
##########
@@ -1857,12 +1859,7 @@ struct spi_dev_s *sam_spibus_initialize(int port)
       spi_getreg(spi, SAM_SPI_SR_OFFSET);
       spi_getreg(spi, SAM_SPI_RDR_OFFSET);
 
-      /* Initialize the SPI mutex that enforces mutually exclusive
-       * access to the SPI registers.
-       */
-
-      nxmutex_init(&spi->spilock);
-      spi->initialized = true;
+       spi->initialized = true;

Review Comment:
   ```suggestion
         spi->initialized = true;
   ```



##########
drivers/usbhost/usbhost_xboxcontroller.c:
##########
@@ -1901,10 +1901,10 @@ static int usbhost_close(FAR struct file *filep)
 static ssize_t usbhost_read(FAR struct file *filep, FAR char *buffer,
                             size_t len)
 {
-  FAR struct inode                          *inode;
-  FAR struct usbhost_state_s                *priv;
-  FAR struct xbox_controller_buttonstate_s  sample;
-  int                                       ret;
+  FAR struct inode                         *inode;
+  FAR struct usbhost_state_s               *priv;
+  FAR struct xbox_controller_buttonstate_s sample;

Review Comment:
   ```suggestion
     struct xbox_controller_buttonstate_s sample;
   ```



##########
crypto/random_pool.c:
##########
@@ -45,8 +45,8 @@
 #  define MIN(a,b) ((a) < (b) ? (a) : (b))
 #endif
 
-#define ROTL_32(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )
-#define ROTR_32(x,n) ( ((x) >> (n)) | ((x) << (32-(n))) )
+#define ROTL_32(x,n) (((x) << (n)) | ((x) >> (32-(n))))
+#define ROTR_32(x,n) (((x) >> (n)) | ((x) << (32-(n))))

Review Comment:
   ```suggestion
   #define ROTL_32(x,n) (((x) << (n)) | ((x) >> (32 - (n))))
   #define ROTR_32(x,n) (((x) >> (n)) | ((x) << (32 - (n))))
   ```



##########
boards/arm/stm32/mikroe-stm32f4/src/stm32_touchscreen.c:
##########
@@ -1350,10 +1350,10 @@ static int tc_ioctl(struct file *filep, int cmd, unsigned long arg)
 static int tc_poll(struct file *filep, struct pollfd *fds,
                         bool setup)

Review Comment:
   ```suggestion
   static int tc_poll(struct file *filep, struct pollfd *fds,
                      bool setup)
   ```



##########
arch/arm/src/sam34/sam_twi.c:
##########
@@ -174,7 +174,7 @@ static void twi_startmessage(struct twi_dev_s *priv, struct i2c_msg_s *msg);
 static int twi_transfer(struct i2c_master_s *dev,
           struct i2c_msg_s *msgs, int count);

Review Comment:
   ```suggestion
   static int  twi_transfer(struct i2c_master_s *dev,
                            struct i2c_msg_s *msgs, int count);
   ```



##########
crypto/random_pool.c:
##########
@@ -89,7 +89,10 @@ enum
  * Private Data
  ****************************************************************************/
 
-static struct rng_s g_rng;
+static struct rng_s g_rng =
+{
+  .rd_lock = NXMUTEX_INITIALIZER,

Review Comment:
   C89



##########
boards/mips/pic32mx/pic32mx7mmb/src/pic32_touchscreen.c:
##########
@@ -1227,10 +1227,10 @@ static int tc_ioctl(struct file *filep, int cmd, unsigned long arg)
 static int tc_poll(struct file *filep, struct pollfd *fds,
                         bool setup)

Review Comment:
   ```suggestion
   static int tc_poll(struct file *filep, struct pollfd *fds,
                      bool setup)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1013544082


##########
arch/xtensa/src/esp32s2/esp32s2_spi.c:
##########
@@ -1432,8 +1432,6 @@ static void esp32s2_spi_init(struct spi_dev_s *dev)
 
 #if defined(CONFIG_ESP32S2_SPI2_DMA) || defined(CONFIG_ESP32S2_SPI3_DMA)
   nxsem_init(&priv->sem_isr, 0, 0);

Review Comment:
   Yes, done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#issuecomment-1308644797

   @masayuki2009 @pkarashchenko please review again.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#issuecomment-1312690412

   @masayuki2009 @pkarashchenko do you have more comment or merge it if no?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011151858


##########
arch/arm/src/sama5/sam_dmac.c:
##########
@@ -1334,7 +1322,7 @@ sam_allocdesc(struct sam_dmach_s *dmach, struct dma_linklist_s *prev,
        * there is at least one free descriptor in the table and it is ours.
        */
 
-      ret = sam_takedsem(dmac);
+      ret = nxsem_wait_uninterruptible(&dmac->dsem);

Review Comment:
   move to next patch



##########
arch/arm/src/sama5/sam_dmac.c:
##########
@@ -1349,7 +1337,7 @@ sam_allocdesc(struct sam_dmach_s *dmach, struct dma_linklist_s *prev,
       ret = nxmutex_lock(&dmac->chlock);
       if (ret < 0)
         {
-          sam_givedsem(dmac);
+          nxsem_post(&dmac->dsem);

Review Comment:
   move to next patch



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1013545232


##########
crypto/random_pool.c:
##########
@@ -45,8 +45,8 @@
 #  define MIN(a,b) ((a) < (b) ? (a) : (b))
 #endif
 
-#define ROTL_32(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )
-#define ROTR_32(x,n) ( ((x) >> (n)) | ((x) << (32-(n))) )
+#define ROTL_32(x,n) (((x) << (n)) | ((x) >> (32-(n))))
+#define ROTR_32(x,n) (((x) >> (n)) | ((x) << (32-(n))))

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011163449


##########
arch/arm/src/sama5/sam_ohci.c:
##########
@@ -4023,10 +4026,6 @@ struct usbhost_connection_s *sam_ohci_initialize(int controller)
 
   usbhost_vtrace1(OHCI_VTRACE1_INITIALIZING, 0);
 
-  /* Initialize all the HCCA to 0 */
-
-  memset((void *)&g_hcca, 0, sizeof(struct ohci_hcca_s));

Review Comment:
   restore



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011122367


##########
arch/arm/src/lpc54xx/lpc54_usb0_ohci.c:
##########
@@ -3904,11 +3903,9 @@ struct usbhost_connection_s *lpc54_usbhost_initialize(int controller)
         LPC54_IOFREE_BASE, LPC54_IOBUFFERS * CONFIG_LPC54_OHCI_IOBUFSIZE);
 #endif
 
-  /* Initialize all the TDs, EDs and HCCA to 0 */
-
-  memset((void *)HCCA,   0, sizeof(struct ohci_hcca_s));
-  memset((void *)TDTAIL, 0, sizeof(struct ohci_gtd_s));
-  memset((void *)EDCTRL, 0, sizeof(struct lpc54_ed_s));

Review Comment:
   restore



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1011965503


##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -1253,83 +1307,59 @@ struct i2c_master_s *sam_i2c_master_initialize(int bus)
 #ifdef SAMD2L2_HAVE_I2C0
   if (bus == 0)
     {
-      /* Select up I2C0 and setup invariant attributes */
+      /* Select up I2C0 and the (initial) I2C frequency */
 
       priv = &g_i2c0;
-      priv->attr = &g_i2c0attr;

Review Comment:
   yes



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -359,16 +412,17 @@ static const struct i2c_attr_s g_i2c5attr =
   .base      = SAM_SERCOM5_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c5;
-#endif
-
-struct i2c_ops_s g_i2cops =
+static struct sam_i2c_dev_s g_i2c5 =
 {
-  .transfer = sam_i2c_transfer,
-#ifdef CONFIG_I2C_RESET
-  .reset = sam_i2c_reset,
-#endif
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c5attr,

Review Comment:
   yes



##########
arch/arm/src/samd2l2/sam_i2c_master.c:
##########
@@ -341,7 +385,16 @@ static const struct i2c_attr_s g_i2c4attr =
   .base      = SAM_SERCOM4_BASE,
 };
 
-static struct sam_i2c_dev_s g_i2c4;
+static struct sam_i2c_dev_s g_i2c4 =
+{
+  .dev       =
+  {
+    .ops     = &g_i2cops,
+  },
+  .attr      = &g_i2c4attr,

Review Comment:
   yes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1017456380


##########
arch/arm/src/sama5/sam_twi.c:
##########
@@ -229,6 +229,14 @@ static void twi_hw_initialize(struct twi_dev_s *priv, uint32_t frequency);
  * Private Data
  ****************************************************************************/
 
+static const struct i2c_ops_s g_twiops =
+{
+  .transfer = twi_transfer
+#ifdef CONFIG_I2C_RESET
+  , .reset  = twi_reset

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1017845029


##########
arch/arm/src/stm32/stm32_i2c_v2.c:
##########
@@ -2804,7 +2804,6 @@ int stm32_i2cbus_uninitialize(struct i2c_master_s *dev)
   if (--priv->refs)
     {
       nxmutex_unlock(&priv->lock);
-      kmm_free(dev);
       return OK;

Review Comment:
   No, split to the new patch.



##########
arch/arm/src/stm32f7/stm32_i2c.c:
##########
@@ -2842,7 +2842,6 @@ int stm32_i2cbus_uninitialize(struct i2c_master_s *dev)
   if (--priv->refs)
     {
       nxmutex_unlock(&priv->lock);
-      kmm_free(dev);
       return OK;

Review Comment:
   ditto



##########
arch/arm/src/stm32l4/stm32l4_1wire.c:
##########
@@ -1247,7 +1247,6 @@ int stm32l4_1wireuninitialize(struct onewire_dev_s *dev)
   if (--priv->refs)
     {
       nxmutex_unlock(&priv->lock);
-      kmm_free(priv);
       return OK;

Review Comment:
   ditto



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1017906507


##########
arch/arm/src/stm32f0l0g0/stm32_i2c.c:
##########
@@ -2803,7 +2803,6 @@ int stm32_i2cbus_uninitialize(struct i2c_master_s *dev)
   if (--priv->refs)
     {
       nxmutex_unlock(&priv->lock);
-      kmm_free(dev);

Review Comment:
   move to new patch



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#issuecomment-1306537994

   > @xiaoxiang781216 Please rebase this PR to the latest master and resolve the conflicts.
   
   Done.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1016100185


##########
arch/arm/src/cxd56xx/cxd56_spi.c:
##########
@@ -863,15 +878,13 @@ static void spi_exchange(struct spi_dev_s *dev, const void *txbuffer,
                          void *rxbuffer, size_t nwords)
 {
 #ifdef CONFIG_CXD56_DMAC
-  struct cxd56_spidev_s *priv = (struct cxd56_spidev_s *)dev;
-
 #ifdef CONFIG_CXD56_SPI_DMATHRESHOLD
   size_t dmath = CONFIG_CXD56_SPI_DMATHRESHOLD;
 #else
   size_t dmath = 0;
 #endif
 
-  if (priv->dmaenable && dmath < nwords)

Review Comment:
   Yes, dmaenable was used to inidicate whether dmasem finish the initialization, mutex/sem is initialized statically far before the spi driver, so we don't need dmaenable anymore.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1018405714


##########
arch/renesas/src/rx65n/rx65n_usbhost.c:
##########
@@ -3001,14 +3003,14 @@ uint16_t usb_hstd_get_pipe_peri_value (uint8_t binterval)
       work2 = 0;
       for (; work1 != 0; work2++ )
         {
-                  work1 = (uint16_t)(work1 >> 1);
+                  work1 >>= 1;

Review Comment:
   remove extra spaces here



##########
arch/renesas/src/rx65n/rx65n_usbhost.c:
##########
@@ -4206,13 +4203,13 @@ static void usb_cstd_clr_stall (uint16_t pipe)
  *                 :                   : USB_WRITESHRT / USB_FIFOERROR
  ****************************************************************************/
 
-uint16_t usb_hstd_ctrl_write_start (uint8_t * buf_add, size_t buf_size)
+uint16_t usb_hstd_ctrl_write_start(uint8_t * buf_add, size_t buf_size)

Review Comment:
   ```suggestion
   uint16_t usb_hstd_ctrl_write_start(uint8_t *buf_add, size_t buf_size)
   ```



##########
arch/renesas/src/rx65n/rx65n_usbhost.c:
##########
@@ -3352,7 +3354,7 @@ void usb_hstd_bus_reset (void)
       /* DeviceStateControlRegister - ResetHandshakeStatusCheck */
 
       buf = hw_usb_read_dvstctr();
-      buf = (uint16_t) (buf & RX65N_USB_DVSTCTR0_RHST);
+      buf &= RX65N_USB_DVSTCTR0_RHST;

Review Comment:
   `buf = hw_usb_read_dvstctr() & RX65N_USB_DVSTCTR0_RHST;`?



##########
arch/renesas/src/rx65n/rx65n_usbhost.c:
##########
@@ -3899,7 +3897,7 @@ static void usb_cstd_set_nak (uint16_t pipe)
  * Return value    : FRDY status
  ****************************************************************************/
 
-static uint16_t usb_cstd_is_set_frdy (uint16_t pipe, uint16_t fifosel,
+static uint16_t usb_cstd_is_set_frdy(uint16_t pipe, uint16_t fifosel,
         uint16_t isel)

Review Comment:
   ```suggestion
   static uint16_t usb_cstd_is_set_frdy(uint16_t pipe, uint16_t fifosel,
                                        uint16_t isel)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1018613332


##########
arch/renesas/src/rx65n/rx65n_usbhost.c:
##########
@@ -4206,13 +4203,13 @@ static void usb_cstd_clr_stall (uint16_t pipe)
  *                 :                   : USB_WRITESHRT / USB_FIFOERROR
  ****************************************************************************/
 
-uint16_t usb_hstd_ctrl_write_start (uint8_t * buf_add, size_t buf_size)
+uint16_t usb_hstd_ctrl_write_start(uint8_t * buf_add, size_t buf_size)

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7472: Initialize global mutext/sem by NXMUTEX_INITIALIZER and SEM_INITIALIZER

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #7472:
URL: https://github.com/apache/incubator-nuttx/pull/7472#discussion_r1018612950


##########
arch/renesas/src/rx65n/rx65n_usbhost.c:
##########
@@ -3899,7 +3897,7 @@ static void usb_cstd_set_nak (uint16_t pipe)
  * Return value    : FRDY status
  ****************************************************************************/
 
-static uint16_t usb_cstd_is_set_frdy (uint16_t pipe, uint16_t fifosel,
+static uint16_t usb_cstd_is_set_frdy(uint16_t pipe, uint16_t fifosel,
         uint16_t isel)

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org