xiaoxiang781216 commented on code in PR #6524:
URL: https://github.com/apache/incubator-nuttx/pull/6524#discussion_r906813067


##########
drivers/wireless/ieee80211/bcm43xxx/bcmf_sdpcm.c:
##########
@@ -141,102 +141,75 @@ int bcmf_sdpcm_readframe(FAR struct bcmf_dev_s *priv)
   uint16_t len;
   uint16_t checksum;
   struct bcmf_sdpcm_header *header;
-  struct bcmf_sdpcm_header tmp_hdr;
   struct bcmf_sdio_frame *sframe;
   FAR struct bcmf_sdio_dev_s *sbus = (FAR struct bcmf_sdio_dev_s *)priv->bus;
 
+  /* Request free frame buffer */
+
+  sframe = bcmf_sdio_allocate_frame(priv, false, false);
+  if (sframe == NULL)
+    {
+      return -ENOMEM;
+    }
+
+  header = (struct bcmf_sdpcm_header *)sframe->data;
+
   /* Read the first 4 bytes of sdpcm header
    * to get the length of the following data to be read
    */
 
   ret = bcmf_transfer_bytes(sbus, false, 2, 0,
-                            (uint8_t *)&tmp_hdr,
+                            (uint8_t *)header,
                             FIRST_WORD_SIZE);
   if (ret != OK)
     {
       wlinfo("Failed to read size\n");
-      bcmf_sdpcm_rxfail(sbus, false);
-      return -EIO;
+      ret = -EIO;

Review Comment:
   why change error code



##########
drivers/wireless/ieee80211/bcm43xxx/bcmf_sdpcm.c:
##########
@@ -141,102 +141,75 @@ int bcmf_sdpcm_readframe(FAR struct bcmf_dev_s *priv)
   uint16_t len;
   uint16_t checksum;
   struct bcmf_sdpcm_header *header;
-  struct bcmf_sdpcm_header tmp_hdr;
   struct bcmf_sdio_frame *sframe;
   FAR struct bcmf_sdio_dev_s *sbus = (FAR struct bcmf_sdio_dev_s *)priv->bus;
 
+  /* Request free frame buffer */
+
+  sframe = bcmf_sdio_allocate_frame(priv, false, false);
+  if (sframe == NULL)
+    {
+      return -ENOMEM;
+    }
+
+  header = (struct bcmf_sdpcm_header *)sframe->data;
+
   /* Read the first 4 bytes of sdpcm header
    * to get the length of the following data to be read
    */
 
   ret = bcmf_transfer_bytes(sbus, false, 2, 0,
-                            (uint8_t *)&tmp_hdr,
+                            (uint8_t *)header,
                             FIRST_WORD_SIZE);
   if (ret != OK)
     {
       wlinfo("Failed to read size\n");
-      bcmf_sdpcm_rxfail(sbus, false);
-      return -EIO;
+      ret = -EIO;
+      goto exit_abort;
     }
 
-  len = tmp_hdr.size;
-  checksum = tmp_hdr.checksum;
+  len = header->size;
+  checksum = header->checksum;
 
   /* All zero means no more to read */
 
   if (!(len | checksum))
     {
-      return -ENODATA;
+      ret = -ENODATA;
+      goto exit_free_frame;
     }
 
   if (((~len & 0xffff) ^ checksum) || len < sizeof(struct bcmf_sdpcm_header))
     {
       wlerr("Invalid header checksum or len %x %x\n", len, checksum);
-      bcmf_sdpcm_rxfail(sbus, false);
-      return -EINVAL;
+      ret = -EINVAL;
+      goto exit_abort;
     }
 
   if (len == FC_UPDATE_PKT_LENGTH)
     {
       /* Flow control update packet with no data */
 
       ret = bcmf_transfer_bytes(sbus, false, 2, 0,
-                                (uint8_t *)&tmp_hdr + FIRST_WORD_SIZE,
+                                (uint8_t *)header + FIRST_WORD_SIZE,
                                 FC_UPDATE_PKT_LENGTH - FIRST_WORD_SIZE);
       if (ret != OK)
         {
           wlinfo("Failed to read the rest 8 bytes\n");
-          bcmf_sdpcm_rxfail(sbus, false);
-          return -EIO;
+          ret = -EIO;

Review Comment:
   ditto



##########
drivers/wireless/ieee80211/bcm43xxx/bcmf_sdpcm.c:
##########
@@ -141,102 +141,75 @@ int bcmf_sdpcm_readframe(FAR struct bcmf_dev_s *priv)
   uint16_t len;
   uint16_t checksum;
   struct bcmf_sdpcm_header *header;
-  struct bcmf_sdpcm_header tmp_hdr;
   struct bcmf_sdio_frame *sframe;
   FAR struct bcmf_sdio_dev_s *sbus = (FAR struct bcmf_sdio_dev_s *)priv->bus;
 
+  /* Request free frame buffer */
+
+  sframe = bcmf_sdio_allocate_frame(priv, false, false);

Review Comment:
   why not blocking



##########
drivers/wireless/ieee80211/bcm43xxx/bcmf_sdpcm.c:
##########
@@ -410,7 +381,6 @@ int bcmf_sdpcm_sendframe(FAR struct bcmf_dev_s *priv)
 
           bcmf_netdev_notify_tx(priv);
         }
-

Review Comment:
   move to previous 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-unsubscr...@nuttx.apache.org

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

Reply via email to