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/01 03:12:57 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6653: Driver/sensor: enhance sensor driver to support uorb and multi core access sensor by rpmsg

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


##########
drivers/sensors/sensor.c:
##########
@@ -609,35 +733,45 @@ static int sensor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
   FAR struct sensor_upperhalf_s *upper = inode->i_private;
   FAR struct sensor_lowerhalf_s *lower = upper->lower;
   FAR struct sensor_user_s *user = filep->f_priv;
-  int ret;
+  int ret = 0;
 
   sninfo("cmd=%x arg=%08lx\n", cmd, arg);
 
-  ret = nxsem_wait(&upper->exclsem);
-  if (ret < 0)
-    {
-      return ret;
-    }
-
   switch (cmd)
     {
       case SNIOC_GET_STATE:
         {
+          nxrmutex_lock(&upper->lock);
           memcpy((FAR void *)(uintptr_t)arg,
                  &upper->state, sizeof(upper->state));
           user->changed = false;
+          nxrmutex_unlock(&upper->lock);
+        }
+        break;
+
+      case SNIOC_GET_USTATE:
+        {
+          nxrmutex_lock(&upper->lock);

Review Comment:
   Since other place(e.g. SNIOC_SET_INTERVAL) which modify field in user->state is locked by upper->lock. 



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