pkarashchenko commented on code in PR #6226:
URL: https://github.com/apache/incubator-nuttx/pull/6226#discussion_r872973586


##########
arch/xtensa/src/esp32/esp32_i2c.c:
##########
@@ -723,31 +723,10 @@ static void esp32_i2c_reset_fsmc(struct esp32_i2c_priv_s 
*priv)
 #ifndef CONFIG_I2C_POLLED
 static int esp32_i2c_sem_waitdone(struct esp32_i2c_priv_s *priv)
 {
-  int ret;
-  struct timespec abstime;
-
-  /* Get the current absolute time and adds a offset as timeout */
-
-  clock_gettime(CLOCK_REALTIME, &abstime);
-
-#if CONFIG_ESP32_I2CTIMEOSEC > 0
-  abstime.tv_sec += CONFIG_ESP32_I2CTIMEOSEC;
-#endif
-
-#if CONFIG_ESP32_I2CTIMEOMS > 0
-  abstime.tv_nsec += CONFIG_ESP32_I2CTIMEOMS * NSEC_PER_MSEC;
-  if (abstime.tv_nsec >= 1000 * NSEC_PER_MSEC)
-    {
-      abstime.tv_sec++;
-      abstime.tv_nsec -= 1000 * NSEC_PER_MSEC;
-    }
-#endif
-
   /* Wait on ISR semaphore */
 
-  ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
-
-  return ret;
+  return nxsem_tickwait_uninterruptible(&priv->sem_isr,
+    SEC2TICK(CONFIG_ESP32_I2CTIMEOSEC) + MSEC2TICK(CONFIG_ESP32_I2CTIMEOMS));

Review Comment:
   Lets add
   ```
   #define ESP32_I2CTIMEOTICKS \
       (SEC2TICK(CONFIG_ESP32_I2CTIMEOSEC) + MSEC2TICK(CONFIG_ESP32_I2CTIMEOMS))
   ```
   and use it here



##########
net/route/ramroute.h:
##########
@@ -200,19 +200,19 @@ void net_freeroute_ipv6(FAR struct net_route_ipv6_s 
*route);
 void ramroute_ipv4_addlast(FAR struct net_route_ipv4_entry_s *entry,
                            FAR struct net_route_ipv4_queue_s *list);
 FAR struct net_route_ipv4_entry_s *
-  ramroute_ipv4_remfirst(struct net_route_ipv4_queue_s *list);
+ramroute_ipv4_remfirst(struct net_route_ipv4_queue_s *list);
 FAR struct net_route_ipv4_entry_s *
-  ramroute_ipv4_remafter(FAR struct net_route_ipv4_entry_s *entry,
+ramroute_ipv4_remafter(FAR struct net_route_ipv4_entry_s *entry,
                          FAR struct net_route_ipv4_queue_s *list);

Review Comment:
   ```suggestion
   ramroute_ipv4_remafter(FAR struct net_route_ipv4_entry_s *entry,
                          FAR struct net_route_ipv4_queue_s *list);
   ```



##########
net/route/ramroute.h:
##########
@@ -200,19 +200,19 @@ void net_freeroute_ipv6(FAR struct net_route_ipv6_s 
*route);
 void ramroute_ipv4_addlast(FAR struct net_route_ipv4_entry_s *entry,
                            FAR struct net_route_ipv4_queue_s *list);
 FAR struct net_route_ipv4_entry_s *
-  ramroute_ipv4_remfirst(struct net_route_ipv4_queue_s *list);
+ramroute_ipv4_remfirst(struct net_route_ipv4_queue_s *list);
 FAR struct net_route_ipv4_entry_s *
-  ramroute_ipv4_remafter(FAR struct net_route_ipv4_entry_s *entry,
+ramroute_ipv4_remafter(FAR struct net_route_ipv4_entry_s *entry,
                          FAR struct net_route_ipv4_queue_s *list);
 #endif
 
 #ifdef CONFIG_ROUTE_IPv6_RAMROUTE
 void ramroute_ipv6_addlast(FAR struct net_route_ipv6_entry_s *entry,
                            FAR struct net_route_ipv6_queue_s *list);
 FAR struct net_route_ipv6_entry_s *
-  ramroute_ipv6_remfirst(struct net_route_ipv6_queue_s *list);
+ramroute_ipv6_remfirst(struct net_route_ipv6_queue_s *list);
 FAR struct net_route_ipv6_entry_s *
-  ramroute_ipv6_remafter(FAR struct net_route_ipv6_entry_s *entry,
+ramroute_ipv6_remafter(FAR struct net_route_ipv6_entry_s *entry,
   struct net_route_ipv6_queue_s *list);

Review Comment:
   ```suggestion
   ramroute_ipv6_remafter(FAR struct net_route_ipv6_entry_s *entry,
                          FAR struct net_route_ipv6_queue_s *list);
   ```



##########
sched/semaphore/sem_tickwait.c:
##########
@@ -165,19 +145,24 @@ int nxsem_tickwait(FAR sem_t *sem, clock_t start, 
uint32_t delay)
  *
  ****************************************************************************/
 
-int nxsem_tickwait_uninterruptible(FAR sem_t *sem, clock_t start,
-                                   uint32_t delay)
+int nxsem_tickwait_uninterruptible(FAR sem_t *sem, uint32_t delay)
 {
-  int ret;
+  clock_t end = clock_systime_ticks() + delay;
 
-  do
+  for (; ; )
     {
       /* Take the semaphore (perhaps waiting) */
 
-      ret = nxsem_tickwait(sem, start, delay);
+      int ret = nxsem_tickwait(sem, delay);
+      if (ret != -EINTR)
+        {
+          return ret;

Review Comment:
   let's add `break` and move `return ret;` to the end of the function scope



##########
net/route/ramroute.h:
##########
@@ -200,19 +200,19 @@ void net_freeroute_ipv6(FAR struct net_route_ipv6_s 
*route);
 void ramroute_ipv4_addlast(FAR struct net_route_ipv4_entry_s *entry,
                            FAR struct net_route_ipv4_queue_s *list);
 FAR struct net_route_ipv4_entry_s *
-  ramroute_ipv4_remfirst(struct net_route_ipv4_queue_s *list);
+ramroute_ipv4_remfirst(struct net_route_ipv4_queue_s *list);
 FAR struct net_route_ipv4_entry_s *
-  ramroute_ipv4_remafter(FAR struct net_route_ipv4_entry_s *entry,
+ramroute_ipv4_remafter(FAR struct net_route_ipv4_entry_s *entry,
                          FAR struct net_route_ipv4_queue_s *list);
 #endif
 
 #ifdef CONFIG_ROUTE_IPv6_RAMROUTE
 void ramroute_ipv6_addlast(FAR struct net_route_ipv6_entry_s *entry,
                            FAR struct net_route_ipv6_queue_s *list);
 FAR struct net_route_ipv6_entry_s *
-  ramroute_ipv6_remfirst(struct net_route_ipv6_queue_s *list);
+ramroute_ipv6_remfirst(struct net_route_ipv6_queue_s *list);

Review Comment:
   ```suggestion
   ramroute_ipv6_remfirst(FAR struct net_route_ipv6_queue_s *list);
   ```



##########
arch/risc-v/src/esp32c3/esp32c3_i2c.c:
##########
@@ -793,27 +793,9 @@ static void esp32c3_i2c_reset_fsmc(struct 
esp32c3_i2c_priv_s *priv)
 #ifndef CONFIG_I2C_POLLED
 static int esp32c3_i2c_sem_waitdone(struct esp32c3_i2c_priv_s *priv)
 {
-  int ret;
-  struct timespec abstime;
-
-  clock_gettime(CLOCK_REALTIME, &abstime);
-
-#if CONFIG_ESP32C3_I2CTIMEOSEC > 0
-  abstime.tv_sec += CONFIG_ESP32C3_I2CTIMEOSEC;
-#endif
-
-#if CONFIG_ESP32C3_I2CTIMEOMS > 0
-  abstime.tv_nsec += CONFIG_ESP32C3_I2CTIMEOMS * NSEC_PER_MSEC;
-  if (abstime.tv_nsec >= 1000 * NSEC_PER_MSEC)
-    {
-      abstime.tv_sec++;
-      abstime.tv_nsec -= 1000 * NSEC_PER_MSEC;
-    }
-#endif
-
-  ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
-
-  return ret;
+  return nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                                      SEC2TICK(CONFIG_ESP32C3_I2CTIMEOSEC) +
+                                      MSEC2TICK(CONFIG_ESP32C3_I2CTIMEOMS));

Review Comment:
   Lets add
   ```
   #define ESP32C3_I2CTIMEOTICKS \
       (SEC2TICK(CONFIG_ESP32C3_I2CTIMEOSEC) + 
MSEC2TICK(CONFIG_ESP32C3_I2CTIMEOMS))
   ```
   and use it here



##########
net/route/ramroute.h:
##########
@@ -200,19 +200,19 @@ void net_freeroute_ipv6(FAR struct net_route_ipv6_s 
*route);
 void ramroute_ipv4_addlast(FAR struct net_route_ipv4_entry_s *entry,
                            FAR struct net_route_ipv4_queue_s *list);
 FAR struct net_route_ipv4_entry_s *
-  ramroute_ipv4_remfirst(struct net_route_ipv4_queue_s *list);
+ramroute_ipv4_remfirst(struct net_route_ipv4_queue_s *list);

Review Comment:
   ```suggestion
   ramroute_ipv4_remfirst(FAR struct net_route_ipv4_queue_s *list);
   ```



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