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/08/31 15:00:02 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6965: nxmutex replace nxsem when used as a lock

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


##########
include/nuttx/semaphore.h:
##########
@@ -74,6 +74,7 @@
 #  define _SEM_WAIT(s)          nxsem_wait(s)
 #  define _SEM_TRYWAIT(s)       nxsem_trywait(s)
 #  define _SEM_TIMEDWAIT(s,t)   nxsem_timedwait(s,t)
+#  define _SEM_TICKWAIT(s,t)   nxsem_timedwait(s,t)

Review Comment:
   why add



##########
fs/hostfs/hostfs.c:
##########
@@ -122,8 +123,7 @@ static int     hostfs_chstat(FAR struct inode *mountpt,
  * Private Data
  ****************************************************************************/
 
-static uint8_t  g_seminitialized = FALSE;
-static sem_t    g_sem;
+static mutex_t g_lock;

Review Comment:
   need add NXMUTEX_INITxxxx



##########
drivers/wireless/ieee80211/bcm43xxx/bcmf_driver.c:
##########
@@ -173,6 +173,59 @@ static int bcmf_wl_channel_to_frequency(int chan)
   return 0; /* not supported */
 }
 
+FAR struct bcmf_dev_s *bcmf_allocate_device(void)

Review Comment:
   why add



##########
drivers/input/button_upper.c:
##########
@@ -40,6 +40,7 @@
 #include <debug.h>
 
 #include <nuttx/kmalloc.h>
+#include <nuttx/mutex.h>

Review Comment:
   why add



##########
drivers/input/button_upper.c:
##########
@@ -460,7 +461,6 @@ static ssize_t btn_read(FAR struct file *filep, FAR char *buffer,
   opriv->bo_pending = false;
 
   leave_critical_section(flags);
-  return (ssize_t)sizeof(btn_buttonset_t);

Review Comment:
   why remove



##########
net/local/local_connect.c:
##########
@@ -31,6 +31,7 @@
 #include <queue.h>
 #include <debug.h>
 
+#include <nuttx/mutex.h>

Review Comment:
   revert



##########
wireless/bluetooth/bt_netdev.c:
##########
@@ -103,7 +104,7 @@ struct btnet_driver_s
 
   /* For internal use by this driver */
 
-  sem_t bd_exclsem;                  /* Exclusive access to struct */
+  mutex_t bd_excllock;                /* Exclusive access to struct */

Review Comment:
   fix the comment alignment



##########
arch/arm/src/lpc17xx_40xx/lpc17_40_gpdma.c:
##########
@@ -613,7 +613,7 @@ void lpc17_40_dmastop(DMA_HANDLE handle)
 
   /* Disable this channel and mask any further interrupts from the channel.
    * this channel.  The channel is disabled by clearning the channel
-   * enable bit. Any outstanding data in the FIFO�s is lost.
+   * enable bit. Any outstanding data in the FIFO�s is lost.

Review Comment:
   revert this change



##########
net/local/local_connect.c:
##########
@@ -152,7 +138,7 @@ static int inline local_stream_connect(FAR struct local_conn_s *client,
     {
       do
         {
-          _local_semtake(&client->lc_waitsem);

Review Comment:
   why change



##########
include/nuttx/semaphore.h:
##########
@@ -87,6 +88,7 @@
 #  define _SEM_WAIT(s)          sem_wait(s)
 #  define _SEM_TRYWAIT(s)       sem_trywait(s)
 #  define _SEM_TIMEDWAIT(s,t)   sem_timedwait(s,t)
+#  define _SEM_TICKWAIT(s,t)   sem_timedwait(s,t)

Review Comment:
   ditto



##########
fs/vfs/fs_eventfd.c:
##########
@@ -254,7 +255,7 @@ static int eventfd_do_close(FAR struct file *filep)
 
   unregister_driver(devpath);
 
-  DEBUGASSERT(priv->exclsem.semcount == 0);
+  DEBUGASSERT(nxmutex_is_locked(priv->excllock) > 0);

Review Comment:
   remove `> 0`



##########
libs/libc/libc.h:
##########
@@ -74,13 +74,6 @@ extern "C"
  * Public Function Prototypes
  ****************************************************************************/
 
-/* Defined in lib_streamsem.c */
-
-#ifdef CONFIG_FILE_STREAM
-void  lib_stream_semtake(FAR struct streamlist *list);

Review Comment:
   we need keep libc as before since mutex api is for kernel only



##########
net/local/local_connect.c:
##########
@@ -143,7 +129,7 @@ static int inline local_stream_connect(FAR struct local_conn_s *client,
 
   if (nxsem_get_value(&server->lc_waitsem, &sval) >= 0 && sval < 1)
     {
-      _local_semgive(&server->lc_waitsem);
+      nxsem_post(&server->lc_waitsem);

Review Comment:
   why change



-- 
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