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

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

commit a50fd2f1dfcfc3fa2157d56649b26c17ad54ea12
Author: chao an <[email protected]>
AuthorDate: Thu Oct 29 14:35:14 2026 +0800

    drivers/usbhost: Fix storage coding style
    
    Fix declaration spacing, switch/case indentation, and long comments to 
satisfy nxstyle.
    
    Signed-off-by: chao an <[email protected]>
---
 drivers/usbhost/usbhost_storage.c | 220 ++++++++++++++++++++------------------
 1 file changed, 114 insertions(+), 106 deletions(-)

diff --git a/drivers/usbhost/usbhost_storage.c 
b/drivers/usbhost/usbhost_storage.c
index a39bc76b66f..70ac73e1a1b 100644
--- a/drivers/usbhost/usbhost_storage.c
+++ b/drivers/usbhost/usbhost_storage.c
@@ -386,6 +386,7 @@ static inline void usbhost_freeclass(FAR struct 
usbhost_state_s *usbclass)
   FAR struct usbhost_freestate_s *entry =
     (FAR struct usbhost_freestate_s *)usbclass;
   irqstate_t flags;
+
   DEBUGASSERT(entry != NULL);
 
   uinfo("Freeing: %p\n", entry);
@@ -429,6 +430,7 @@ static int usbhost_allocdevno(FAR struct usbhost_state_s 
*priv)
   for (devno = 0; devno < 26; devno++)
     {
       uint32_t bitno = 1 << devno;
+
       if ((g_devinuse & bitno) == 0)
         {
           g_devinuse |= bitno;
@@ -448,7 +450,9 @@ static void usbhost_freedevno(FAR struct usbhost_state_s 
*priv)
 
   if (devno >= 0 && devno < 26)
     {
-      irqstate_t flags = spin_lock_irqsave(&g_lock);
+      irqstate_t flags;
+
+      flags = spin_lock_irqsave(&g_lock);
       g_devinuse &= ~(1 << devno);
       spin_unlock_irqrestore(&g_lock, flags);
     }
@@ -651,9 +655,10 @@ static inline int usbhost_maxlunreq(FAR struct 
usbhost_state_s *priv)
 {
   FAR struct usb_ctrlreq_s *req = (FAR struct usb_ctrlreq_s *)priv->tbuffer;
   FAR struct usbhost_hubport_s *hport;
-  DEBUGASSERT(priv && priv->tbuffer);
   int ret;
 
+  DEBUGASSERT(priv && priv->tbuffer);
+
   /* Request maximum logical unit number.  NOTE: On an IN transaction, The
    * req and buffer pointers passed to DRVR_CTRLIN may refer to the same
    * allocated memory.
@@ -1049,7 +1054,7 @@ static inline int usbhost_cfgdesc(FAR struct 
usbhost_state_s *priv,
   configdesc += cfgdesc->len;
   remaining  -= cfgdesc->len;
 
-  /* Loop where there are more descriptors to examine */
+  /* Loop while there are more descriptors to examine */
 
   while (remaining >= sizeof(struct usb_desc_s))
     {
@@ -1058,116 +1063,119 @@ static inline int usbhost_cfgdesc(FAR struct 
usbhost_state_s *priv,
       desc = (FAR struct usb_desc_s *)configdesc;
       switch (desc->type)
         {
-        /* Interface descriptor. We really should get the number of endpoints
-         * from this descriptor too.
-         */
+          /* Interface descriptor. We really should get the number of
+           * endpoints from this descriptor too.
+           */
 
-        case USB_DESC_TYPE_INTERFACE:
-          {
-            FAR struct usb_ifdesc_s *ifdesc =
-              (FAR struct usb_ifdesc_s *)configdesc;
+          case USB_DESC_TYPE_INTERFACE:
+            {
+              FAR struct usb_ifdesc_s *ifdesc =
+                (FAR struct usb_ifdesc_s *)configdesc;
 
-            uinfo("Interface descriptor\n");
-            DEBUGASSERT(remaining >= USB_SIZEOF_IFDESC);
+              uinfo("Interface descriptor\n");
+              DEBUGASSERT(remaining >= USB_SIZEOF_IFDESC);
 
-            /* Save the interface number and mark ONLY the interface found */
+              /* Save the interface number and mark ONLY the interface
+               * found.
+               */
 
-            priv->ifno = ifdesc->ifno;
-            found      = USBHOST_IFFOUND;
-          }
-          break;
+              priv->ifno = ifdesc->ifno;
+              found      = USBHOST_IFFOUND;
+            }
+            break;
 
-        /* Endpoint descriptor.  We expect two bulk endpoints, an IN and an
-         * OUT.
-         */
-
-        case USB_DESC_TYPE_ENDPOINT:
-          {
-            FAR struct usb_epdesc_s *epdesc =
-              (FAR struct usb_epdesc_s *)configdesc;
-
-            uinfo("Endpoint descriptor\n");
-            DEBUGASSERT(remaining >= USB_SIZEOF_EPDESC);
-
-            /* Check for a bulk endpoint.  We only support the bulk-only
-             * protocol so I suppose anything else should really be an error.
-             */
-
-            if ((epdesc->attr & USB_EP_ATTR_XFERTYPE_MASK) ==
-                USB_EP_ATTR_XFER_BULK)
-              {
-                /* Yes.. it is a bulk endpoint.  IN or OUT? */
-
-                if (USB_ISEPOUT(epdesc->addr))
-                  {
-                    /* It is an OUT bulk endpoint.  There should be only one
-                     * bulk OUT endpoint.
-                     */
-
-                    if ((found & USBHOST_BOUTFOUND) != 0)
-                      {
-                        /* Oops.. more than one endpoint.  We don't know
-                         * what to do with this.
-                         */
-
-                        return -EINVAL;
-                      }
-
-                    found |= USBHOST_BOUTFOUND;
-
-                    /* Save the bulk OUT endpoint information */
-
-                    boutdesc.hport        = hport;
-                    boutdesc.addr         = epdesc->addr &
-                                            USB_EP_ADDR_NUMBER_MASK;
-                    boutdesc.in           = false;
-                    boutdesc.xfrtype      = USB_EP_ATTR_XFER_BULK;
-                    boutdesc.interval     = epdesc->interval;
-                    boutdesc.mxpacketsize =
-                      usbhost_getle16(epdesc->mxpacketsize);
-
-                    uinfo("Bulk OUT EP addr:%d mxpacketsize:%d\n",
-                          boutdesc.addr, boutdesc.mxpacketsize);
-                  }
-                else
-                  {
-                    /* It is an IN bulk endpoint.  There should be only one
-                     * bulk IN endpoint.
-                     */
-
-                    if ((found & USBHOST_BINFOUND) != 0)
-                      {
-                        /* Oops.. more than one endpoint.  We don't know
-                         * what to do with this.
-                         */
-
-                        return -EINVAL;
-                      }
-
-                    found |= USBHOST_BINFOUND;
-
-                    /* Save the bulk IN endpoint information */
-
-                    bindesc.hport        = hport;
-                    bindesc.addr         = epdesc->addr &
-                                           USB_EP_ADDR_NUMBER_MASK;
-                    bindesc.in           = 1;
-                    bindesc.xfrtype      = USB_EP_ATTR_XFER_BULK;
-                    bindesc.interval     = epdesc->interval;
-                    bindesc.mxpacketsize =
-                      usbhost_getle16(epdesc->mxpacketsize);
-
-                    uinfo("Bulk IN EP addr:%d mxpacketsize:%d\n",
-                          bindesc.addr, bindesc.mxpacketsize);
-                  }
-              }
-          }
-          break;
+          /* Endpoint descriptor.  We expect two bulk endpoints, an IN and an
+           * OUT.
+           */
 
-        /* Other descriptors are just ignored for now */
+          case USB_DESC_TYPE_ENDPOINT:
+            {
+              FAR struct usb_epdesc_s *epdesc =
+                (FAR struct usb_epdesc_s *)configdesc;
 
-        default:
-          break;
+              uinfo("Endpoint descriptor\n");
+              DEBUGASSERT(remaining >= USB_SIZEOF_EPDESC);
+
+              /* Check for a bulk endpoint.  We only support the bulk-only
+               * protocol so I suppose anything else should really be an
+               * error.
+               */
+
+              if ((epdesc->attr & USB_EP_ATTR_XFERTYPE_MASK) ==
+                  USB_EP_ATTR_XFER_BULK)
+                {
+                  /* Yes.. it is a bulk endpoint.  IN or OUT? */
+
+                  if (USB_ISEPOUT(epdesc->addr))
+                    {
+                      /* It is an OUT bulk endpoint.  There should be only
+                       * one bulk OUT endpoint.
+                       */
+
+                      if ((found & USBHOST_BOUTFOUND) != 0)
+                        {
+                          /* Oops.. more than one endpoint.  We don't know
+                           * what to do with this.
+                           */
+
+                          return -EINVAL;
+                        }
+
+                      found |= USBHOST_BOUTFOUND;
+
+                      /* Save the bulk OUT endpoint information */
+
+                      boutdesc.hport        = hport;
+                      boutdesc.addr         = epdesc->addr &
+                                              USB_EP_ADDR_NUMBER_MASK;
+                      boutdesc.in           = false;
+                      boutdesc.xfrtype      = USB_EP_ATTR_XFER_BULK;
+                      boutdesc.interval     = epdesc->interval;
+                      boutdesc.mxpacketsize =
+                        usbhost_getle16(epdesc->mxpacketsize);
+
+                      uinfo("Bulk OUT EP addr:%d mxpacketsize:%d\n",
+                            boutdesc.addr, boutdesc.mxpacketsize);
+                    }
+                  else
+                    {
+                      /* It is an IN bulk endpoint.  There should be only one
+                       * bulk IN endpoint.
+                       */
+
+                      if ((found & USBHOST_BINFOUND) != 0)
+                        {
+                          /* Oops.. more than one endpoint.  We don't know
+                           * what to do with this.
+                           */
+
+                          return -EINVAL;
+                        }
+
+                      found |= USBHOST_BINFOUND;
+
+                      /* Save the bulk IN endpoint information */
+
+                      bindesc.hport        = hport;
+                      bindesc.addr         = epdesc->addr &
+                                             USB_EP_ADDR_NUMBER_MASK;
+                      bindesc.in           = 1;
+                      bindesc.xfrtype      = USB_EP_ATTR_XFER_BULK;
+                      bindesc.interval     = epdesc->interval;
+                      bindesc.mxpacketsize =
+                        usbhost_getle16(epdesc->mxpacketsize);
+
+                      uinfo("Bulk IN EP addr:%d mxpacketsize:%d\n",
+                            bindesc.addr, bindesc.mxpacketsize);
+                    }
+                }
+            }
+            break;
+
+          /* Other descriptors are just ignored for now */
+
+          default:
+            break;
         }
 
       /* If we found everything we need with this interface, then break out

Reply via email to