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



##########
File path: drivers/input/ajoystick.c
##########
@@ -722,6 +720,19 @@ static int ajoy_poll(FAR struct file *filep, FAR struct 
pollfd *fds,
 
               opriv->ao_fds[i] = fds;
               fds->priv = &opriv->ao_fds[i];
+
+              /* Report if the event is pending */
+
+              if (opriv->ao_pollpending)
+                {
+                  fds->revents |= (fds->events & POLLIN);
+                  if (fds->revents != 0)
+                    {
+                      iinfo("Report events: %02x\n", fds->revents);
+                      nxsem_post(fds->sem);

Review comment:
       Why do we need to `nxsem_post(fds->sem);` here? 

##########
File path: drivers/input/ajoystick.c
##########
@@ -194,19 +194,8 @@ static void ajoy_enable(FAR struct ajoy_upperhalf_s *priv)
 
   for (opriv = priv->au_open; opriv; opriv = opriv->ao_flink)
     {
-      /* Are there any poll waiters? */
-
-      for (i = 0; i < CONFIG_INPUT_AJOYSTICK_NPOLLWAITERS; i++)
-        {
-          if (opriv->ao_fds[i])
-            {
-              /* Yes.. OR in the poll event buttons */
-
-              press   |= opriv->ao_pollevents.ap_press;
-              release |= opriv->ao_pollevents.ap_release;
-              break;
-            }
-        }
+      press   |= opriv->ao_pollevents.ap_press;

Review comment:
       So now we `|=` even in there are no waiters?

##########
File path: drivers/input/ajoystick.c
##########
@@ -100,6 +100,7 @@ struct ajoy_open_s
    * driver events.
    */
 
+  bool ao_pollpending;

Review comment:
       Why this reside here and not in `struct btn_upperhalf_s`? I'm just 
thinking from the analogy with network sockets. If data arrive and there are 
many waiters, then only one can read the data and not all. Or I'm missing 
something?

##########
File path: drivers/input/button_upper.c
##########
@@ -97,6 +97,7 @@ struct btn_open_s
    */
 
   FAR struct pollfd *bo_fds[CONFIG_INPUT_BUTTONS_NPOLLWAITERS];
+  bool bo_pending;

Review comment:
       ```suggestion
     bool bo_pending;
     FAR struct pollfd *bo_fds[CONFIG_INPUT_BUTTONS_NPOLLWAITERS];
   ```
   Just for consistency with other files




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