pkarashchenko commented on a change in pull request #5204:
URL: https://github.com/apache/incubator-nuttx/pull/5204#discussion_r821687232



##########
File path: drivers/input/ajoystick.c
##########
@@ -526,12 +461,7 @@ static ssize_t ajoy_read(FAR struct file *filep, FAR char 
*buffer,
 
   /* Get exclusive access to the driver structure */
 
-  ret = ajoy_takesem(&priv->au_exclsem);
-  if (ret < 0)
-    {
-      ierr("ERROR: ajoy_takesem failed: %d\n", ret);
-      return ret;
-    }
+  flags = enter_critical_section();

Review comment:
       @xiaoxiang781216 thank you. Yes, the reuse of data by VFS is still an 
unhanded problem. Now I agree to keep your previous version
   ```
   static ssize_t ajoy_read(FAR struct file *filep, FAR char *buffer,
                            size_t len)
   {
     FAR struct inode *inode;
     FAR struct ajoy_open_s *opriv;
     FAR struct ajoy_upperhalf_s *priv;
     FAR const struct ajoy_lowerhalf_s *lower;
     int ret;
   
     DEBUGASSERT(filep && filep->f_inode);
     opriv = filep->f_priv;
     inode = filep->f_inode;
     DEBUGASSERT(inode->i_private);
     priv  = (FAR struct ajoy_upperhalf_s *)inode->i_private;
   
     /* Make sure that the buffer is sufficiently large to hold at least one
      * complete sample.
      *
      * REVISIT:  Should also check buffer alignment.
      */
   
     if (len < sizeof(struct ajoy_sample_s))
       {
         ierr("ERROR: buffer too small: %lu\n", (unsigned long)len);
         return -EINVAL;
       }
   
     /* Get exclusive access to the driver structure */
   
     flags = enter_critical_section();
   
     /* Read and return the current state of the joystick buttons */
   
     lower = priv->au_lower;
     DEBUGASSERT(lower && lower->al_sample);
     ret = lower->al_sample(lower, (FAR struct ajoy_sample_s *)buffer);
     if (ret >= 0)
       {
         opriv->ao_pollpending = false;
         ret = sizeof(struct ajoy_sample_s);
       }
   
     leave_critical_section(flags);
     return (ssize_t)ret;
   }
   ```
   and resolve a limitation of a driver based on VFS device in a different way. 
This will be a limitation for now.




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