xiaoxiang781216 commented on code in PR #15506:
URL: https://github.com/apache/nuttx/pull/15506#discussion_r1921105975


##########
arch/arm/src/samv7/sam_usbdevhs.c:
##########
@@ -428,6 +430,10 @@ struct sam_usbdev_s
    */
 
   uint8_t                  ep0out[SAM_EP0_MAXPACKET];
+
+  /* Spinlock */
+
+  spinlock_t              lock;

Review Comment:
   ```suggestion
     spinlock_t               lock;
   ```



##########
arch/arm/src/stm32f0l0g0/stm32_usbdev.c:
##########
@@ -3835,15 +3865,14 @@ int usbdev_register(struct usbdevclass_driver_s *driver)
  *
  ****************************************************************************/
 
-int usbdev_unregister(struct usbdevclass_driver_s *driver)
+static int usbdev_unregister_nolock(struct usbdevclass_driver_s *driver)

Review Comment:
   let's move before line 3676 and remove line 488-489



##########
arch/arm/src/imxrt/imxrt_usbdev.c:
##########
@@ -2821,16 +2848,14 @@ void arm_usbinitialize(void)
 {
   struct imxrt_usbdev_s *priv = &g_usbdev;
   int i;
-  irqstate_t flags;
-
-  flags = enter_critical_section();
 
   /* Initialize the device state structure */
 
   memset(priv, 0, sizeof(struct imxrt_usbdev_s));
   priv->usbdev.ops = &g_devops;
   priv->usbdev.ep0 = &priv->eplist[IMXRT_EP0_IN].ep;
   priv->epavail    = IMXRT_EPALLSET & ~IMXRT_EPCTRLSET;
+  priv->lock        = SP_UNLOCKED;

Review Comment:
   spinlock_init



##########
arch/arm/src/stm32/stm32_usbdev.c:
##########
@@ -3224,7 +3244,8 @@ static int stm32_epstall(struct usbdev_ep_s *ep, bool 
resume)
           priv->ep0state = EP0STATE_STALLED;
         }
 
-      leave_critical_section(flags);
+      spin_unlock_irqrestore(&priv->lock, flags);
+  sched_unlock();

Review Comment:
   ```suggestion
         sched_unlock();
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to