You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/05/15 10:56:05 UTC

[incubator-nuttx] branch master updated (08002a0a38 -> 51cf7ba05a)

This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


    from 08002a0a38 sched: Replace pthread_sem_take with nxsem_wait_uninterruptible
     new 22e4f1c59a sched: Remove start from nxsem_tickwait[_uninterruptible]
     new 816ce73ab4 Replace nxsem_timedwait with nxsem_tickwait
     new 1fb8c13e5e Replace nxsem_timedwait_uninterruptible with nxsem_tickwait_uninterruptible
     new 2976accd9f arch: Remove the extra space before the function prototype
     new f905563cc9 tools/nxstyle: Add kbps to the while suffix list
     new 51cf7ba05a Remove FAR from arm/risc-v/xtensa/sim/x86

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/arm/src/am335x/am335x_i2c.c                   |  41 ++-----
 arch/arm/src/cxd56xx/cxd56_gnss.c                  |  13 +-
 arch/arm/src/cxd56xx/cxd56_usbdev.c                |   2 +-
 arch/arm/src/efm32/efm32_i2c.c                     |  46 ++-----
 arch/arm/src/imxrt/imxrt_lpi2c.c                   |  81 +++++--------
 arch/arm/src/kinetis/kinetis_i2c.c                 |   6 +-
 arch/arm/src/lc823450/lc823450_i2c.c               |  75 +++++-------
 arch/arm/src/rp2040/rp2040_usbdev.c                |   2 +-
 arch/arm/src/rtl8720c/amebaz_depend.c              |  15 +--
 arch/arm/src/s32k1xx/s32k1xx_lpi2c.c               | 135 +++++++++------------
 arch/arm/src/samd2l2/sam_i2c_master.c              |  17 +--
 arch/arm/src/samd5e5/sam_i2c_master.c              |  17 +--
 arch/arm/src/stm32/stm32_1wire.c                   |  13 +-
 arch/arm/src/stm32/stm32_hrtim.c                   |   4 +-
 arch/arm/src/stm32/stm32_i2c.c                     |  43 ++-----
 arch/arm/src/stm32/stm32_i2c_alt.c                 |  43 ++-----
 arch/arm/src/stm32/stm32_i2c_v2.c                  |  41 ++-----
 arch/arm/src/stm32/stm32f40xxx_i2c.c               |  43 ++-----
 arch/arm/src/stm32f0l0g0/stm32_i2c.c               |  41 ++-----
 arch/arm/src/stm32f7/stm32_i2c.c                   |  41 ++-----
 arch/arm/src/stm32h7/stm32_fdcan_sock.c            |  84 ++++++-------
 arch/arm/src/stm32h7/stm32_i2c.c                   |  41 ++-----
 arch/arm/src/stm32l4/stm32l4_1wire.c               |  13 +-
 arch/arm/src/stm32l4/stm32l4_i2c.c                 |  43 ++-----
 arch/arm/src/stm32l4/stm32l4_otgfsdev.c            |   4 +-
 arch/arm/src/stm32l4/stm32l4_otgfshost.c           |   4 +-
 arch/arm/src/stm32l4/stm32l4_pwm.c                 |   2 +-
 arch/arm/src/tiva/common/tiva_i2c.c                |  43 ++-----
 arch/mips/src/pic32mx/pic32mx_ethernet.c           |   4 +-
 arch/mips/src/pic32mz/pic32mz_ethernet.c           |   2 +-
 arch/mips/src/pic32mz/pic32mz_i2c.c                |  93 ++++++--------
 arch/mips/src/pic32mz/pic32mz_timer.c              |   4 +-
 arch/risc-v/src/bl602/bl602_os_hal.c               |  15 +--
 arch/risc-v/src/esp32c3/esp32c3_ble_adapter.c      |  12 +-
 arch/risc-v/src/esp32c3/esp32c3_i2c.c              |  48 ++------
 arch/risc-v/src/esp32c3/esp32c3_spi.c              |  12 +-
 arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c     |  15 +--
 arch/risc-v/src/esp32c3/esp32c3_wifi_utils.c       |   5 +-
 arch/risc-v/src/mpfs/mpfs_i2c.c                    |  12 +-
 arch/risc-v/src/mpfs/mpfs_spi.c                    |  12 +-
 arch/x86/src/common/up_allocateheap.c              |   4 +-
 arch/x86/src/common/up_assert.c                    |   6 +-
 arch/x86/src/common/up_exit.c                      |   4 +-
 arch/x86/src/i486/up_createstack.c                 |   2 +-
 arch/x86/src/i486/up_releasestack.c                |   2 +-
 arch/x86/src/i486/up_stackframe.c                  |   6 +-
 arch/x86/src/qemu/qemu.h                           |  12 +-
 arch/x86/src/qemu/qemu_keypad.c                    |   4 +-
 arch/x86/src/qemu/qemu_vga.c                       |  38 +++---
 arch/x86/src/qemu/qemu_vga.h                       |   2 +-
 arch/xtensa/src/esp32/esp32_ble_adapter.c          |  15 +--
 arch/xtensa/src/esp32/esp32_i2c.c                  |  49 ++------
 arch/xtensa/src/esp32/esp32_spi.c                  |  12 +-
 arch/xtensa/src/esp32/esp32_spiflash.c             |   6 +-
 arch/xtensa/src/esp32/esp32_wifi_adapter.c         |  15 +--
 arch/xtensa/src/esp32/esp32_wifi_utils.c           |   5 +-
 .../samd21-xplained/src/sam_ug2832hsweg04.c        |   6 +-
 boards/arm/stm32/nucleo-g474re/src/stm32_usbdev.c  |   2 +-
 drivers/can/can.c                                  |  13 +-
 drivers/contactless/pn532.c                        |   5 +-
 drivers/modem/altair/altmdm_sys.c                  |  33 +----
 drivers/sensors/lps25h.c                           |  13 +-
 drivers/wireless/bluetooth/bt_uart_bcm4343x.c      |  18 +--
 drivers/wireless/ieee80211/bcm43xxx/bcmf_utils.c   |  19 +--
 drivers/wireless/nrf24l01.c                        |   3 +-
 fs/vfs/fs_poll.c                                   |   2 +-
 include/nuttx/semaphore.h                          |  15 +--
 libs/libc/machine/arm/aeabi_memclr.c               |   2 +-
 libs/libc/machine/arm/aeabi_memclr4.c              |   2 +-
 libs/libc/machine/arm/aeabi_memclr8.c              |   2 +-
 libs/libc/machine/arm/aeabi_memcpy.c               |   2 +-
 libs/libc/machine/arm/aeabi_memcpy4.c              |   2 +-
 libs/libc/machine/arm/aeabi_memcpy8.c              |   2 +-
 libs/libc/machine/arm/aeabi_memmove.c              |   2 +-
 libs/libc/machine/arm/aeabi_memmove4.c             |   2 +-
 libs/libc/machine/arm/aeabi_memmove8.c             |   2 +-
 libs/libc/machine/arm/aeabi_memset.c               |   2 +-
 libs/libc/machine/arm/aeabi_memset4.c              |   2 +-
 libs/libc/machine/arm/aeabi_memset8.c              |   2 +-
 libs/libc/machine/arm/arm/arch_elf.c               |   7 +-
 libs/libc/machine/arm/armv6-m/arch_elf.c           |   7 +-
 libs/libc/machine/arm/armv7-a/arch_elf.c           |   7 +-
 libs/libc/machine/arm/armv7-m/arch_elf.c           |   7 +-
 libs/libc/machine/arm/armv7-r/arch_elf.c           |   7 +-
 libs/libc/machine/arm/armv8-m/arch_elf.c           |   7 +-
 libs/libc/machine/risc-v/common/arch_elf.c         |   7 +-
 libs/libc/machine/sim/arch_elf.c                   |   9 +-
 libs/libc/machine/sim/arch_elf64.c                 |   7 +-
 libs/libc/machine/x86/arch_elf.c                   |   9 +-
 libs/libc/machine/xtensa/arch_elf.c                |  13 +-
 mm/iob/iob_alloc.c                                 |  14 +--
 net/route/net_queue_ramroute.c                     |  12 +-
 net/route/ramroute.h                               |  12 +-
 net/utils/net_lock.c                               |  18 +--
 sched/semaphore/sem_clockwait.c                    |   2 +-
 sched/semaphore/sem_tickwait.c                     |  42 +++----
 tools/nxstyle.c                                    |   7 +-
 wireless/bluetooth/bt_hcicore.c                    |  37 +-----
 98 files changed, 516 insertions(+), 1237 deletions(-)


[incubator-nuttx] 03/06: Replace nxsem_timedwait_uninterruptible with nxsem_tickwait_uninterruptible

Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 1fb8c13e5e80ee4cd5758e76821378162451c2fa
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Tue May 10 09:32:31 2022 +0800

    Replace nxsem_timedwait_uninterruptible with nxsem_tickwait_uninterruptible
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 arch/arm/src/efm32/efm32_i2c.c                | 42 ++++++-------------------
 arch/arm/src/imxrt/imxrt_lpi2c.c              | 43 ++++++-------------------
 arch/arm/src/lc823450/lc823450_i2c.c          | 27 +++-------------
 arch/arm/src/s32k1xx/s32k1xx_lpi2c.c          | 45 ++++++---------------------
 arch/arm/src/stm32/stm32_i2c.c                | 43 ++++++-------------------
 arch/arm/src/stm32/stm32_i2c_alt.c            | 43 ++++++-------------------
 arch/arm/src/stm32/stm32_i2c_v2.c             | 41 ++++++------------------
 arch/arm/src/stm32/stm32f40xxx_i2c.c          | 43 ++++++-------------------
 arch/arm/src/stm32f0l0g0/stm32_i2c.c          | 41 ++++++------------------
 arch/arm/src/stm32f7/stm32_i2c.c              | 41 ++++++------------------
 arch/arm/src/stm32h7/stm32_i2c.c              | 41 ++++++------------------
 arch/arm/src/stm32l4/stm32l4_i2c.c            | 41 ++++++------------------
 arch/arm/src/tiva/common/tiva_i2c.c           | 43 ++++++-------------------
 arch/mips/src/pic32mz/pic32mz_i2c.c           | 39 ++++++-----------------
 arch/risc-v/src/esp32c3/esp32c3_i2c.c         | 26 +++-------------
 arch/risc-v/src/esp32c3/esp32c3_spi.c         | 12 +------
 arch/risc-v/src/mpfs/mpfs_i2c.c               | 12 +------
 arch/risc-v/src/mpfs/mpfs_spi.c               | 12 +------
 arch/xtensa/src/esp32/esp32_i2c.c             | 27 +++-------------
 arch/xtensa/src/esp32/esp32_spi.c             | 12 +------
 drivers/modem/altair/altmdm_sys.c             | 33 ++------------------
 drivers/sensors/lps25h.c                      | 13 ++------
 drivers/wireless/bluetooth/bt_uart_bcm4343x.c | 18 +----------
 include/nuttx/semaphore.h                     |  2 +-
 mm/iob/iob_alloc.c                            | 14 +--------
 net/utils/net_lock.c                          | 18 ++---------
 sched/semaphore/sem_clockwait.c               |  2 +-
 wireless/bluetooth/bt_hcicore.c               | 37 ++--------------------
 28 files changed, 156 insertions(+), 655 deletions(-)

diff --git a/arch/arm/src/efm32/efm32_i2c.c b/arch/arm/src/efm32/efm32_i2c.c
index 59a8a3d866..eb0ede3f43 100644
--- a/arch/arm/src/efm32/efm32_i2c.c
+++ b/arch/arm/src/efm32/efm32_i2c.c
@@ -528,40 +528,10 @@ static useconds_t efm32_i2c_tousecs(int msgc, struct i2c_msg_s *msgs)
 #ifndef CONFIG_I2C_POLLED
 static inline int efm32_i2c_sem_waitdone(struct efm32_i2c_priv_s *priv)
 {
-  struct timespec abstime;
   int ret;
 
   do
     {
-      /* Get the current time */
-
-      clock_gettime(CLOCK_REALTIME, &abstime);
-
-      /* Calculate a time in the future */
-
-#if CONFIG_EFM32_I2CTIMEOSEC > 0
-      abstime.tv_sec += CONFIG_EFM32_I2CTIMEOSEC;
-#endif
-
-      /* Add a value proportional to the number of bytes in the transfer */
-
-#ifdef CONFIG_EFM32_I2C_DYNTIMEO
-      abstime.tv_nsec += 1000 * efm32_i2c_tousecs(priv->msgc, priv->msgv);
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
-
-#elif CONFIG_EFM32_I2CTIMEOMS > 0
-      abstime.tv_nsec += CONFIG_EFM32_I2CTIMEOMS * 1000 * 1000;
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
-#endif
-
       /* Enable I2C interrupts */
 
       efm32_i2c_putreg(priv, EFM32_I2C_IEN_OFFSET, I2C_IF_NACK | I2C_IF_ACK |
@@ -569,7 +539,13 @@ static inline int efm32_i2c_sem_waitdone(struct efm32_i2c_priv_s *priv)
 
       /* Wait until either the transfer is complete or the timeout expires */
 
-      ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
+#ifdef CONFIG_EFM32_I2C_DYNTIMEO
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                       USEC2TICK(efm32_i2c_tousecs(priv->msgc, priv->msgv)));
+#else
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                                           CONFIG_EFM32_I2CTIMEOTICKS);
+#endif
 
       /* Disable I2C interrupts */
 
@@ -579,7 +555,7 @@ static inline int efm32_i2c_sem_waitdone(struct efm32_i2c_priv_s *priv)
         {
           /* Break out of the loop on irrecoverable errors.  This would
            * include timeouts and mystery errors reported by
-           * nxsem_timedwait.
+           * nxsem_tickwait_uninterruptible.
            */
 
           break;
@@ -615,7 +591,7 @@ static inline int efm32_i2c_sem_waitdone(struct efm32_i2c_priv_s *priv)
 
   /* Signal the interrupt handler that we are waiting.  NOTE: Interrupts are
    * currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait_uninterruptible() sleeps.
    */
 
   start = clock_systime_ticks();
diff --git a/arch/arm/src/imxrt/imxrt_lpi2c.c b/arch/arm/src/imxrt/imxrt_lpi2c.c
index b230e37715..6f4750bc6d 100644
--- a/arch/arm/src/imxrt/imxrt_lpi2c.c
+++ b/arch/arm/src/imxrt/imxrt_lpi2c.c
@@ -581,7 +581,6 @@ static useconds_t imxrt_lpi2c_tousecs(int msgc, struct i2c_msg_s *msgs)
 static inline int
   imxrt_lpi2c_sem_waitdone(struct imxrt_lpi2c_priv_s *priv)
 {
-  struct timespec abstime;
   irqstate_t flags;
   uint32_t regval;
   int ret;
@@ -615,48 +614,26 @@ static inline int
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait_uninterruptible() sleeps.
    */
 
   priv->intstate = INTSTATE_WAITING;
   do
     {
-      /* Get the current time */
-
-      clock_gettime(CLOCK_REALTIME, &abstime);
-
-      /* Calculate a time in the future */
-
-#if CONFIG_IMXRT_LPI2C_TIMEOSEC > 0
-      abstime.tv_sec += CONFIG_IMXRT_LPI2C_TIMEOSEC;
-#endif
-
-      /* Add a value proportional to the number of bytes in the transfer */
+      /* Wait until either the transfer is complete or the timeout expires */
 
 #ifdef CONFIG_IMXRT_LPI2C_DYNTIMEO
-      abstime.tv_nsec += 1000 * imxrt_lpi2c_tousecs(priv->msgc, priv->msgv);
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
-
-#elif CONFIG_IMXRT_LPI2C_TIMEOMS > 0
-      abstime.tv_nsec += CONFIG_IMXRT_LPI2C_TIMEOMS * 1000 * 1000;
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                     USEC2TICK(imxrt_lpi2c_tousecs(priv->msgc, priv->msgv)));
+#else
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                                           CONFIG_IMXRT_LPI2C_TIMEOTICKS);
 #endif
-
-      /* Wait until either the transfer is complete or the timeout expires */
-
-      ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
       if (ret < 0)
         {
           /* Break out of the loop on irrecoverable errors.  This would
-           * include timeouts and mystery errors reported by nxsem_timedwait.
+           * include timeouts and mystery errors reported by
+           * nxsem_tickwait_uninterruptible.
            */
 
           break;
@@ -709,7 +686,7 @@ static inline int
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait_uninterruptible() sleeps.
    */
 
   priv->intstate = INTSTATE_WAITING;
diff --git a/arch/arm/src/lc823450/lc823450_i2c.c b/arch/arm/src/lc823450/lc823450_i2c.c
index c308ed905a..280396fe59 100644
--- a/arch/arm/src/lc823450/lc823450_i2c.c
+++ b/arch/arm/src/lc823450/lc823450_i2c.c
@@ -290,37 +290,20 @@ static inline void
 static inline int
   lc823450_i2c_sem_waitdone(struct lc823450_i2c_priv_s *priv)
 {
-  struct timespec abstime;
   int ret;
 
   do
     {
-      /* Get the current time */
-
-      clock_gettime(CLOCK_REALTIME, &abstime);
-
-      /* Calculate a time in the future */
-
-#if CONFIG_LC823450_I2C_TIMEOSEC > 0
-      abstime.tv_sec += CONFIG_LC823450_I2C_TIMEOSEC;
-#endif
-
-      /* Add a value proportional to the number of bytes in the transfer */
-
-      abstime.tv_nsec += priv->timeoms * 1000 * 1000;
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
-
       /* Wait until either the transfer is complete or the timeout expires */
 
-      ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                                     SEC2TICK(CONFIG_LC823450_I2C_TIMEOSEC) +
+                                     MSEC2TICK(priv->timeoms));
       if (ret < 0)
         {
           /* Break out of the loop on irrecoverable errors.  This would
-           * include timeouts and mystery errors reported by nxsem_timedwait.
+           * include timeouts and mystery errors reported by
+           * nxsem_tickwait_uninterruptible.
            */
 
           break;
diff --git a/arch/arm/src/s32k1xx/s32k1xx_lpi2c.c b/arch/arm/src/s32k1xx/s32k1xx_lpi2c.c
index 5bd7eb0665..daadde4928 100644
--- a/arch/arm/src/s32k1xx/s32k1xx_lpi2c.c
+++ b/arch/arm/src/s32k1xx/s32k1xx_lpi2c.c
@@ -471,7 +471,6 @@ static useconds_t s32k1xx_lpi2c_tousecs(int msgc, struct i2c_msg_s *msgs)
 static inline int
   s32k1xx_lpi2c_sem_waitdone(struct s32k1xx_lpi2c_priv_s *priv)
 {
-  struct timespec abstime;
   irqstate_t flags;
   uint32_t regval;
   int ret;
@@ -505,50 +504,26 @@ static inline int
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait_uninterruptible() sleeps.
    */
 
   priv->intstate = INTSTATE_WAITING;
   do
     {
-      /* Get the current time */
-
-      clock_gettime(CLOCK_REALTIME, &abstime);
-
-      /* Calculate a time in the future */
-
-#if CONFIG_S32K1XX_I2CTIMEOSEC > 0
-      abstime.tv_sec += CONFIG_S32K1XX_I2CTIMEOSEC;
-#endif
-
-      /* Add a value proportional to the number of bytes in the transfer */
+      /* Wait until either the transfer is complete or the timeout expires */
 
 #ifdef CONFIG_S32K1XX_I2C_DYNTIMEO
-      abstime.tv_nsec +=
-        1000 * s32k1xx_lpi2c_tousecs(priv->msgc, priv->msgv);
-
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
-
-#elif CONFIG_S32K1XX_I2CTIMEOMS > 0
-      abstime.tv_nsec += CONFIG_S32K1XX_I2CTIMEOMS * 1000 * 1000;
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                   USEC2TICK(s32k1xx_lpi2c_tousecs(priv->msgc, priv->msgv)));
+#else
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                                           CONFIG_S32K1XX_I2CTIMEOTICKS);
 #endif
-
-      /* Wait until either the transfer is complete or the timeout expires */
-
-      ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
       if (ret < 0)
         {
           /* Break out of the loop on irrecoverable errors.  This would
-           * include timeouts and mystery errors reported by nxsem_timedwait.
+           * include timeouts and mystery errors reported by
+           * nxsem_tickwait_uninterruptible.
            */
 
           break;
@@ -603,7 +578,7 @@ static inline int
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait_uninterruptible() sleeps.
    */
 
   priv->intstate = INTSTATE_WAITING;
diff --git a/arch/arm/src/stm32/stm32_i2c.c b/arch/arm/src/stm32/stm32_i2c.c
index 3b13cbe61e..877b6a91c3 100644
--- a/arch/arm/src/stm32/stm32_i2c.c
+++ b/arch/arm/src/stm32/stm32_i2c.c
@@ -528,7 +528,6 @@ static useconds_t stm32_i2c_tousecs(int msgc, struct i2c_msg_s *msgs)
 #ifndef CONFIG_I2C_POLLED
 static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
 {
-  struct timespec abstime;
   irqstate_t flags;
   uint32_t regval;
   int ret;
@@ -543,48 +542,26 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait_uninterruptible() sleeps.
    */
 
   priv->intstate = INTSTATE_WAITING;
   do
     {
-      /* Get the current time */
-
-      clock_gettime(CLOCK_REALTIME, &abstime);
-
-      /* Calculate a time in the future */
-
-#if CONFIG_STM32_I2CTIMEOSEC > 0
-      abstime.tv_sec += CONFIG_STM32_I2CTIMEOSEC;
-#endif
-
-      /* Add a value proportional to the number of bytes in the transfer */
+      /* Wait until either the transfer is complete or the timeout expires */
 
 #ifdef CONFIG_STM32_I2C_DYNTIMEO
-      abstime.tv_nsec += 1000 * stm32_i2c_tousecs(priv->msgc, priv->msgv);
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
-
-#elif CONFIG_STM32_I2CTIMEOMS > 0
-      abstime.tv_nsec += CONFIG_STM32_I2CTIMEOMS * 1000 * 1000;
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                       USEC2TICK(stm32_i2c_tousecs(priv->msgc, priv->msgv)));
+#else
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                                           CONFIG_STM32_I2CTIMEOTICKS);
 #endif
-
-      /* Wait until either the transfer is complete or the timeout expires */
-
-      ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
       if (ret < 0)
         {
           /* Break out of the loop on irrecoverable errors.  This would
-           * include timeouts and mystery errors reported by nxsem_timedwait.
+           * include timeouts and mystery errors reported by
+           * nxsem_tickwait_uninterruptible.
            */
 
           break;
@@ -626,7 +603,7 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait_uninterruptible() sleeps.
    */
 
   priv->intstate = INTSTATE_WAITING;
diff --git a/arch/arm/src/stm32/stm32_i2c_alt.c b/arch/arm/src/stm32/stm32_i2c_alt.c
index 7c4f8e8e34..4f1ac39161 100644
--- a/arch/arm/src/stm32/stm32_i2c_alt.c
+++ b/arch/arm/src/stm32/stm32_i2c_alt.c
@@ -558,7 +558,6 @@ static useconds_t stm32_i2c_tousecs(int msgc, struct i2c_msg_s *msgs)
 #ifndef CONFIG_I2C_POLLED
 static int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
 {
-  struct timespec abstime;
   irqstate_t flags;
   uint32_t regval;
   int ret;
@@ -573,48 +572,26 @@ static int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait_uninterruptible() sleeps.
    */
 
   priv->intstate = INTSTATE_WAITING;
   do
     {
-      /* Get the current time */
-
-      clock_gettime(CLOCK_REALTIME, &abstime);
-
-      /* Calculate a time in the future */
-
-#if CONFIG_STM32_I2CTIMEOSEC > 0
-      abstime.tv_sec += CONFIG_STM32_I2CTIMEOSEC;
-#endif
-
-      /* Add a value proportional to the number of bytes in the transfer */
+      /* Wait until either the transfer is complete or the timeout expires */
 
 #ifdef CONFIG_STM32_I2C_DYNTIMEO
-      abstime.tv_nsec += 1000 * stm32_i2c_tousecs(priv->msgc, priv->msgv);
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
-
-#elif CONFIG_STM32_I2CTIMEOMS > 0
-      abstime.tv_nsec += CONFIG_STM32_I2CTIMEOMS * 1000 * 1000;
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                       USEC2TICK(stm32_i2c_tousecs(priv->msgc, priv->msgv)));
+#else
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                                           CONFIG_STM32_I2CTIMEOTICKS);
 #endif
-
-      /* Wait until either the transfer is complete or the timeout expires */
-
-      ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
       if (ret < 0)
         {
           /* Break out of the loop on irrecoverable errors.  This would
-           * include timeouts and mystery errors reported by nxsem_timedwait.
+           * include timeouts and mystery errors reported by
+           * nxsem_tickwait_uninterruptible.
            */
 
           break;
@@ -656,7 +633,7 @@ static int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait_uninterruptible() sleeps.
    */
 
   priv->intstate = INTSTATE_WAITING;
diff --git a/arch/arm/src/stm32/stm32_i2c_v2.c b/arch/arm/src/stm32/stm32_i2c_v2.c
index 737a6bf07c..2714cd16c5 100644
--- a/arch/arm/src/stm32/stm32_i2c_v2.c
+++ b/arch/arm/src/stm32/stm32_i2c_v2.c
@@ -771,7 +771,6 @@ static inline void stm32_i2c_enableinterrupts(struct stm32_i2c_priv_s *priv)
 #ifndef CONFIG_I2C_POLLED
 static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
 {
-  struct timespec abstime;
   irqstate_t flags;
   int ret;
 
@@ -792,42 +791,20 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
   priv->intstate = INTSTATE_WAITING;
   do
     {
-      /* Get the current time */
-
-      clock_gettime(CLOCK_REALTIME, &abstime);
-
-      /* Calculate a time in the future */
-
-#if CONFIG_STM32_I2CTIMEOSEC > 0
-      abstime.tv_sec += CONFIG_STM32_I2CTIMEOSEC;
-#endif
-
-      /* Add a value proportional to the number of bytes in the transfer */
+      /* Wait until either the transfer is complete or the timeout expires */
 
 #ifdef CONFIG_STM32_I2C_DYNTIMEO
-      abstime.tv_nsec += 1000 * stm32_i2c_tousecs(priv->msgc, priv->msgv);
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
-
-#elif CONFIG_STM32_I2CTIMEOMS > 0
-      abstime.tv_nsec += CONFIG_STM32_I2CTIMEOMS * 1000 * 1000;
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                       USEC2TICK(stm32_i2c_tousecs(priv->msgc, priv->msgv)));
+#else
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                                           CONFIG_STM32_I2CTIMEOTICKS);
 #endif
-
-      /* Wait until either the transfer is complete or the timeout expires */
-
-      ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
       if (ret < 0)
         {
           /* Break out of the loop on irrecoverable errors.  This would
-           * include timeouts and mystery errors reported by nxsem_timedwait.
+           * include timeouts and mystery errors reported by
+           * nxsem_tickwait_uninterruptible.
            */
 
           break;
@@ -867,7 +844,7 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait_uninterruptible() sleeps.
    */
 
   priv->intstate = INTSTATE_WAITING;
diff --git a/arch/arm/src/stm32/stm32f40xxx_i2c.c b/arch/arm/src/stm32/stm32f40xxx_i2c.c
index 422697a6a9..bd367ce3c6 100644
--- a/arch/arm/src/stm32/stm32f40xxx_i2c.c
+++ b/arch/arm/src/stm32/stm32f40xxx_i2c.c
@@ -581,7 +581,6 @@ static useconds_t stm32_i2c_tousecs(int msgc, struct i2c_msg_s *msgs)
 #ifndef CONFIG_I2C_POLLED
 static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
 {
-  struct timespec abstime;
   irqstate_t flags;
   uint32_t regval;
   int ret;
@@ -596,48 +595,26 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait_uninterruptible() sleeps.
    */
 
   priv->intstate = INTSTATE_WAITING;
   do
     {
-      /* Get the current time */
-
-      clock_gettime(CLOCK_REALTIME, &abstime);
-
-      /* Calculate a time in the future */
-
-#if CONFIG_STM32_I2CTIMEOSEC > 0
-      abstime.tv_sec += CONFIG_STM32_I2CTIMEOSEC;
-#endif
-
-      /* Add a value proportional to the number of bytes in the transfer */
+      /* Wait until either the transfer is complete or the timeout expires */
 
 #ifdef CONFIG_STM32_I2C_DYNTIMEO
-      abstime.tv_nsec += 1000 * stm32_i2c_tousecs(priv->msgc, priv->msgv);
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
-
-#elif CONFIG_STM32_I2CTIMEOMS > 0
-      abstime.tv_nsec += CONFIG_STM32_I2CTIMEOMS * 1000 * 1000;
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                       USEC2TICK(stm32_i2c_tousecs(priv->msgc, priv->msgv)));
+#else
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                                           CONFIG_STM32_I2CTIMEOTICKS);
 #endif
-
-      /* Wait until either the transfer is complete or the timeout expires */
-
-      ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
       if (ret < 0)
         {
           /* Break out of the loop on irrecoverable errors.  This would
-           * include timeouts and mystery errors reported by nxsem_timedwait.
+           * include timeouts and mystery errors reported by
+           * nxsem_tickwait_uninterruptible.
            */
 
           break;
@@ -679,7 +656,7 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait_uninterruptible() sleeps.
    */
 
   priv->intstate = INTSTATE_WAITING;
diff --git a/arch/arm/src/stm32f0l0g0/stm32_i2c.c b/arch/arm/src/stm32f0l0g0/stm32_i2c.c
index 58d61bc44d..550dd10f07 100644
--- a/arch/arm/src/stm32f0l0g0/stm32_i2c.c
+++ b/arch/arm/src/stm32f0l0g0/stm32_i2c.c
@@ -785,7 +785,6 @@ static inline void stm32_i2c_enableinterrupts(struct stm32_i2c_priv_s *priv)
 #ifndef CONFIG_I2C_POLLED
 static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
 {
-  struct timespec abstime;
   irqstate_t flags;
   int ret;
 
@@ -806,42 +805,20 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
   priv->intstate = INTSTATE_WAITING;
   do
     {
-      /* Get the current time */
-
-      clock_gettime(CLOCK_REALTIME, &abstime);
-
-      /* Calculate a time in the future */
-
-#if CONFIG_STM32F0L0G0_I2CTIMEOSEC > 0
-      abstime.tv_sec += CONFIG_STM32F0L0G0_I2CTIMEOSEC;
-#endif
-
-      /* Add a value proportional to the number of bytes in the transfer */
+      /* Wait until either the transfer is complete or the timeout expires */
 
 #ifdef CONFIG_STM32F0L0G0_I2C_DYNTIMEO
-      abstime.tv_nsec += 1000 * stm32_i2c_tousecs(priv->msgc, priv->msgv);
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
-
-#elif CONFIG_STM32F0L0G0_I2CTIMEOMS > 0
-      abstime.tv_nsec += CONFIG_STM32F0L0G0_I2CTIMEOMS * 1000 * 1000;
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                       USEC2TICK(stm32_i2c_tousecs(priv->msgc, priv->msgv)));
+#else
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                                           CONFIG_STM32F0L0G0_I2CTIMEOTICKS);
 #endif
-
-      /* Wait until either the transfer is complete or the timeout expires */
-
-      ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
       if (ret < 0)
         {
           /* Break out of the loop on irrecoverable errors.  This would
-           * include timeouts and mystery errors reported by nxsem_timedwait.
+           * include timeouts and mystery errors reported by
+           * nxsem_tickwait_uninterruptible.
            */
 
           break;
@@ -881,7 +858,7 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait_uninterruptible() sleeps.
    */
 
   priv->intstate = INTSTATE_WAITING;
diff --git a/arch/arm/src/stm32f7/stm32_i2c.c b/arch/arm/src/stm32f7/stm32_i2c.c
index 402c2d0b1e..35f7ecafcb 100644
--- a/arch/arm/src/stm32f7/stm32_i2c.c
+++ b/arch/arm/src/stm32f7/stm32_i2c.c
@@ -808,7 +808,6 @@ static inline void stm32_i2c_enableinterrupts(struct stm32_i2c_priv_s *priv)
 #ifndef CONFIG_I2C_POLLED
 static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
 {
-  struct timespec abstime;
   irqstate_t flags;
   int ret;
 
@@ -829,42 +828,20 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
   priv->intstate = INTSTATE_WAITING;
   do
     {
-      /* Get the current time */
-
-      clock_gettime(CLOCK_REALTIME, &abstime);
-
-      /* Calculate a time in the future */
-
-#if CONFIG_STM32F7_I2CTIMEOSEC > 0
-      abstime.tv_sec += CONFIG_STM32F7_I2CTIMEOSEC;
-#endif
-
-      /* Add a value proportional to the number of bytes in the transfer */
+      /* Wait until either the transfer is complete or the timeout expires */
 
 #ifdef CONFIG_STM32F7_I2C_DYNTIMEO
-      abstime.tv_nsec += 1000 * stm32_i2c_tousecs(priv->msgc, priv->msgv);
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
-
-#elif CONFIG_STM32F7_I2CTIMEOMS > 0
-      abstime.tv_nsec += CONFIG_STM32F7_I2CTIMEOMS * 1000 * 1000;
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                       USEC2TICK(stm32_i2c_tousecs(priv->msgc, priv->msgv)));
+#else
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                                           CONFIG_STM32F7_I2CTIMEOTICKS);
 #endif
-
-      /* Wait until either the transfer is complete or the timeout expires */
-
-      ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
       if (ret < 0)
         {
           /* Break out of the loop on irrecoverable errors.  This would
-           * include timeouts and mystery errors reported by nxsem_timedwait.
+           * include timeouts and mystery errors reported by
+           * nxsem_tickwait_uninterruptible.
            */
 
           break;
@@ -904,7 +881,7 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait_uninterruptible() sleeps.
    */
 
   priv->intstate = INTSTATE_WAITING;
diff --git a/arch/arm/src/stm32h7/stm32_i2c.c b/arch/arm/src/stm32h7/stm32_i2c.c
index 469b89a9bb..b19d722aee 100644
--- a/arch/arm/src/stm32h7/stm32_i2c.c
+++ b/arch/arm/src/stm32h7/stm32_i2c.c
@@ -767,7 +767,6 @@ static inline void stm32_i2c_enableinterrupts(struct stm32_i2c_priv_s *priv)
 #ifndef CONFIG_I2C_POLLED
 static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
 {
-  struct timespec abstime;
   irqstate_t flags;
   int ret;
 
@@ -788,42 +787,20 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
   priv->intstate = INTSTATE_WAITING;
   do
     {
-      /* Get the current time */
-
-      clock_gettime(CLOCK_REALTIME, &abstime);
-
-      /* Calculate a time in the future */
-
-#if CONFIG_STM32H7_I2CTIMEOSEC > 0
-      abstime.tv_sec += CONFIG_STM32H7_I2CTIMEOSEC;
-#endif
-
-      /* Add a value proportional to the number of bytes in the transfer */
+      /* Wait until either the transfer is complete or the timeout expires */
 
 #ifdef CONFIG_STM32H7_I2C_DYNTIMEO
-      abstime.tv_nsec += 1000 * stm32_i2c_tousecs(priv->msgc, priv->msgv);
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
-
-#elif CONFIG_STM32H7_I2CTIMEOMS > 0
-      abstime.tv_nsec += CONFIG_STM32H7_I2CTIMEOMS * 1000 * 1000;
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                       USEC2TICK(stm32_i2c_tousecs(priv->msgc, priv->msgv)));
+#else
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                                           CONFIG_STM32H7_I2CTIMEOTICKS);
 #endif
-
-      /* Wait until either the transfer is complete or the timeout expires */
-
-      ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
       if (ret < 0)
         {
           /* Break out of the loop on irrecoverable errors.  This would
-           * include timeouts and mystery errors reported by nxsem_timedwait.
+           * include timeouts and mystery errors reported by
+           * nxsem_tickwait_uninterruptible.
            */
 
           break;
@@ -863,7 +840,7 @@ static inline int stm32_i2c_sem_waitdone(struct stm32_i2c_priv_s *priv)
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait_uninterruptible() sleeps.
    */
 
   priv->intstate = INTSTATE_WAITING;
diff --git a/arch/arm/src/stm32l4/stm32l4_i2c.c b/arch/arm/src/stm32l4/stm32l4_i2c.c
index 11113f0d98..ecf1703a9f 100644
--- a/arch/arm/src/stm32l4/stm32l4_i2c.c
+++ b/arch/arm/src/stm32l4/stm32l4_i2c.c
@@ -815,7 +815,6 @@ void stm32l4_i2c_enableinterrupts(struct stm32l4_i2c_priv_s *priv)
 static inline
 int stm32l4_i2c_sem_waitdone(struct stm32l4_i2c_priv_s *priv)
 {
-  struct timespec abstime;
   irqstate_t flags;
   int ret;
 
@@ -836,42 +835,20 @@ int stm32l4_i2c_sem_waitdone(struct stm32l4_i2c_priv_s *priv)
   priv->intstate = INTSTATE_WAITING;
   do
     {
-      /* Get the current time */
-
-      clock_gettime(CLOCK_REALTIME, &abstime);
-
-      /* Calculate a time in the future */
-
-#if CONFIG_STM32L4_I2CTIMEOSEC > 0
-      abstime.tv_sec += CONFIG_STM32L4_I2CTIMEOSEC;
-#endif
-
-      /* Add a value proportional to the number of bytes in the transfer */
+      /* Wait until either the transfer is complete or the timeout expires */
 
 #ifdef CONFIG_STM32L4_I2C_DYNTIMEO
-      abstime.tv_nsec += 1000 * stm32l4_i2c_tousecs(priv->msgc, priv->msgv);
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
-
-#elif CONFIG_STM32L4_I2CTIMEOMS > 0
-      abstime.tv_nsec += CONFIG_STM32L4_I2CTIMEOMS * 1000 * 1000;
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                     USEC2TICK(stm32l4_i2c_tousecs(priv->msgc, priv->msgv)));
+#else
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                                           CONFIG_STM32L4_I2CTIMEOTICKS);
 #endif
-
-      /* Wait until either the transfer is complete or the timeout expires */
-
-      ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
       if (ret < 0)
         {
           /* Break out of the loop on irrecoverable errors.  This would
-           * include timeouts and mystery errors reported by nxsem_timedwait.
+           * include timeouts and mystery errors reported by
+           * nxsem_tickwait_uninterruptible.
            */
 
           break;
@@ -912,7 +889,7 @@ int stm32l4_i2c_sem_waitdone(struct stm32l4_i2c_priv_s *priv)
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait_uninterruptible() sleeps.
    */
 
   priv->intstate = INTSTATE_WAITING;
diff --git a/arch/arm/src/tiva/common/tiva_i2c.c b/arch/arm/src/tiva/common/tiva_i2c.c
index 5f47633ef0..95fceb1390 100644
--- a/arch/arm/src/tiva/common/tiva_i2c.c
+++ b/arch/arm/src/tiva/common/tiva_i2c.c
@@ -671,7 +671,6 @@ static useconds_t tiva_i2c_tousecs(int msgc, struct i2c_msg_s *msgv)
 #ifndef CONFIG_I2C_POLLED
 static inline int tiva_i2c_sem_waitdone(struct tiva_i2c_priv_s *priv)
 {
-  struct timespec abstime;
   irqstate_t flags;
   int ret;
 
@@ -686,47 +685,25 @@ static inline int tiva_i2c_sem_waitdone(struct tiva_i2c_priv_s *priv)
 
   /* Signal the interrupt handler that we are waiting.
    * NOTE:  Interrupts  are currently disabled but will be temporarily
-   * re-enabled below when nxsem_timedwait() sleeps.
+   * re-enabled below when nxsem_tickwait_uninterruptible() sleeps.
    */
 
   do
     {
-      /* Get the current time */
-
-      clock_gettime(CLOCK_REALTIME, &abstime);
-
-      /* Calculate a time in the future */
-
-#if CONFIG_TIVA_I2C_TIMEOSEC > 0
-      abstime.tv_sec += CONFIG_TIVA_I2C_TIMEOSEC;
-#endif
-
-      /* Add a value proportional to the number of bytes in the transfer */
+      /* Wait until either the transfer is complete or the timeout expires */
 
 #ifdef CONFIG_TIVA_I2C_DYNTIMEO
-      abstime.tv_nsec += 1000 * tiva_i2c_tousecs(priv->msgc, priv->msgv);
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
-
-#elif CONFIG_TIVA_I2C_TIMEOMS > 0
-      abstime.tv_nsec += CONFIG_TIVA_I2C_TIMEOMS * 1000 * 1000;
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
+      ret = nxsem_tickwait_uninterruptible(&priv->waitsem,
+                        USEC2TICK(tiva_i2c_tousecs(priv->msgc, priv->msgv)));
+#else
+      ret = nxsem_tickwait_uninterruptible(&priv->waitsem,
+                                           CONFIG_TIVA_I2C_TIMEOTICKS);
 #endif
-
-      /* Wait until either the transfer is complete or the timeout expires */
-
-      ret = nxsem_timedwait_uninterruptible(&priv->waitsem, &abstime);
       if (ret < 0)
         {
           /* Break out of the loop on irrecoverable errors.  This would
-           * include timeouts and mystery errors reported by nxsem_timedwait.
+           * include timeouts and mystery errors reported by
+           * nxsem_tickwait_uninterruptible.
            */
 
           tiva_i2c_traceevent(priv, I2CEVENT_TIMEOUT,
@@ -769,7 +746,7 @@ static inline int tiva_i2c_sem_waitdone(struct tiva_i2c_priv_s *priv)
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait_uninterruptible() sleeps.
    */
 
   start = clock_systime_ticks();
diff --git a/arch/mips/src/pic32mz/pic32mz_i2c.c b/arch/mips/src/pic32mz/pic32mz_i2c.c
index 01530ed9a4..4020004d10 100644
--- a/arch/mips/src/pic32mz/pic32mz_i2c.c
+++ b/arch/mips/src/pic32mz/pic32mz_i2c.c
@@ -660,7 +660,6 @@ static useconds_t pic32mz_i2c_tousecs(int msgc, struct i2c_msg_s *msgs)
 static inline int
   pic32mz_i2c_sem_waitdone(struct pic32mz_i2c_priv_s *priv)
 {
-  struct timespec abstime;
   irqstate_t flags;
   int ret;
 
@@ -672,40 +671,20 @@ static inline int
 
   do
     {
-      clock_gettime(CLOCK_REALTIME, &abstime);
-
-      /* Calculate a time in the future */
-
-#if CONFIG_PIC32MZ_I2CTIMEOSEC > 0
-      abstime.tv_sec += CONFIG_PIC32MZ_I2CTIMEOSEC;
-#endif
-
-      /* Add a value proportional to the number of bytes in the transfer */
+      /* Wait until either the transfer is complete or the timeout expires */
 
 #ifdef CONFIG_PIC32MZ_I2C_DYNTIMEO
-      abstime.tv_nsec += 1000 * pic32mz_i2c_tousecs(priv->msgc, priv->msgv);
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
-
-#elif CONFIG_PIC32MZ_I2CTIMEOMS > 0
-      abstime.tv_nsec += CONFIG_PIC32MZ_I2CTIMEOMS * 1000 * 1000;
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                     USEC2TICK(pic32mz_i2c_tousecs(priv->msgc, priv->msgv)));
+#else
+      ret = nxsem_tickwait_uninterruptible(&priv->sem_isr,
+                                           CONFIG_PIC32MZ_I2CTIMEOTICKS);
 #endif
-
-      /* Wait until either the transfer is complete or the timeout expires */
-
-      ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
       if (ret < 0)
         {
           /* Break out of the loop on irrecoverable errors.  This would
-           * include timeouts and mystery errors reported by nxsem_timedwait.
+           * include timeouts and mystery errors reported by
+           * nxsem_tickwait_uninterruptible.
            */
 
           break;
@@ -748,7 +727,7 @@ static inline int
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait_uninterruptible() sleeps.
    */
 
   priv->intstate = INTSTATE_WAITING;
diff --git a/arch/risc-v/src/esp32c3/esp32c3_i2c.c b/arch/risc-v/src/esp32c3/esp32c3_i2c.c
index 8b7865dc3b..e762567f34 100644
--- a/arch/risc-v/src/esp32c3/esp32c3_i2c.c
+++ b/arch/risc-v/src/esp32c3/esp32c3_i2c.c
@@ -84,6 +84,9 @@
 #define TIMESPEC_TO_US(sec, nano)  ((sec * USEC_PER_SEC) + (nano / NSEC_PER_USEC))
 #endif
 
+#define ESP32C3_I2CTIMEOTICKS \
+    (SEC2TICK(CONFIG_ESP32C3_I2CTIMEOSEC) + MSEC2TICK(CONFIG_ESP32C3_I2CTIMEOMS))
+
 /* I2C hardware FIFO depth */
 
 #define I2C_FIFO_SIZE (32)
@@ -793,27 +796,8 @@ 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,
+                                        ESP32C3_I2CTIMEOTICKS);
 }
 #endif
 
diff --git a/arch/risc-v/src/esp32c3/esp32c3_spi.c b/arch/risc-v/src/esp32c3/esp32c3_spi.c
index 209589db70..3b78b8cfd9 100644
--- a/arch/risc-v/src/esp32c3/esp32c3_spi.c
+++ b/arch/risc-v/src/esp32c3/esp32c3_spi.c
@@ -425,17 +425,7 @@ static int esp32c3_spi_lock(struct spi_dev_s *dev, bool lock)
 #ifdef CONFIG_ESP32C3_SPI2_DMA
 static int esp32c3_spi_sem_waitdone(struct esp32c3_spi_priv_s *priv)
 {
-  int ret;
-  struct timespec abstime;
-
-  clock_gettime(CLOCK_REALTIME, &abstime);
-
-  abstime.tv_sec += 10;
-  abstime.tv_nsec += 0;
-
-  ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
-
-  return ret;
+  return nxsem_tickwait_uninterruptible(&priv->sem_isr, SEC2TICK(10));
 }
 #endif
 
diff --git a/arch/risc-v/src/mpfs/mpfs_i2c.c b/arch/risc-v/src/mpfs/mpfs_i2c.c
index e9a7f2ce64..8f04a33dee 100755
--- a/arch/risc-v/src/mpfs/mpfs_i2c.c
+++ b/arch/risc-v/src/mpfs/mpfs_i2c.c
@@ -340,17 +340,7 @@ static void mpfs_i2c_deinit(struct mpfs_i2c_priv_s *priv)
 
 static int mpfs_i2c_sem_waitdone(struct mpfs_i2c_priv_s *priv)
 {
-  struct timespec abstime;
-  int ret;
-
-  clock_gettime(CLOCK_REALTIME, &abstime);
-
-  abstime.tv_sec += 10;
-  abstime.tv_nsec += 0;
-
-  ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
-
-  return ret;
+  return nxsem_tickwait_uninterruptible(&priv->sem_isr, SEC2TICK(10));
 }
 
 /****************************************************************************
diff --git a/arch/risc-v/src/mpfs/mpfs_spi.c b/arch/risc-v/src/mpfs/mpfs_spi.c
index 66ba550d82..4c3fa75fc0 100644
--- a/arch/risc-v/src/mpfs/mpfs_spi.c
+++ b/arch/risc-v/src/mpfs/mpfs_spi.c
@@ -681,17 +681,7 @@ static int mpfs_spi_hwfeatures(struct spi_dev_s *dev,
 
 static int mpfs_spi_sem_waitdone(struct mpfs_spi_priv_s *priv)
 {
-  struct timespec abstime;
-  int ret;
-
-  clock_gettime(CLOCK_REALTIME, &abstime);
-
-  abstime.tv_sec += 10;
-  abstime.tv_nsec += 0;
-
-  ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
-
-  return ret;
+  return nxsem_tickwait_uninterruptible(&priv->sem_isr, SEC2TICK(10));
 }
 
 /****************************************************************************
diff --git a/arch/xtensa/src/esp32/esp32_i2c.c b/arch/xtensa/src/esp32/esp32_i2c.c
index c665c8d3de..6dea1b053c 100644
--- a/arch/xtensa/src/esp32/esp32_i2c.c
+++ b/arch/xtensa/src/esp32/esp32_i2c.c
@@ -79,6 +79,9 @@
 #define TIMESPEC_TO_US(sec, nano)  ((sec * USEC_PER_SEC) + (nano / NSEC_PER_USEC))
 #endif
 
+#define ESP32_I2CTIMEOTICKS \
+    (SEC2TICK(CONFIG_ESP32_I2CTIMEOSEC) + MSEC2TICK(CONFIG_ESP32_I2CTIMEOMS))
+
 /* Default option */
 
 #define I2C_FIFO_SIZE (255)
@@ -723,31 +726,9 @@ 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, ESP32_I2CTIMEOTICKS);
 }
 #endif
 
diff --git a/arch/xtensa/src/esp32/esp32_spi.c b/arch/xtensa/src/esp32/esp32_spi.c
index 593c996670..d5518b9913 100644
--- a/arch/xtensa/src/esp32/esp32_spi.c
+++ b/arch/xtensa/src/esp32/esp32_spi.c
@@ -497,17 +497,7 @@ static int esp32_spi_lock(struct spi_dev_s *dev, bool lock)
 
 static int esp32_spi_sem_waitdone(struct esp32_spi_priv_s *priv)
 {
-  int ret;
-  struct timespec abstime;
-
-  clock_gettime(CLOCK_REALTIME, &abstime);
-
-  abstime.tv_sec += 10;
-  abstime.tv_nsec += 0;
-
-  ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
-
-  return ret;
+  return nxsem_tickwait_uninterruptible(&priv->sem_isr, SEC2TICK(10));
 }
 
 /****************************************************************************
diff --git a/drivers/modem/altair/altmdm_sys.c b/drivers/modem/altair/altmdm_sys.c
index 33cb2b3630..47c0eb73a6 100644
--- a/drivers/modem/altair/altmdm_sys.c
+++ b/drivers/modem/altair/altmdm_sys.c
@@ -394,8 +394,6 @@ int altmdm_sys_waitflag(FAR struct altmdm_sys_flag_s *handle,
                         FAR uint32_t * pattern, uint32_t timeout_ms)
 {
   int ret = OK;
-  struct timespec abs_time;
-  struct timespec curr_time;
   irqstate_t flags;
   uint32_t ptn;
 
@@ -419,32 +417,6 @@ int altmdm_sys_waitflag(FAR struct altmdm_sys_flag_s *handle,
       return ERROR;
     }
 
-  if (timeout_ms != ALTMDM_SYS_FLAG_TMOFEVR)
-    {
-      /* Get current time. */
-
-      ret = clock_gettime(CLOCK_REALTIME, &curr_time);
-      if (ret != OK)
-        {
-          return ret;
-        }
-
-      abs_time.tv_sec = timeout_ms / 1000;
-      abs_time.tv_nsec = (timeout_ms - (abs_time.tv_sec * 1000)) *
-                          1000 * 1000;
-
-      abs_time.tv_sec += curr_time.tv_sec;
-      abs_time.tv_nsec += curr_time.tv_nsec;
-
-      /* Check more than 1 sec. */
-
-      if (abs_time.tv_nsec >= (1000 * 1000 * 1000))
-        {
-          abs_time.tv_sec += 1;
-          abs_time.tv_nsec -= (1000 * 1000 * 1000);
-        }
-    }
-
   *pattern = 0;
 
   while (1)
@@ -514,10 +486,11 @@ int altmdm_sys_waitflag(FAR struct altmdm_sys_flag_s *handle,
         {
           /* Wait for the semaphore to be posted until timeout occurs. */
 
-          ret = nxsem_timedwait_uninterruptible(&handle->sem, &abs_time);
+          ret = nxsem_tickwait_uninterruptible(&handle->sem,
+                                               MSEC2TICK(timeout_ms));
           if (ret < 0)
             {
-              m_err("nxsem_timedwait_uninterruptible() failed:%d\n", ret);
+              m_err("nxsem_tickwait_uninterruptible() failed:%d\n", ret);
               break;
             }
         }
diff --git a/drivers/sensors/lps25h.c b/drivers/sensors/lps25h.c
index 4f9d9f6a83..15919ee1a4 100644
--- a/drivers/sensors/lps25h.c
+++ b/drivers/sensors/lps25h.c
@@ -494,7 +494,6 @@ static int lps25h_one_shot(FAR struct lps25h_dev_s *dev)
 {
   int ret = ERROR;
   int retries;
-  struct timespec abstime;
   irqstate_t flags;
 
   if (!dev->irqenabled)
@@ -530,16 +529,8 @@ static int lps25h_one_shot(FAR struct lps25h_dev_s *dev)
           return ret;
         }
 
-      clock_gettime(CLOCK_REALTIME, &abstime);
-      abstime.tv_sec += (LPS25H_RETRY_TIMEOUT_MSECS / 1000);
-      abstime.tv_nsec += (LPS25H_RETRY_TIMEOUT_MSECS % 1000) * 1000 * 1000;
-      while (abstime.tv_nsec >= (1000 * 1000 * 1000))
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
-
-      ret = nxsem_timedwait_uninterruptible(&dev->waitsem, &abstime);
+      ret = nxsem_tickwait_uninterruptible(&dev->waitsem,
+                                      MSEC2TICK(LPS25H_RETRY_TIMEOUT_MSECS));
       if (ret == OK)
         {
           break;
diff --git a/drivers/wireless/bluetooth/bt_uart_bcm4343x.c b/drivers/wireless/bluetooth/bt_uart_bcm4343x.c
index facd7ed1b9..70eae69a18 100644
--- a/drivers/wireless/bluetooth/bt_uart_bcm4343x.c
+++ b/drivers/wireless/bluetooth/bt_uart_bcm4343x.c
@@ -125,7 +125,6 @@ static int uartwriteconf(FAR const struct btuart_lowerhalf_s *lower,
   int ret;
   int gotlen = 0;
   FAR uint8_t *din;
-  struct timespec abstime;
 
   DEBUGASSERT(lower != NULL);
 
@@ -149,22 +148,7 @@ static int uartwriteconf(FAR const struct btuart_lowerhalf_s *lower,
   din = kmm_malloc(maxl);
   while (gotlen < maxl)
     {
-      ret = clock_gettime(CLOCK_REALTIME, &abstime);
-      if (ret < 0)
-        {
-          goto exit_uartwriteconf;
-        }
-
-      /* Add the offset to the time in the future */
-
-      abstime.tv_nsec += NSEC_PER_SEC / 10;
-      if (abstime.tv_nsec >= NSEC_PER_SEC)
-        {
-          abstime.tv_nsec -= NSEC_PER_SEC;
-          abstime.tv_sec++;
-        }
-
-      ret = nxsem_timedwait_uninterruptible(rxsem, &abstime);
+      ret = nxsem_tickwait_uninterruptible(rxsem, MSEC2TICK(100));
       if (ret < 0)
         {
           /* We didn't receive enough message, so fall out */
diff --git a/include/nuttx/semaphore.h b/include/nuttx/semaphore.h
index dcea5ee863..736113c96e 100644
--- a/include/nuttx/semaphore.h
+++ b/include/nuttx/semaphore.h
@@ -566,7 +566,7 @@ int nxsem_timedwait_uninterruptible(FAR sem_t *sem,
  * Name: nxsem_clockwait_uninterruptible
  *
  * Description:
- *   This function is wrapped version of nxsem_timedwait(), which is
+ *   This function is wrapped version of nxsem_clockwait(), which is
  *   uninterruptible and convenient for use.
  *
  * Input Parameters:
diff --git a/mm/iob/iob_alloc.c b/mm/iob/iob_alloc.c
index 7df00e8227..0f5d24567b 100644
--- a/mm/iob/iob_alloc.c
+++ b/mm/iob/iob_alloc.c
@@ -136,19 +136,7 @@ static FAR struct iob_s *iob_allocwait(bool throttled, unsigned int timeout,
         }
       else
         {
-          struct timespec abstime;
-
-          DEBUGVERIFY(clock_gettime(CLOCK_REALTIME, &abstime));
-
-          abstime.tv_sec  += timeout / MSEC_PER_SEC;
-          abstime.tv_nsec += timeout % MSEC_PER_SEC * NSEC_PER_MSEC;
-          if (abstime.tv_nsec >= NSEC_PER_SEC)
-            {
-              abstime.tv_sec++;
-              abstime.tv_nsec -= NSEC_PER_SEC;
-            }
-
-          ret = nxsem_timedwait_uninterruptible(sem, &abstime);
+          ret = nxsem_tickwait_uninterruptible(sem, MSEC2TICK(timeout));
         }
 
       if (ret >= 0)
diff --git a/net/utils/net_lock.c b/net/utils/net_lock.c
index 8d634cbaa4..5dc6967c4c 100644
--- a/net/utils/net_lock.c
+++ b/net/utils/net_lock.c
@@ -97,27 +97,15 @@ _net_timedwait(sem_t *sem, bool interruptible, unsigned int timeout)
 
   if (timeout != UINT_MAX)
     {
-      struct timespec abstime;
-
-      DEBUGVERIFY(clock_gettime(CLOCK_REALTIME, &abstime));
-
-      abstime.tv_sec  += timeout / MSEC_PER_SEC;
-      abstime.tv_nsec += timeout % MSEC_PER_SEC * NSEC_PER_MSEC;
-      if (abstime.tv_nsec >= NSEC_PER_SEC)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= NSEC_PER_SEC;
-        }
-
       /* Wait until we get the lock or until the timeout expires */
 
       if (interruptible)
         {
-          ret = nxsem_timedwait(sem, &abstime);
+          ret = nxsem_tickwait(sem, MSEC2TICK(timeout));
         }
       else
         {
-          ret = nxsem_timedwait_uninterruptible(sem, &abstime);
+          ret = nxsem_tickwait_uninterruptible(sem, MSEC2TICK(timeout));
         }
     }
   else
@@ -447,7 +435,7 @@ int net_lockedwait_uninterruptible(sem_t *sem)
  * Description:
  *   Allocate an IOB.  If no IOBs are available, then atomically wait for
  *   for the IOB while temporarily releasing the lock on the network.
- *   This function is wrapped version of nxsem_timedwait(), this wait will
+ *   This function is wrapped version of nxsem_tickwait(), this wait will
  *   be terminated when the specified timeout expires.
  *
  *   Caution should be utilized.  Because the network lock is relinquished
diff --git a/sched/semaphore/sem_clockwait.c b/sched/semaphore/sem_clockwait.c
index d203ee676a..1ea1d4fc86 100644
--- a/sched/semaphore/sem_clockwait.c
+++ b/sched/semaphore/sem_clockwait.c
@@ -190,7 +190,7 @@ out:
  * Name: nxsem_clockwait_uninterruptible
  *
  * Description:
- *   This function is wrapped version of nxsem_timedwait(), which is
+ *   This function is wrapped version of nxsem_clockwait(), which is
  *   uninterruptible and convenient for use.
  *
  * Input Parameters:
diff --git a/wireless/bluetooth/bt_hcicore.c b/wireless/bluetooth/bt_hcicore.c
index 1914835b53..8268f0943b 100644
--- a/wireless/bluetooth/bt_hcicore.c
+++ b/wireless/bluetooth/bt_hcicore.c
@@ -76,8 +76,7 @@
  * to be adjusted.
  */
 
-#define TIMEOUT_SEC    2
-#define TIMEOUT_NSEC   500 * 1024 * 1024
+#define TIMEOUT_MSEC   2500
 
 /****************************************************************************
  * Public Data
@@ -1816,8 +1815,6 @@ int bt_hci_cmd_send_sync(uint16_t opcode, FAR struct bt_buf_s *buf,
     }
   else
     {
-      struct timespec abstime;
-
       /* Wait for the response to the command.  An I/O error will be
        * declared if the response does not occur within the timeout
        * interval.
@@ -1825,38 +1822,10 @@ int bt_hci_cmd_send_sync(uint16_t opcode, FAR struct bt_buf_s *buf,
        * REVISIT: The cause of the timeout could be a failure to receive a
        * response to a sent frame or, perhaps, a failure to send the frame.
        * Should there also be logic to flush any unsent Tx packets?
-       *
-       * Get the current time.  Not that we lock the scheduler here so that
-       * we can be assured that there will be no context switches will occur
-       * between the time that we calculate the delay time and until we get
-       * to the wait.
        */
 
-      sched_lock();
-      ret = clock_gettime(CLOCK_REALTIME, &abstime);
-      if (ret >= 0)
-        {
-          /* Add the offset to the time in the future */
-
-          abstime.tv_sec  += TIMEOUT_SEC;
-          abstime.tv_nsec += TIMEOUT_NSEC;
-
-          /* Handle carry from nanoseconds to seconds */
-
-          if (abstime.tv_nsec >= NSEC_PER_SEC)
-            {
-              abstime.tv_nsec -= NSEC_PER_SEC;
-              abstime.tv_sec++;
-            }
-
-          /* Now wait for the response.  The scheduler lock will be
-           * released while we are waiting.
-           */
-
-          ret = nxsem_timedwait_uninterruptible(&sync_sem, &abstime);
-        }
-
-      sched_unlock();
+      ret = nxsem_tickwait_uninterruptible(&sync_sem,
+                                           MSEC2TICK(TIMEOUT_MSEC));
     }
 
   /* Indicate failure if we failed to get the response */


[incubator-nuttx] 04/06: arch: Remove the extra space before the function prototype

Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 2976accd9f591ccde87ea4a9b28a065f6bd8128d
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Tue May 10 12:06:44 2022 +0800

    arch: Remove the extra space before the function prototype
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 arch/arm/src/cxd56xx/cxd56_usbdev.c      |  2 +-
 arch/arm/src/efm32/efm32_i2c.c           |  4 +-
 arch/arm/src/imxrt/imxrt_lpi2c.c         | 38 +++++++-------
 arch/arm/src/kinetis/kinetis_i2c.c       |  6 +--
 arch/arm/src/lc823450/lc823450_i2c.c     | 46 ++++++++--------
 arch/arm/src/rp2040/rp2040_usbdev.c      |  2 +-
 arch/arm/src/s32k1xx/s32k1xx_lpi2c.c     | 90 ++++++++++++++++----------------
 arch/arm/src/stm32/stm32_hrtim.c         |  4 +-
 arch/arm/src/stm32l4/stm32l4_i2c.c       |  2 +-
 arch/arm/src/stm32l4/stm32l4_otgfsdev.c  |  4 +-
 arch/arm/src/stm32l4/stm32l4_otgfshost.c |  4 +-
 arch/arm/src/stm32l4/stm32l4_pwm.c       |  2 +-
 arch/mips/src/pic32mx/pic32mx_ethernet.c |  4 +-
 arch/mips/src/pic32mz/pic32mz_ethernet.c |  2 +-
 arch/mips/src/pic32mz/pic32mz_i2c.c      | 54 +++++++++----------
 arch/mips/src/pic32mz/pic32mz_timer.c    |  4 +-
 arch/xtensa/src/esp32/esp32_spiflash.c   |  6 +--
 net/route/net_queue_ramroute.c           | 12 ++---
 net/route/ramroute.h                     | 12 ++---
 19 files changed, 149 insertions(+), 149 deletions(-)

diff --git a/arch/arm/src/cxd56xx/cxd56_usbdev.c b/arch/arm/src/cxd56xx/cxd56_usbdev.c
index 3cfc664a27..64f1b5c41b 100644
--- a/arch/arm/src/cxd56xx/cxd56_usbdev.c
+++ b/arch/arm/src/cxd56xx/cxd56_usbdev.c
@@ -442,7 +442,7 @@ static void cxd56_usbreset(struct cxd56_usbdev_s *priv);
 /* Interrupt handling */
 
 static struct cxd56_ep_s *
-  cxd56_epfindbyaddr(struct cxd56_usbdev_s *priv, uint16_t eplog);
+cxd56_epfindbyaddr(struct cxd56_usbdev_s *priv, uint16_t eplog);
 static void cxd56_dispatchrequest(struct cxd56_usbdev_s *priv);
 static inline void cxd56_ep0setup(struct cxd56_usbdev_s *priv);
 static int cxd56_usbinterrupt(int irq, void *context, void *arg);
diff --git a/arch/arm/src/efm32/efm32_i2c.c b/arch/arm/src/efm32/efm32_i2c.c
index eb0ede3f43..5262413a2d 100644
--- a/arch/arm/src/efm32/efm32_i2c.c
+++ b/arch/arm/src/efm32/efm32_i2c.c
@@ -262,7 +262,7 @@ static inline void efm32_i2c_modifyreg(struct efm32_i2c_priv_s *priv,
                                        uint32_t setbits);
 static inline int efm32_i2c_sem_wait(struct efm32_i2c_priv_s *priv);
 static int
-  efm32_i2c_sem_wait_noncancelable(struct efm32_i2c_priv_s *priv);
+efm32_i2c_sem_wait_noncancelable(struct efm32_i2c_priv_s *priv);
 
 #ifdef CONFIG_EFM32_I2C_DYNTIMEOUT
 static useconds_t efm32_i2c_tousecs(int msgc, struct i2c_msg_s *msgs);
@@ -482,7 +482,7 @@ static inline int efm32_i2c_sem_wait(struct efm32_i2c_priv_s *priv)
  ****************************************************************************/
 
 static int
-  efm32_i2c_sem_wait_noncancelable(struct efm32_i2c_priv_s *priv)
+efm32_i2c_sem_wait_noncancelable(struct efm32_i2c_priv_s *priv)
 {
   return nxsem_wait_uninterruptible(&priv->sem_excl);
 }
diff --git a/arch/arm/src/imxrt/imxrt_lpi2c.c b/arch/arm/src/imxrt/imxrt_lpi2c.c
index 6f4750bc6d..ff031dfdbc 100644
--- a/arch/arm/src/imxrt/imxrt_lpi2c.c
+++ b/arch/arm/src/imxrt/imxrt_lpi2c.c
@@ -218,7 +218,7 @@ struct imxrt_lpi2c_priv_s
  ****************************************************************************/
 
 static inline uint32_t
-  imxrt_lpi2c_getreg(struct imxrt_lpi2c_priv_s *priv, uint16_t offset);
+imxrt_lpi2c_getreg(struct imxrt_lpi2c_priv_s *priv, uint16_t offset);
 static inline void imxrt_lpi2c_putreg(struct imxrt_lpi2c_priv_s *priv,
                                       uint16_t offset, uint32_t value);
 static inline void imxrt_lpi2c_modifyreg(struct imxrt_lpi2c_priv_s *priv,
@@ -227,7 +227,7 @@ static inline void imxrt_lpi2c_modifyreg(struct imxrt_lpi2c_priv_s *priv,
 static inline int imxrt_lpi2c_sem_wait(struct imxrt_lpi2c_priv_s *priv);
 #ifdef CONFIG_I2C_RESET
 static int
-  imxrt_lpi2c_sem_wait_noncancelable(struct imxrt_lpi2c_priv_s *priv);
+imxrt_lpi2c_sem_wait_noncancelable(struct imxrt_lpi2c_priv_s *priv);
 #endif
 
 #ifdef CONFIG_IMXRT_LPI2C_DYNTIMEO
@@ -235,15 +235,15 @@ static useconds_t imxrt_lpi2c_tousecs(int msgc, struct i2c_msg_s *msgs);
 #endif /* CONFIG_IMXRT_LPI2C_DYNTIMEO */
 
 static inline int
-  imxrt_lpi2c_sem_waitdone(struct imxrt_lpi2c_priv_s *priv);
+imxrt_lpi2c_sem_waitdone(struct imxrt_lpi2c_priv_s *priv);
 static inline void
-  imxrt_lpi2c_sem_waitstop(struct imxrt_lpi2c_priv_s *priv);
+imxrt_lpi2c_sem_waitstop(struct imxrt_lpi2c_priv_s *priv);
 static inline void
-  imxrt_lpi2c_sem_post(struct imxrt_lpi2c_priv_s *priv);
+imxrt_lpi2c_sem_post(struct imxrt_lpi2c_priv_s *priv);
 static inline void
-  imxrt_lpi2c_sem_init(struct imxrt_lpi2c_priv_s *priv);
+imxrt_lpi2c_sem_init(struct imxrt_lpi2c_priv_s *priv);
 static inline void
-  imxrt_lpi2c_sem_destroy(struct imxrt_lpi2c_priv_s *priv);
+imxrt_lpi2c_sem_destroy(struct imxrt_lpi2c_priv_s *priv);
 
 #ifdef CONFIG_I2C_TRACE
 static void imxrt_lpi2c_tracereset(struct imxrt_lpi2c_priv_s *priv);
@@ -260,7 +260,7 @@ static inline void imxrt_lpi2c_sendstart(struct imxrt_lpi2c_priv_s *priv,
                                          uint8_t address);
 static inline void imxrt_lpi2c_sendstop(struct imxrt_lpi2c_priv_s *priv);
 static inline uint32_t
-  imxrt_lpi2c_getstatus(struct imxrt_lpi2c_priv_s *priv);
+imxrt_lpi2c_getstatus(struct imxrt_lpi2c_priv_s *priv);
 
 static int imxrt_lpi2c_isr_process(struct imxrt_lpi2c_priv_s * priv);
 
@@ -475,7 +475,7 @@ static struct imxrt_lpi2c_priv_s imxrt_lpi2c4_priv =
  ****************************************************************************/
 
 static inline uint32_t
-  imxrt_lpi2c_getreg(struct imxrt_lpi2c_priv_s *priv, uint16_t offset)
+imxrt_lpi2c_getreg(struct imxrt_lpi2c_priv_s *priv, uint16_t offset)
 {
   return getreg32(priv->config->base + offset);
 }
@@ -533,7 +533,7 @@ static inline int imxrt_lpi2c_sem_wait(struct imxrt_lpi2c_priv_s *priv)
 
 #ifdef CONFIG_I2C_RESET
 static int
-  imxrt_lpi2c_sem_wait_noncancelable(struct imxrt_lpi2c_priv_s *priv)
+imxrt_lpi2c_sem_wait_noncancelable(struct imxrt_lpi2c_priv_s *priv)
 {
   return nxsem_wait_uninterruptible(&priv->sem_excl);
 }
@@ -579,7 +579,7 @@ static useconds_t imxrt_lpi2c_tousecs(int msgc, struct i2c_msg_s *msgs)
 
 #ifndef CONFIG_I2C_POLLED
 static inline int
-  imxrt_lpi2c_sem_waitdone(struct imxrt_lpi2c_priv_s *priv)
+imxrt_lpi2c_sem_waitdone(struct imxrt_lpi2c_priv_s *priv)
 {
   irqstate_t flags;
   uint32_t regval;
@@ -669,7 +669,7 @@ static inline int
 }
 #else
 static inline int
-  imxrt_lpi2c_sem_waitdone(struct imxrt_lpi2c_priv_s *priv)
+imxrt_lpi2c_sem_waitdone(struct imxrt_lpi2c_priv_s *priv)
 {
   clock_t timeout;
   clock_t start;
@@ -729,7 +729,7 @@ static inline int
  ****************************************************************************/
 
 static inline void
-  imxrt_lpi2c_sem_waitstop(struct imxrt_lpi2c_priv_s *priv)
+imxrt_lpi2c_sem_waitstop(struct imxrt_lpi2c_priv_s *priv)
 {
   clock_t start;
   clock_t elapsed;
@@ -853,7 +853,7 @@ static inline void imxrt_lpi2c_sem_init(struct imxrt_lpi2c_priv_s *priv)
  ****************************************************************************/
 
 static inline void
-  imxrt_lpi2c_sem_destroy(struct imxrt_lpi2c_priv_s *priv)
+imxrt_lpi2c_sem_destroy(struct imxrt_lpi2c_priv_s *priv)
 {
   nxsem_destroy(&priv->sem_excl);
 #ifndef CONFIG_I2C_POLLED
@@ -1187,7 +1187,7 @@ static inline void imxrt_lpi2c_sendstart(struct imxrt_lpi2c_priv_s *priv,
     }
 
   imxrt_lpi2c_putreg(priv, IMXRT_LPI2C_MTDR_OFFSET,
-                    (LPI2C_MTDR_CMD_START | LPI2C_MTDR_DATA(addr)));
+                     (LPI2C_MTDR_CMD_START | LPI2C_MTDR_DATA(addr)));
 }
 
 /****************************************************************************
@@ -1212,7 +1212,7 @@ static inline void imxrt_lpi2c_sendstop(struct imxrt_lpi2c_priv_s *priv)
  ****************************************************************************/
 
 static inline uint32_t
-  imxrt_lpi2c_getstatus(struct imxrt_lpi2c_priv_s *priv)
+imxrt_lpi2c_getstatus(struct imxrt_lpi2c_priv_s *priv)
 {
   return imxrt_lpi2c_getreg(priv, IMXRT_LPI2C_MSR_OFFSET);
 }
@@ -1562,9 +1562,9 @@ static int imxrt_lpi2c_init(struct imxrt_lpi2c_priv_s *priv)
   /* Set scl, sda glitch filters and busy idle */
 
   imxrt_lpi2c_putreg(priv, IMXRT_LPI2C_MCFGR2_OFFSET,
-                    LPI2C_MCFG2_BUSIDLE(priv->config->busy_idle) |
-                    LPI2C_MCFG2_FILTSCL_CYCLES(priv->config->filtscl) |
-                    LPI2C_MCFG2_FILTSDA_CYCLES(priv->config->filtsda));
+                     LPI2C_MCFG2_BUSIDLE(priv->config->busy_idle) |
+                     LPI2C_MCFG2_FILTSCL_CYCLES(priv->config->filtscl) |
+                     LPI2C_MCFG2_FILTSDA_CYCLES(priv->config->filtsda));
 
   /* Set pin low cycles to 0 (disable) */
 
diff --git a/arch/arm/src/kinetis/kinetis_i2c.c b/arch/arm/src/kinetis/kinetis_i2c.c
index c6ef7af2d4..6cac05ce2e 100644
--- a/arch/arm/src/kinetis/kinetis_i2c.c
+++ b/arch/arm/src/kinetis/kinetis_i2c.c
@@ -134,12 +134,12 @@ static void kinetis_i2c_putreg(struct kinetis_i2cdev_s *priv,
 
 static inline void kinetis_i2c_sem_init(struct kinetis_i2cdev_s *priv);
 static inline void
-  kinetis_i2c_sem_destroy(struct kinetis_i2cdev_s *priv);
+kinetis_i2c_sem_destroy(struct kinetis_i2cdev_s *priv);
 static inline int kinetis_i2c_sem_wait(struct kinetis_i2cdev_s *priv);
 
 #ifdef CONFIG_I2C_RESET
 static int
-  kinetis_i2c_sem_wait_noncancelable(struct kinetis_i2cdev_s *priv);
+kinetis_i2c_sem_wait_noncancelable(struct kinetis_i2cdev_s *priv);
 #endif
 
 static inline void kinetis_i2c_sem_post(struct kinetis_i2cdev_s *priv);
@@ -361,7 +361,7 @@ static inline int kinetis_i2c_sem_wait(struct kinetis_i2cdev_s *priv)
  ****************************************************************************/
 
 static int
-  kinetis_i2c_sem_wait_noncancelable(struct kinetis_i2cdev_s *priv)
+kinetis_i2c_sem_wait_noncancelable(struct kinetis_i2cdev_s *priv)
 {
   return nxsem_wait_uninterruptible(&priv->mutex);
 }
diff --git a/arch/arm/src/lc823450/lc823450_i2c.c b/arch/arm/src/lc823450/lc823450_i2c.c
index 280396fe59..2e779ab435 100644
--- a/arch/arm/src/lc823450/lc823450_i2c.c
+++ b/arch/arm/src/lc823450/lc823450_i2c.c
@@ -138,30 +138,30 @@ struct lc823450_i2c_priv_s
  ****************************************************************************/
 
 static inline int
-  lc823450_i2c_sem_wait(struct lc823450_i2c_priv_s *priv);
+lc823450_i2c_sem_wait(struct lc823450_i2c_priv_s *priv);
 static inline void
-  lc823450_i2c_sem_post(struct lc823450_i2c_priv_s *priv);
+lc823450_i2c_sem_post(struct lc823450_i2c_priv_s *priv);
 static inline int
-  lc823450_i2c_sem_waitdone(struct lc823450_i2c_priv_s *priv);
+lc823450_i2c_sem_waitdone(struct lc823450_i2c_priv_s *priv);
 
 #ifndef CONFIG_I2C_POLLED
 static inline void
-  lc823450_i2c_enableirq(struct lc823450_i2c_priv_s *priv);
+lc823450_i2c_enableirq(struct lc823450_i2c_priv_s *priv);
 static inline void
-  lc823450_i2c_disableirq(struct lc823450_i2c_priv_s *priv);
+lc823450_i2c_disableirq(struct lc823450_i2c_priv_s *priv);
 #endif
 static inline bool
-  lc823450_i2c_checkirq(struct lc823450_i2c_priv_s *priv);
+lc823450_i2c_checkirq(struct lc823450_i2c_priv_s *priv);
 static inline bool
-  lc823450_i2c_checkbusy(struct lc823450_i2c_priv_s *priv);
+lc823450_i2c_checkbusy(struct lc823450_i2c_priv_s *priv);
 static inline void
-  lc823450_i2c_prepxfer(struct lc823450_i2c_priv_s *priv);
+lc823450_i2c_prepxfer(struct lc823450_i2c_priv_s *priv);
 static inline void
-  lc823450_i2c_sendstart(struct lc823450_i2c_priv_s *priv);
+lc823450_i2c_sendstart(struct lc823450_i2c_priv_s *priv);
 static inline void
-  lc823450_i2c_sendstop(struct lc823450_i2c_priv_s *priv);
+lc823450_i2c_sendstop(struct lc823450_i2c_priv_s *priv);
 static inline uint32_t
-  lc823450_i2c_readdata(struct lc823450_i2c_priv_s *priv);
+lc823450_i2c_readdata(struct lc823450_i2c_priv_s *priv);
 static void lc823450_i2c_starttransfer(struct lc823450_i2c_priv_s *priv);
 
 static int lc823450_i2c_poll(struct lc823450_i2c_priv_s *priv);
@@ -171,7 +171,7 @@ static int lc823450_i2c_isr(int irq, void *context, void *arg);
 
 static int lc823450_i2c_init(struct lc823450_i2c_priv_s *priv, int port);
 static int
-  lc823450_i2c_deinit(struct lc823450_i2c_priv_s *priv, int port);
+lc823450_i2c_deinit(struct lc823450_i2c_priv_s *priv, int port);
 
 static int lc823450_i2c_transfer(struct i2c_master_s *dev,
                                  struct i2c_msg_s *msgs, int count);
@@ -273,7 +273,7 @@ static inline int lc823450_i2c_sem_wait(struct lc823450_i2c_priv_s *priv)
  ****************************************************************************/
 
 static inline void
-  lc823450_i2c_sem_post(struct lc823450_i2c_priv_s *priv)
+lc823450_i2c_sem_post(struct lc823450_i2c_priv_s *priv)
 {
   nxsem_post(&priv->sem_excl);
 }
@@ -288,7 +288,7 @@ static inline void
 
 #ifndef CONFIG_I2C_POLLED
 static inline int
-  lc823450_i2c_sem_waitdone(struct lc823450_i2c_priv_s *priv)
+lc823450_i2c_sem_waitdone(struct lc823450_i2c_priv_s *priv)
 {
   int ret;
 
@@ -319,7 +319,7 @@ static inline int
 }
 #else
 static inline int
-  lc823450_i2c_sem_waitdone(struct lc823450_i2c_priv_s *priv)
+lc823450_i2c_sem_waitdone(struct lc823450_i2c_priv_s *priv)
 {
   uint32_t timeout;
   clock_t start;
@@ -390,7 +390,7 @@ static void lc823450_i2c_prepxfer(struct lc823450_i2c_priv_s *priv)
  ****************************************************************************/
 
 static inline bool
-  lc823450_i2c_checkbusy(struct lc823450_i2c_priv_s *priv)
+lc823450_i2c_checkbusy(struct lc823450_i2c_priv_s *priv)
 {
   return (getreg32(priv->config->base + I2CSTR) & I2C_STR_BBSY) != 0;
 }
@@ -404,7 +404,7 @@ static inline bool
  ****************************************************************************/
 
 static inline bool
-  lc823450_i2c_checkirq(struct lc823450_i2c_priv_s *priv)
+lc823450_i2c_checkirq(struct lc823450_i2c_priv_s *priv)
 {
   return (getreg32(priv->config->base + I2CSTR) & I2C_STR_IREQ) != 0;
 }
@@ -418,7 +418,7 @@ static inline bool
  ****************************************************************************/
 
 static inline bool
-  lc823450_i2c_checkack(struct lc823450_i2c_priv_s *priv)
+lc823450_i2c_checkack(struct lc823450_i2c_priv_s *priv)
 {
   return (getreg32(priv->config->base + I2CSTR) & I2C_STR_ACKD) != 0;
 }
@@ -432,7 +432,7 @@ static inline bool
  ****************************************************************************/
 
 static inline void
-  lc823450_i2c_sendstart(struct lc823450_i2c_priv_s *priv)
+lc823450_i2c_sendstart(struct lc823450_i2c_priv_s *priv)
 {
   modifyreg32(priv->config->base + I2CCTL, I2C_CTL_TRX, I2C_CTL_TRX);
   modifyreg32(priv->config->base + I2CCTL, I2C_CTL_ST, I2C_CTL_ST);
@@ -447,7 +447,7 @@ static inline void
  ****************************************************************************/
 
 static inline void
-  lc823450_i2c_sendstop(struct lc823450_i2c_priv_s *priv)
+lc823450_i2c_sendstop(struct lc823450_i2c_priv_s *priv)
 {
   modifyreg32(priv->config->base + I2CSTR, I2C_STR_IREQ, 0);
   modifyreg32(priv->config->base + I2CCTL, I2C_CTL_TRX, I2C_CTL_TRX);
@@ -497,7 +497,7 @@ static int lc823450_i2c_reset(struct i2c_master_s *dev)
 
 #ifndef CONFIG_I2C_POLLED
 static inline void
-  lc823450_i2c_enableirq(struct lc823450_i2c_priv_s *priv)
+lc823450_i2c_enableirq(struct lc823450_i2c_priv_s *priv)
 {
   modifyreg32(priv->config->base + I2CCTL, I2C_CTL_IREQEN, I2C_CTL_IREQEN);
 }
@@ -513,7 +513,7 @@ static inline void
 
 #ifndef CONFIG_I2C_POLLED
 static inline void
-  lc823450_i2c_disableirq(struct lc823450_i2c_priv_s *priv)
+lc823450_i2c_disableirq(struct lc823450_i2c_priv_s *priv)
 {
   modifyreg32(priv->config->base + I2CCTL, I2C_CTL_IREQEN, 0);
 }
@@ -528,7 +528,7 @@ static inline void
  ****************************************************************************/
 
 static inline uint32_t
-  lc823450_i2c_readdata(struct lc823450_i2c_priv_s *priv)
+lc823450_i2c_readdata(struct lc823450_i2c_priv_s *priv)
 {
   return getreg32(priv->config->base + I2CRXD);
 }
diff --git a/arch/arm/src/rp2040/rp2040_usbdev.c b/arch/arm/src/rp2040/rp2040_usbdev.c
index 608343c92e..8bac7a7c16 100644
--- a/arch/arm/src/rp2040/rp2040_usbdev.c
+++ b/arch/arm/src/rp2040/rp2040_usbdev.c
@@ -327,7 +327,7 @@ static void rp2040_handle_zlp(struct rp2040_usbdev_s *priv);
 
 static void rp2040_cancelrequests(struct rp2040_ep_s *privep);
 static struct rp2040_ep_s *
-  rp2040_epfindbyaddr(struct rp2040_usbdev_s *priv, uint16_t eplog);
+rp2040_epfindbyaddr(struct rp2040_usbdev_s *priv, uint16_t eplog);
 static void rp2040_dispatchrequest(struct rp2040_usbdev_s *priv);
 static void rp2040_ep0setup(struct rp2040_usbdev_s *priv);
 
diff --git a/arch/arm/src/s32k1xx/s32k1xx_lpi2c.c b/arch/arm/src/s32k1xx/s32k1xx_lpi2c.c
index daadde4928..dc8d4851d2 100644
--- a/arch/arm/src/s32k1xx/s32k1xx_lpi2c.c
+++ b/arch/arm/src/s32k1xx/s32k1xx_lpi2c.c
@@ -209,33 +209,33 @@ struct s32k1xx_lpi2c_priv_s
  ****************************************************************************/
 
 static inline uint32_t
-  s32k1xx_lpi2c_getreg(struct s32k1xx_lpi2c_priv_s *priv,
-                       uint16_t offset);
+s32k1xx_lpi2c_getreg(struct s32k1xx_lpi2c_priv_s *priv,
+                     uint16_t offset);
 static inline void
-  s32k1xx_lpi2c_putreg(struct s32k1xx_lpi2c_priv_s *priv,
-                       uint16_t offset, uint32_t value);
+s32k1xx_lpi2c_putreg(struct s32k1xx_lpi2c_priv_s *priv,
+                     uint16_t offset, uint32_t value);
 static inline void
-  s32k1xx_lpi2c_modifyreg(struct s32k1xx_lpi2c_priv_s *priv,
-                          uint16_t offset, uint32_t clearbits,
-                          uint32_t setbits);
+s32k1xx_lpi2c_modifyreg(struct s32k1xx_lpi2c_priv_s *priv,
+                        uint16_t offset, uint32_t clearbits,
+                        uint32_t setbits);
 static inline int
-  s32k1xx_lpi2c_sem_wait(struct s32k1xx_lpi2c_priv_s *priv);
+s32k1xx_lpi2c_sem_wait(struct s32k1xx_lpi2c_priv_s *priv);
 
 #ifdef CONFIG_S32K1XX_I2C_DYNTIMEO
 static useconds_t
-  s32k1xx_lpi2c_tousecs(int msgc, struct i2c_msg_s *msgs);
+s32k1xx_lpi2c_tousecs(int msgc, struct i2c_msg_s *msgs);
 #endif /* CONFIG_S32K1XX_I2C_DYNTIMEO */
 
 static inline int
-  s32k1xx_lpi2c_sem_waitdone(struct s32k1xx_lpi2c_priv_s *priv);
+s32k1xx_lpi2c_sem_waitdone(struct s32k1xx_lpi2c_priv_s *priv);
 static inline void
-  s32k1xx_lpi2c_sem_waitstop(struct s32k1xx_lpi2c_priv_s *priv);
+s32k1xx_lpi2c_sem_waitstop(struct s32k1xx_lpi2c_priv_s *priv);
 static inline void
-  s32k1xx_lpi2c_sem_post(struct s32k1xx_lpi2c_priv_s *priv);
+s32k1xx_lpi2c_sem_post(struct s32k1xx_lpi2c_priv_s *priv);
 static inline void
-  s32k1xx_lpi2c_sem_init(struct s32k1xx_lpi2c_priv_s *priv);
+s32k1xx_lpi2c_sem_init(struct s32k1xx_lpi2c_priv_s *priv);
 static inline void
-  s32k1xx_lpi2c_sem_destroy(struct s32k1xx_lpi2c_priv_s *priv);
+s32k1xx_lpi2c_sem_destroy(struct s32k1xx_lpi2c_priv_s *priv);
 
 #ifdef CONFIG_I2C_TRACE
 static void s32k1xx_lpi2c_tracereset(struct s32k1xx_lpi2c_priv_s *priv);
@@ -251,12 +251,12 @@ static uint32_t s32k1xx_lpi2c_pckfreq(uintptr_t base);
 static void s32k1xx_lpi2c_setclock(struct s32k1xx_lpi2c_priv_s *priv,
                                    uint32_t frequency);
 static inline void
-  s32k1xx_lpi2c_sendstart(struct s32k1xx_lpi2c_priv_s *priv,
-                          uint8_t address);
+s32k1xx_lpi2c_sendstart(struct s32k1xx_lpi2c_priv_s *priv,
+                        uint8_t address);
 static inline void
-  s32k1xx_lpi2c_sendstop(struct s32k1xx_lpi2c_priv_s *priv);
+s32k1xx_lpi2c_sendstop(struct s32k1xx_lpi2c_priv_s *priv);
 static inline uint32_t
-  s32k1xx_lpi2c_getstatus(struct s32k1xx_lpi2c_priv_s *priv);
+s32k1xx_lpi2c_getstatus(struct s32k1xx_lpi2c_priv_s *priv);
 
 static int s32k1xx_lpi2c_isr_process(struct s32k1xx_lpi2c_priv_s *priv);
 
@@ -377,8 +377,8 @@ static struct s32k1xx_lpi2c_priv_s s32k1xx_lpi2c1_priv =
  ****************************************************************************/
 
 static inline uint32_t
-  s32k1xx_lpi2c_getreg(struct s32k1xx_lpi2c_priv_s *priv,
-                       uint16_t offset)
+s32k1xx_lpi2c_getreg(struct s32k1xx_lpi2c_priv_s *priv,
+                     uint16_t offset)
 {
   return getreg32(priv->config->base + offset);
 }
@@ -392,8 +392,8 @@ static inline uint32_t
  ****************************************************************************/
 
 static inline void
-  s32k1xx_lpi2c_putreg(struct s32k1xx_lpi2c_priv_s *priv,
-                       uint16_t offset, uint32_t value)
+s32k1xx_lpi2c_putreg(struct s32k1xx_lpi2c_priv_s *priv,
+                     uint16_t offset, uint32_t value)
 {
   putreg32(value, priv->config->base + offset);
 }
@@ -407,9 +407,9 @@ static inline void
  ****************************************************************************/
 
 static inline void
-  s32k1xx_lpi2c_modifyreg(struct s32k1xx_lpi2c_priv_s *priv,
-                          uint16_t offset, uint32_t clearbits,
-                          uint32_t setbits)
+s32k1xx_lpi2c_modifyreg(struct s32k1xx_lpi2c_priv_s *priv,
+                        uint16_t offset, uint32_t clearbits,
+                        uint32_t setbits)
 {
   modifyreg32(priv->config->base + offset, clearbits, setbits);
 }
@@ -424,7 +424,7 @@ static inline void
  ****************************************************************************/
 
 static inline int
-  s32k1xx_lpi2c_sem_wait(struct s32k1xx_lpi2c_priv_s *priv)
+s32k1xx_lpi2c_sem_wait(struct s32k1xx_lpi2c_priv_s *priv)
 {
   return nxsem_wait(&priv->sem_excl);
 }
@@ -469,7 +469,7 @@ static useconds_t s32k1xx_lpi2c_tousecs(int msgc, struct i2c_msg_s *msgs)
 
 #ifndef CONFIG_I2C_POLLED
 static inline int
-  s32k1xx_lpi2c_sem_waitdone(struct s32k1xx_lpi2c_priv_s *priv)
+s32k1xx_lpi2c_sem_waitdone(struct s32k1xx_lpi2c_priv_s *priv)
 {
   irqstate_t flags;
   uint32_t regval;
@@ -561,7 +561,7 @@ static inline int
 }
 #else
 static inline int
-  s32k1xx_lpi2c_sem_waitdone(struct s32k1xx_lpi2c_priv_s *priv)
+s32k1xx_lpi2c_sem_waitdone(struct s32k1xx_lpi2c_priv_s *priv)
 {
   clock_t timeout;
   clock_t start;
@@ -621,7 +621,7 @@ static inline int
  ****************************************************************************/
 
 static inline void
-  s32k1xx_lpi2c_sem_waitstop(struct s32k1xx_lpi2c_priv_s *priv)
+s32k1xx_lpi2c_sem_waitstop(struct s32k1xx_lpi2c_priv_s *priv)
 {
   clock_t start;
   clock_t elapsed;
@@ -723,7 +723,7 @@ static inline void s32k1xx_lpi2c_sem_post(struct s32k1xx_lpi2c_priv_s *priv)
  ****************************************************************************/
 
 static inline void
-  s32k1xx_lpi2c_sem_init(struct s32k1xx_lpi2c_priv_s *priv)
+s32k1xx_lpi2c_sem_init(struct s32k1xx_lpi2c_priv_s *priv)
 {
   nxsem_init(&priv->sem_excl, 0, 1);
 
@@ -746,7 +746,7 @@ static inline void
  ****************************************************************************/
 
 static inline void
-  s32k1xx_lpi2c_sem_destroy(struct s32k1xx_lpi2c_priv_s *priv)
+s32k1xx_lpi2c_sem_destroy(struct s32k1xx_lpi2c_priv_s *priv)
 {
   nxsem_destroy(&priv->sem_excl);
 #ifndef CONFIG_I2C_POLLED
@@ -1070,8 +1070,8 @@ static void s32k1xx_lpi2c_setclock(struct s32k1xx_lpi2c_priv_s *priv,
  ****************************************************************************/
 
 static inline void
-  s32k1xx_lpi2c_sendstart(struct s32k1xx_lpi2c_priv_s *priv,
-                          uint8_t address)
+s32k1xx_lpi2c_sendstart(struct s32k1xx_lpi2c_priv_s *priv,
+                        uint8_t address)
 {
   uint32_t txcount = 0;
   uint32_t status = 0;
@@ -1082,7 +1082,7 @@ static inline void
   /* Turn off auto_stop option */
 
   s32k1xx_lpi2c_modifyreg(priv, S32K1XX_LPI2C_MCFGR1_OFFSET,
-                        LPI2C_MCFGR1_IGNACK, 0);
+                          LPI2C_MCFGR1_IGNACK, 0);
 
   do
     {
@@ -1110,7 +1110,7 @@ static inline void
     }
 
   s32k1xx_lpi2c_putreg(priv, S32K1XX_LPI2C_MTDR_OFFSET,
-                    (LPI2C_MTDR_CMD_START | LPI2C_MTDR_DATA(addr)));
+                       (LPI2C_MTDR_CMD_START | LPI2C_MTDR_DATA(addr)));
 }
 
 /****************************************************************************
@@ -1122,7 +1122,7 @@ static inline void
  ****************************************************************************/
 
 static inline void
-  s32k1xx_lpi2c_sendstop(struct s32k1xx_lpi2c_priv_s *priv)
+s32k1xx_lpi2c_sendstop(struct s32k1xx_lpi2c_priv_s *priv)
 {
   s32k1xx_lpi2c_putreg(priv, S32K1XX_LPI2C_MTDR_OFFSET, LPI2C_MTDR_CMD_STOP);
 }
@@ -1136,7 +1136,7 @@ static inline void
  ****************************************************************************/
 
 static inline uint32_t
-  s32k1xx_lpi2c_getstatus(struct s32k1xx_lpi2c_priv_s *priv)
+s32k1xx_lpi2c_getstatus(struct s32k1xx_lpi2c_priv_s *priv)
 {
   return s32k1xx_lpi2c_getreg(priv, S32K1XX_LPI2C_MSR_OFFSET);
 }
@@ -1412,18 +1412,18 @@ static int s32k1xx_lpi2c_init(struct s32k1xx_lpi2c_priv_s *priv)
   /* Disable host request */
 
   s32k1xx_lpi2c_modifyreg(priv, S32K1XX_LPI2C_MCFGR0_OFFSET,
-                        LPI2C_MCFG0_HREN | LPI2C_MCFG0_HRSEL,
-                        LPI2C_MCFG0_HRPOL);
+                          LPI2C_MCFG0_HREN | LPI2C_MCFG0_HRSEL,
+                          LPI2C_MCFG0_HRPOL);
 
   /* Pin config and ignore NACK disable */
 
   s32k1xx_lpi2c_modifyreg(priv, S32K1XX_LPI2C_MCFGR1_OFFSET,
-                        LPI2C_MCFGR1_IGNACK | LPI2C_MCFGR1_PINCFG_MASK, 0);
+                          LPI2C_MCFGR1_IGNACK | LPI2C_MCFGR1_PINCFG_MASK, 0);
 
   /* Set tx and rx watermarks */
 
   s32k1xx_lpi2c_putreg(priv, S32K1XX_LPI2C_MFCR_OFFSET,
-                     LPI2C_MFCR_TXWATER(0) | LPI2C_MFCR_RXWATER(0));
+                       LPI2C_MFCR_TXWATER(0) | LPI2C_MFCR_RXWATER(0));
 
   /* Force a frequency update */
 
@@ -1433,14 +1433,14 @@ static int s32k1xx_lpi2c_init(struct s32k1xx_lpi2c_priv_s *priv)
   /* Set scl, sda glitch filters and busy idle */
 
   s32k1xx_lpi2c_putreg(priv, S32K1XX_LPI2C_MCFGR2_OFFSET,
-                    LPI2C_MCFG2_BUSIDLE(priv->config->busy_idle) |
-                    LPI2C_MCFG2_FILTSCL_CYCLES(priv->config->filtscl) |
-                    LPI2C_MCFG2_FILTSDA_CYCLES(priv->config->filtsda));
+                       LPI2C_MCFG2_BUSIDLE(priv->config->busy_idle) |
+                       LPI2C_MCFG2_FILTSCL_CYCLES(priv->config->filtscl) |
+                       LPI2C_MCFG2_FILTSDA_CYCLES(priv->config->filtsda));
 
   /* Set pin low cycles to 0 (disable) */
 
   s32k1xx_lpi2c_putreg(priv, S32K1XX_LPI2C_MCFGR3_OFFSET,
-                     LPI2C_MCFG3_PINLOW_CYCLES(0));
+                       LPI2C_MCFG3_PINLOW_CYCLES(0));
 
   /* Attach ISRs */
 
diff --git a/arch/arm/src/stm32/stm32_hrtim.c b/arch/arm/src/stm32/stm32_hrtim.c
index 157aa244b9..b1242d96bb 100644
--- a/arch/arm/src/stm32/stm32_hrtim.c
+++ b/arch/arm/src/stm32/stm32_hrtim.c
@@ -1786,7 +1786,7 @@ static void hrtim_cmn_modifyreg(struct stm32_hrtim_s *priv,
  ****************************************************************************/
 
 static struct stm32_hrtim_tim_s *
-  hrtim_tim_get(struct stm32_hrtim_s *priv, uint8_t timer)
+hrtim_tim_get(struct stm32_hrtim_s *priv, uint8_t timer)
 {
   struct stm32_hrtim_tim_s *tim;
 
@@ -1865,7 +1865,7 @@ static struct stm32_hrtim_tim_s *
 
 #if defined(CONFIG_STM32_HRTIM_PWM) || defined(CONFIG_STM32_HRTIM_FAULTS)
 static struct stm32_hrtim_slave_priv_s *
-  hrtim_slave_get(struct stm32_hrtim_s *priv, uint8_t timer)
+hrtim_slave_get(struct stm32_hrtim_s *priv, uint8_t timer)
 {
   struct stm32_hrtim_tim_s *tim;
   struct stm32_hrtim_slave_priv_s *slave;
diff --git a/arch/arm/src/stm32l4/stm32l4_i2c.c b/arch/arm/src/stm32l4/stm32l4_i2c.c
index ecf1703a9f..ee939589cf 100644
--- a/arch/arm/src/stm32l4/stm32l4_i2c.c
+++ b/arch/arm/src/stm32l4/stm32l4_i2c.c
@@ -931,7 +931,7 @@ int stm32l4_i2c_sem_waitdone(struct stm32l4_i2c_priv_s *priv)
  ****************************************************************************/
 
 static inline void
-  stm32l4_i2c_set_7bit_address(struct stm32l4_i2c_priv_s *priv)
+stm32l4_i2c_set_7bit_address(struct stm32l4_i2c_priv_s *priv)
 {
   stm32l4_i2c_modifyreg32(priv, STM32L4_I2C_CR2_OFFSET, I2C_CR2_SADD7_MASK,
                         ((priv->msgv->addr & 0x7f) << I2C_CR2_SADD7_SHIFT));
diff --git a/arch/arm/src/stm32l4/stm32l4_otgfsdev.c b/arch/arm/src/stm32l4/stm32l4_otgfsdev.c
index 5697fd5550..e12dae8e5b 100644
--- a/arch/arm/src/stm32l4/stm32l4_otgfsdev.c
+++ b/arch/arm/src/stm32l4/stm32l4_otgfsdev.c
@@ -989,7 +989,7 @@ static void stm32l4_putreg(uint32_t val, uint32_t addr)
  ****************************************************************************/
 
 static struct stm32l4_req_s *
-  stm32l4_req_remfirst(struct stm32l4_ep_s *privep)
+stm32l4_req_remfirst(struct stm32l4_ep_s *privep)
 {
   struct stm32l4_req_s *ret = privep->head;
 
@@ -1060,7 +1060,7 @@ static void stm32l4_ep0in_setupresponse(struct stm32l4_usbdev_s *priv,
  ****************************************************************************/
 
 static inline void
-  stm32l4_ep0in_transmitzlp(struct stm32l4_usbdev_s *priv)
+stm32l4_ep0in_transmitzlp(struct stm32l4_usbdev_s *priv)
 {
   stm32l4_ep0in_setupresponse(priv, NULL, 0);
 }
diff --git a/arch/arm/src/stm32l4/stm32l4_otgfshost.c b/arch/arm/src/stm32l4/stm32l4_otgfshost.c
index 34f91fc162..f2b72c359e 100644
--- a/arch/arm/src/stm32l4/stm32l4_otgfshost.c
+++ b/arch/arm/src/stm32l4/stm32l4_otgfshost.c
@@ -394,9 +394,9 @@ static void stm32l4_gint_disconnected(struct stm32l4_usbhost_s *priv);
 static inline void stm32l4_gint_sofisr(struct stm32l4_usbhost_s *priv);
 #endif
 static inline void
-  stm32l4_gint_rxflvlisr(struct stm32l4_usbhost_s *priv);
+stm32l4_gint_rxflvlisr(struct stm32l4_usbhost_s *priv);
 static inline void
-  stm32l4_gint_nptxfeisr(struct stm32l4_usbhost_s *priv);
+stm32l4_gint_nptxfeisr(struct stm32l4_usbhost_s *priv);
 static inline void stm32l4_gint_ptxfeisr(struct stm32l4_usbhost_s *priv);
 static inline void stm32l4_gint_hcisr(struct stm32l4_usbhost_s *priv);
 static inline void stm32l4_gint_hprtisr(struct stm32l4_usbhost_s *priv);
diff --git a/arch/arm/src/stm32l4/stm32l4_pwm.c b/arch/arm/src/stm32l4/stm32l4_pwm.c
index 49cda889f1..57f680c2f7 100644
--- a/arch/arm/src/stm32l4/stm32l4_pwm.c
+++ b/arch/arm/src/stm32l4/stm32l4_pwm.c
@@ -2665,7 +2665,7 @@ static int pwm_soft_break(struct pwm_lowerhalf_s *dev, bool state)
  ****************************************************************************/
 
 static uint16_t
-  pwm_outputs_from_channels(struct stm32l4_pwmtimer_s *priv)
+pwm_outputs_from_channels(struct stm32l4_pwmtimer_s *priv)
 {
   uint16_t outputs = 0;
   uint8_t  channel = 0;
diff --git a/arch/mips/src/pic32mx/pic32mx_ethernet.c b/arch/mips/src/pic32mx/pic32mx_ethernet.c
index 3a2df1d3ed..938141b8cc 100644
--- a/arch/mips/src/pic32mx/pic32mx_ethernet.c
+++ b/arch/mips/src/pic32mx/pic32mx_ethernet.c
@@ -376,7 +376,7 @@ static void pic32mx_freebuffer(struct pic32mx_driver_s *priv,
 static inline void pic32mx_txdescinit(struct pic32mx_driver_s *priv);
 static inline void pic32mx_rxdescinit(struct pic32mx_driver_s *priv);
 static inline struct pic32mx_txdesc_s *
-  pic32mx_txdesc(struct pic32mx_driver_s *priv);
+pic32mx_txdesc(struct pic32mx_driver_s *priv);
 static inline void pic32mx_txnext(struct pic32mx_driver_s *priv);
 static inline void pic32mx_rxreturn(struct pic32mx_rxdesc_s *rxdesc);
 static struct pic32mx_rxdesc_s *
@@ -858,7 +858,7 @@ static inline void pic32mx_rxdescinit(struct pic32mx_driver_s *priv)
  ****************************************************************************/
 
 static inline struct pic32mx_txdesc_s *
-  pic32mx_txdesc(struct pic32mx_driver_s *priv)
+pic32mx_txdesc(struct pic32mx_driver_s *priv)
 {
   struct pic32mx_txdesc_s *txdesc;
 
diff --git a/arch/mips/src/pic32mz/pic32mz_ethernet.c b/arch/mips/src/pic32mz/pic32mz_ethernet.c
index 7c8745f34b..8cb709de3a 100644
--- a/arch/mips/src/pic32mz/pic32mz_ethernet.c
+++ b/arch/mips/src/pic32mz/pic32mz_ethernet.c
@@ -930,7 +930,7 @@ static inline void pic32mz_rxdescinit(struct pic32mz_driver_s *priv)
  ****************************************************************************/
 
 static inline struct pic32mz_txdesc_s *
-  pic32mz_txdesc(struct pic32mz_driver_s *priv)
+pic32mz_txdesc(struct pic32mz_driver_s *priv)
 {
   struct pic32mz_txdesc_s *txdesc;
 
diff --git a/arch/mips/src/pic32mz/pic32mz_i2c.c b/arch/mips/src/pic32mz/pic32mz_i2c.c
index 4020004d10..35af74ea1a 100644
--- a/arch/mips/src/pic32mz/pic32mz_i2c.c
+++ b/arch/mips/src/pic32mz/pic32mz_i2c.c
@@ -219,8 +219,8 @@ struct pic32mz_i2c_priv_s
  ****************************************************************************/
 
 static inline uint32_t
-  pic32mz_i2c_getreg(struct pic32mz_i2c_priv_s *priv,
-                     uint8_t offset);
+pic32mz_i2c_getreg(struct pic32mz_i2c_priv_s *priv,
+                   uint8_t offset);
 static inline void pic32mz_i2c_putreg(struct pic32mz_i2c_priv_s *priv,
                                       uint8_t offset, uint32_t value);
 static inline void pic32mz_i2c_modifyreg(struct pic32mz_i2c_priv_s *priv,
@@ -232,44 +232,44 @@ static useconds_t pic32mz_i2c_tousecs(int msgc, struct i2c_msg_s *msgs);
 #endif /* CONFIG_PIC32MZ_I2C_DYNTIMEO */
 
 static inline int
-  pic32mz_i2c_sem_waitdone(struct pic32mz_i2c_priv_s *priv);
+pic32mz_i2c_sem_waitdone(struct pic32mz_i2c_priv_s *priv);
 static inline void
-  pic32mz_i2c_sem_waitidle(struct pic32mz_i2c_priv_s *priv);
+pic32mz_i2c_sem_waitidle(struct pic32mz_i2c_priv_s *priv);
 static inline void pic32mz_i2c_sem_post(struct pic32mz_i2c_priv_s *priv);
 static inline void pic32mz_i2c_sem_init(struct pic32mz_i2c_priv_s *priv);
 static inline void
-  pic32mz_i2c_sem_destroy(struct pic32mz_i2c_priv_s *priv);
+pic32mz_i2c_sem_destroy(struct pic32mz_i2c_priv_s *priv);
 
 #ifdef CONFIG_I2C_TRACE
 static void pic32mz_i2c_tracereset(struct pic32mz_i2c_priv_s *priv);
 static void pic32mz_i2c_tracenew(struct pic32mz_i2c_priv_s *priv,
                                  uint32_t status);
 static void
-  pic32mz_i2c_traceevent(struct pic32mz_i2c_priv_s *priv,
-                         enum pic32mz_trace_e event, uint32_t parm);
+pic32mz_i2c_traceevent(struct pic32mz_i2c_priv_s *priv,
+                       enum pic32mz_trace_e event, uint32_t parm);
 static void pic32mz_i2c_tracedump(struct pic32mz_i2c_priv_s *priv);
 #endif /* CONFIG_I2C_TRACE */
 
 static inline int
-  pic32mz_i2c_setbaudrate(struct pic32mz_i2c_priv_s *priv,
-                          uint32_t frequency);
+pic32mz_i2c_setbaudrate(struct pic32mz_i2c_priv_s *priv,
+                        uint32_t frequency);
 static inline void
-  pic32mz_i2c_send_start(struct pic32mz_i2c_priv_s *priv);
+pic32mz_i2c_send_start(struct pic32mz_i2c_priv_s *priv);
 static inline void
-  pic32mz_i2c_send_stop(struct pic32mz_i2c_priv_s *priv);
+pic32mz_i2c_send_stop(struct pic32mz_i2c_priv_s *priv);
 static inline void
-  pic32mz_i2c_send_repeatedstart(struct pic32mz_i2c_priv_s *priv);
+pic32mz_i2c_send_repeatedstart(struct pic32mz_i2c_priv_s *priv);
 static inline void pic32mz_i2c_send_ack(struct pic32mz_i2c_priv_s *priv,
                                         bool ack);
 static inline void pic32mz_i2c_transmitbyte(struct pic32mz_i2c_priv_s *priv,
                                             uint8_t data);
 static inline uint32_t
-  pic32mz_i2c_receivebyte(struct pic32mz_i2c_priv_s *priv);
+pic32mz_i2c_receivebyte(struct pic32mz_i2c_priv_s *priv);
 
 static inline uint32_t
-  pic32mz_i2c_getstatus(struct pic32mz_i2c_priv_s *priv);
+pic32mz_i2c_getstatus(struct pic32mz_i2c_priv_s *priv);
 static inline bool
-  pic32mz_i2c_master_inactive(struct pic32mz_i2c_priv_s *priv);
+pic32mz_i2c_master_inactive(struct pic32mz_i2c_priv_s *priv);
 
 static int pic32mz_i2c_isr_process(struct pic32mz_i2c_priv_s * priv);
 
@@ -581,7 +581,7 @@ static void pic32mz_i2c_tracedump(struct pic32mz_i2c_priv_s *priv)
  ****************************************************************************/
 
 static inline uint32_t
-  pic32mz_i2c_getreg(struct pic32mz_i2c_priv_s *priv, uint8_t offset)
+pic32mz_i2c_getreg(struct pic32mz_i2c_priv_s *priv, uint8_t offset)
 {
   return getreg32(priv->config->base + offset);
 }
@@ -658,7 +658,7 @@ static useconds_t pic32mz_i2c_tousecs(int msgc, struct i2c_msg_s *msgs)
 
 #ifndef CONFIG_I2C_POLLED
 static inline int
-  pic32mz_i2c_sem_waitdone(struct pic32mz_i2c_priv_s *priv)
+pic32mz_i2c_sem_waitdone(struct pic32mz_i2c_priv_s *priv)
 {
   irqstate_t flags;
   int ret;
@@ -710,7 +710,7 @@ static inline int
 }
 #else
 static inline int
-  pic32mz_i2c_sem_waitdone(struct pic32mz_i2c_priv_s *priv)
+pic32mz_i2c_sem_waitdone(struct pic32mz_i2c_priv_s *priv)
 {
   clock_t timeout;
   clock_t start;
@@ -770,7 +770,7 @@ static inline int
  ****************************************************************************/
 
 static inline void
-  pic32mz_i2c_sem_waitidle(struct pic32mz_i2c_priv_s *priv)
+pic32mz_i2c_sem_waitidle(struct pic32mz_i2c_priv_s *priv)
 {
   uint32_t timeout;
   uint32_t start;
@@ -853,7 +853,7 @@ static inline void pic32mz_i2c_sem_init(struct pic32mz_i2c_priv_s *priv)
  ****************************************************************************/
 
 static inline void
-  pic32mz_i2c_sem_destroy(struct pic32mz_i2c_priv_s *priv)
+pic32mz_i2c_sem_destroy(struct pic32mz_i2c_priv_s *priv)
 {
   nxsem_destroy(&priv->sem_excl);
 #ifndef CONFIG_I2C_POLLED
@@ -1276,8 +1276,8 @@ static int pic32mz_i2c_isr(int irq, void *context, void *arg)
  ****************************************************************************/
 
 static inline int
-  pic32mz_i2c_setbaudrate(struct pic32mz_i2c_priv_s *priv,
-                          uint32_t frequency)
+pic32mz_i2c_setbaudrate(struct pic32mz_i2c_priv_s *priv,
+                        uint32_t frequency)
 {
   uint32_t baudrate;
 
@@ -1326,7 +1326,7 @@ static inline int
  ****************************************************************************/
 
 static inline void
-  pic32mz_i2c_send_start(struct pic32mz_i2c_priv_s *priv)
+pic32mz_i2c_send_start(struct pic32mz_i2c_priv_s *priv)
 {
   pic32mz_i2c_putreg(priv, PIC32MZ_I2C_CONSET_OFFSET, I2C_CON_SEN);
 
@@ -1367,7 +1367,7 @@ static inline void pic32mz_i2c_send_stop(struct pic32mz_i2c_priv_s *priv)
  ****************************************************************************/
 
 static inline void
-  pic32mz_i2c_send_repeatedstart(struct pic32mz_i2c_priv_s *priv)
+pic32mz_i2c_send_repeatedstart(struct pic32mz_i2c_priv_s *priv)
 {
   pic32mz_i2c_putreg(priv, PIC32MZ_I2C_CONSET_OFFSET, I2C_CON_RSEN);
 
@@ -1439,7 +1439,7 @@ static inline void pic32mz_i2c_transmitbyte(struct pic32mz_i2c_priv_s *priv,
  ****************************************************************************/
 
 static inline uint32_t
-  pic32mz_i2c_receivebyte(struct pic32mz_i2c_priv_s *priv)
+pic32mz_i2c_receivebyte(struct pic32mz_i2c_priv_s *priv)
 {
   uint32_t val;
 
@@ -1465,7 +1465,7 @@ static inline uint32_t
  ****************************************************************************/
 
 static inline bool
-  pic32mz_i2c_master_inactive(struct pic32mz_i2c_priv_s *priv)
+pic32mz_i2c_master_inactive(struct pic32mz_i2c_priv_s *priv)
 {
   uint32_t con;
 
@@ -1483,7 +1483,7 @@ static inline bool
  ****************************************************************************/
 
 static inline uint32_t
-  pic32mz_i2c_getstatus(struct pic32mz_i2c_priv_s *priv)
+pic32mz_i2c_getstatus(struct pic32mz_i2c_priv_s *priv)
 {
   return pic32mz_i2c_getreg(priv, PIC32MZ_I2C_STAT_OFFSET);
 }
diff --git a/arch/mips/src/pic32mz/pic32mz_timer.c b/arch/mips/src/pic32mz/pic32mz_timer.c
index cd703f0c97..0492730a72 100644
--- a/arch/mips/src/pic32mz/pic32mz_timer.c
+++ b/arch/mips/src/pic32mz/pic32mz_timer.c
@@ -133,7 +133,7 @@ static inline void pic32mz_putreg(struct pic32mz_timer_dev_s *dev,
 static inline bool pic32mz_timer_mode32(struct pic32mz_timer_dev_s *dev);
 static inline uint32_t pic32mz_timer_oddoffset(uint32_t evenoffset);
 static inline uint32_t
-  pic32mz_timer_nextirq(struct pic32mz_timer_dev_s *dev);
+pic32mz_timer_nextirq(struct pic32mz_timer_dev_s *dev);
 
 static void pic32mz_timer_stopinidle(struct pic32mz_timer_dev_s *dev,
                                     bool stop);
@@ -588,7 +588,7 @@ static inline uint32_t pic32mz_timer_oddoffset(uint32_t evenoffset)
  ****************************************************************************/
 
 static inline uint32_t
-  pic32mz_timer_nextirq(struct pic32mz_timer_dev_s *dev)
+pic32mz_timer_nextirq(struct pic32mz_timer_dev_s *dev)
 {
   uint32_t irq;
 
diff --git a/arch/xtensa/src/esp32/esp32_spiflash.c b/arch/xtensa/src/esp32/esp32_spiflash.c
index ba44ea26c7..a14d028be7 100644
--- a/arch/xtensa/src/esp32/esp32_spiflash.c
+++ b/arch/xtensa/src/esp32/esp32_spiflash.c
@@ -194,9 +194,9 @@ static inline void spi_reset_regbits(struct esp32_spiflash_s *priv,
 /* Misc. helpers */
 
 static inline void IRAM_ATTR
-  esp32_spiflash_opstart(struct spiflash_cachestate_s *state);
+esp32_spiflash_opstart(struct spiflash_cachestate_s *state);
 static inline void IRAM_ATTR
-  esp32_spiflash_opdone(const struct spiflash_cachestate_s *state);
+esp32_spiflash_opdone(const struct spiflash_cachestate_s *state);
 
 static bool IRAM_ATTR spiflash_pagecached(uint32_t phypage);
 static void IRAM_ATTR spiflash_flushmapped(size_t start, size_t size);
@@ -408,7 +408,7 @@ static inline void spi_reset_regbits(struct esp32_spiflash_s *priv,
  ****************************************************************************/
 
 static inline void IRAM_ATTR
-  esp32_spiflash_opstart(struct spiflash_cachestate_s *state)
+esp32_spiflash_opstart(struct spiflash_cachestate_s *state)
 {
   state->flags = enter_critical_section();
 
diff --git a/net/route/net_queue_ramroute.c b/net/route/net_queue_ramroute.c
index 9d9f6fdbf2..c1ae77335f 100644
--- a/net/route/net_queue_ramroute.c
+++ b/net/route/net_queue_ramroute.c
@@ -102,7 +102,7 @@ void ramroute_ipv6_addlast(FAR struct net_route_ipv6_entry_s *entry,
 
 #ifdef CONFIG_ROUTE_IPv4_RAMROUTE
 FAR struct net_route_ipv4_entry_s *
-  ramroute_ipv4_remfirst(struct net_route_ipv4_queue_s *list)
+ramroute_ipv4_remfirst(FAR struct net_route_ipv4_queue_s *list)
 {
   FAR struct net_route_ipv4_entry_s *ret = list->head;
 
@@ -123,7 +123,7 @@ FAR struct net_route_ipv4_entry_s *
 
 #ifdef CONFIG_ROUTE_IPv6_RAMROUTE
 FAR struct net_route_ipv6_entry_s *
-  ramroute_ipv6_remfirst(struct net_route_ipv6_queue_s *list)
+ramroute_ipv6_remfirst(FAR struct net_route_ipv6_queue_s *list)
 {
   FAR struct net_route_ipv6_entry_s *ret = list->head;
 
@@ -161,8 +161,8 @@ FAR struct net_route_ipv6_entry_s *
 
 #ifdef CONFIG_ROUTE_IPv4_RAMROUTE
 FAR struct net_route_ipv4_entry_s *
-  ramroute_ipv4_remafter(FAR struct net_route_ipv4_entry_s *entry,
-                         FAR struct net_route_ipv4_queue_s *list)
+ramroute_ipv4_remafter(FAR struct net_route_ipv4_entry_s *entry,
+                       FAR struct net_route_ipv4_queue_s *list)
 {
   FAR struct net_route_ipv4_entry_s *ret = entry->flink;
 
@@ -187,8 +187,8 @@ FAR struct net_route_ipv4_entry_s *
 
 #ifdef CONFIG_ROUTE_IPv6_RAMROUTE
 FAR struct net_route_ipv6_entry_s *
-  ramroute_ipv6_remafter(FAR struct net_route_ipv6_entry_s *entry,
-  struct net_route_ipv6_queue_s *list)
+ramroute_ipv6_remafter(FAR struct net_route_ipv6_entry_s *entry,
+                       FAR struct net_route_ipv6_queue_s *list)
 {
   FAR struct net_route_ipv6_entry_s *ret = entry->flink;
 
diff --git a/net/route/ramroute.h b/net/route/ramroute.h
index 7986674fef..164084ef96 100644
--- a/net/route/ramroute.h
+++ b/net/route/ramroute.h
@@ -200,20 +200,20 @@ 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(FAR 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,
-                         FAR struct net_route_ipv4_queue_s *list);
+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(FAR 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,
-  struct net_route_ipv6_queue_s *list);
+ramroute_ipv6_remafter(FAR struct net_route_ipv6_entry_s *entry,
+                       FAR struct net_route_ipv6_queue_s *list);
 #endif
 
 #endif /* CONFIG_ROUTE_IPv4_RAMROUTE || CONFIG_ROUTE_IPv6_RAMROUTE */


[incubator-nuttx] 02/06: Replace nxsem_timedwait with nxsem_tickwait

Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 816ce73ab48bd9ad440a9d6cf8ca9a2ac98463e0
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Tue May 10 13:20:32 2022 +0800

    Replace nxsem_timedwait with nxsem_tickwait
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 arch/arm/src/am335x/am335x_i2c.c                 | 41 ++++++------------------
 arch/arm/src/cxd56xx/cxd56_gnss.c                | 13 +-------
 arch/arm/src/lc823450/lc823450_i2c.c             |  2 +-
 arch/arm/src/rtl8720c/amebaz_depend.c            | 15 ++-------
 arch/arm/src/samd2l2/sam_i2c_master.c            | 17 ++--------
 arch/arm/src/samd5e5/sam_i2c_master.c            | 17 ++--------
 arch/arm/src/stm32/stm32_1wire.c                 | 13 ++------
 arch/arm/src/stm32l4/stm32l4_1wire.c             | 13 ++------
 arch/risc-v/src/bl602/bl602_os_hal.c             | 15 +--------
 arch/risc-v/src/esp32c3/esp32c3_ble_adapter.c    | 12 ++-----
 arch/risc-v/src/esp32c3/esp32c3_i2c.c            | 22 ++++---------
 arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c   | 15 +--------
 arch/risc-v/src/esp32c3/esp32c3_wifi_utils.c     |  5 +--
 arch/xtensa/src/esp32/esp32_ble_adapter.c        | 15 +--------
 arch/xtensa/src/esp32/esp32_i2c.c                | 22 ++++---------
 arch/xtensa/src/esp32/esp32_wifi_adapter.c       | 15 +--------
 arch/xtensa/src/esp32/esp32_wifi_utils.c         |  5 +--
 drivers/can/can.c                                | 13 ++------
 drivers/contactless/pn532.c                      |  5 +--
 drivers/wireless/ieee80211/bcm43xxx/bcmf_utils.c | 19 +----------
 20 files changed, 51 insertions(+), 243 deletions(-)

diff --git a/arch/arm/src/am335x/am335x_i2c.c b/arch/arm/src/am335x/am335x_i2c.c
index e8831a55c1..b906629332 100644
--- a/arch/arm/src/am335x/am335x_i2c.c
+++ b/arch/arm/src/am335x/am335x_i2c.c
@@ -508,7 +508,6 @@ static useconds_t am335x_i2c_tousecs(int msgc, struct i2c_msg_s *msgs)
 #ifndef CONFIG_I2C_POLLED
 static inline int am335x_i2c_sem_waitdone(struct am335x_i2c_priv_s *priv)
 {
-  struct timespec abstime;
   irqstate_t flags;
   uint32_t regval;
   int ret;
@@ -546,48 +545,26 @@ static inline int am335x_i2c_sem_waitdone(struct am335x_i2c_priv_s *priv)
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * nxsem_timedwait() sleeps.
+   * nxsem_tickwait() sleeps.
    */
 
   priv->intstate = INTSTATE_WAITING;
   do
     {
-      /* Get the current time */
-
-      clock_gettime(CLOCK_REALTIME, &abstime);
-
-      /* Calculate a time in the future */
-
-#if CONFIG_AM335X_I2CTIMEOSEC > 0
-      abstime.tv_sec += CONFIG_AM335X_I2CTIMEOSEC;
-#endif
-
-      /* Add a value proportional to the number of bytes in the transfer */
+      /* Wait until either the transfer is complete or the timeout expires */
 
 #ifdef CONFIG_AM335X_I2C_DYNTIMEO
-      abstime.tv_nsec += 1000 * am335x_i2c_tousecs(priv->msgc, priv->msgv);
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
-
-#elif CONFIG_AM335X_I2CTIMEOMS > 0
-      abstime.tv_nsec += CONFIG_AM335X_I2CTIMEOMS * 1000 * 1000;
-      if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-        {
-          abstime.tv_sec++;
-          abstime.tv_nsec -= 1000 * 1000 * 1000;
-        }
+      ret = nxsem_tickwait(&priv->sem_isr,
+                           USEC2TICK(am335x_i2c_tousecs(priv->msgc,
+                                                        priv->msgv));
+#else
+      ret = nxsem_tickwait(&priv->sem_isr,
+                           CONFIG_AM335X_I2CTIMEOTICKS);
 #endif
-
-      /* Wait until either the transfer is complete or the timeout expires */
-
-      ret = nxsem_timedwait(&priv->sem_isr, &abstime);
       if (ret < 0 && ret != -EINTR)
         {
           /* Break out of the loop on irrecoverable errors.  This would
-           * include timeouts and mystery errors reported by nxsem_timedwait.
+           * include timeouts and mystery errors reported by nxsem_tickwait.
            * NOTE that we try again if we are awakened by a signal (EINTR).
            */
 
diff --git a/arch/arm/src/cxd56xx/cxd56_gnss.c b/arch/arm/src/cxd56xx/cxd56_gnss.c
index 65c0887945..41fb3cb5ae 100644
--- a/arch/arm/src/cxd56xx/cxd56_gnss.c
+++ b/arch/arm/src/cxd56xx/cxd56_gnss.c
@@ -2108,18 +2108,7 @@ static int cxd56_gnss_get_1pps_output(struct file *filep,
 
 static int cxd56_gnss_wait_notify(sem_t *sem, time_t waitsec)
 {
-  int             ret;
-  struct timespec timeout;
-
-  ret = clock_gettime(CLOCK_REALTIME, &timeout);
-  if (ret < 0)
-    {
-      return ret;
-    }
-
-  timeout.tv_sec += waitsec; /* <waitsec> seconds timeout for wait */
-
-  return nxsem_timedwait(sem, &timeout);
+  return nxsem_tickwait(sem, SEC2TICK(waitsec));
 }
 
 /****************************************************************************
diff --git a/arch/arm/src/lc823450/lc823450_i2c.c b/arch/arm/src/lc823450/lc823450_i2c.c
index 922fb36336..c308ed905a 100644
--- a/arch/arm/src/lc823450/lc823450_i2c.c
+++ b/arch/arm/src/lc823450/lc823450_i2c.c
@@ -350,7 +350,7 @@ static inline int
 
   /* Signal the interrupt handler that we are waiting.  NOTE:  Interrupts
    * are currently disabled but will be temporarily re-enabled below when
-   * sem_timedwait() sleeps.
+   * nxsem_tickwait() sleeps.
    */
 
   start = clock_systime_ticks();
diff --git a/arch/arm/src/rtl8720c/amebaz_depend.c b/arch/arm/src/rtl8720c/amebaz_depend.c
index c12450bfa6..35c902aff8 100644
--- a/arch/arm/src/rtl8720c/amebaz_depend.c
+++ b/arch/arm/src/rtl8720c/amebaz_depend.c
@@ -196,25 +196,16 @@ void rtw_up_sema_from_isr(void **sema)
 
 uint32_t rtw_down_timeout_sema(void **sema, uint32_t timeout)
 {
-  struct timespec abstime;
   int ret;
+
   if (timeout == 0xffffffff)
     {
-      ret = sem_wait(*sema);
+      ret = nxsem_wait(*sema);
     }
 
   else
     {
-      clock_gettime(CLOCK_REALTIME, &abstime);
-      abstime.tv_sec += timeout / 1000;
-      abstime.tv_nsec += (timeout % 1000) * 1000 * 1000;
-      if (abstime.tv_nsec >= (1000 * 1000000))
-        {
-          abstime.tv_sec += 1;
-          abstime.tv_nsec -= (1000 * 1000000);
-        }
-
-      ret = sem_timedwait(*sema, &abstime);
+      ret = nxsem_tickwait(*sema, MSEC2TICK(timeout));
     }
 
   return !ret;
diff --git a/arch/arm/src/samd2l2/sam_i2c_master.c b/arch/arm/src/samd2l2/sam_i2c_master.c
index e371141870..83b7d334e5 100644
--- a/arch/arm/src/samd2l2/sam_i2c_master.c
+++ b/arch/arm/src/samd2l2/sam_i2c_master.c
@@ -642,25 +642,12 @@ static inline void i2c_putrel(struct sam_i2c_dev_s *priv,
 
 static int i2c_wait_for_bus(struct sam_i2c_dev_s *priv, unsigned int size)
 {
-  struct timespec ts;
   int ret;
-  long usec;
 
-  clock_gettime(CLOCK_REALTIME, &ts);
-
-  usec = size * I2C_TIMEOUT_MSPB + ts.tv_nsec / 1000;
-  while (usec >= USEC_PER_SEC)
-    {
-      ts.tv_sec += 1;
-      usec      -= USEC_PER_SEC;
-    }
-
-  ts.tv_nsec = usec * 1000;
-
-  ret = nxsem_timedwait(&priv->waitsem, (const struct timespec *)&ts);
+  ret = nxsem_tickwait(&priv->waitsem, USEC2TICK(size * I2C_TIMEOUT_MSPB));
   if (ret < 0)
     {
-      i2cinfo("timedwait error %d\n", ret);
+      i2cinfo("nxsem_tickwait error %d\n", ret);
       return ret;
     }
 
diff --git a/arch/arm/src/samd5e5/sam_i2c_master.c b/arch/arm/src/samd5e5/sam_i2c_master.c
index 72e2827b4c..cb4db72537 100644
--- a/arch/arm/src/samd5e5/sam_i2c_master.c
+++ b/arch/arm/src/samd5e5/sam_i2c_master.c
@@ -660,25 +660,12 @@ static inline void i2c_putrel(struct sam_i2c_dev_s *priv,
 
 static int i2c_wait_for_bus(struct sam_i2c_dev_s *priv, unsigned int size)
 {
-  struct timespec ts;
   int ret;
-  long usec;
 
-  clock_gettime(CLOCK_REALTIME, &ts);
-
-  usec = size * I2C_TIMEOUT_MSPB + ts.tv_nsec / 1000;
-  while (usec > USEC_PER_SEC)
-    {
-      ts.tv_sec += 1;
-      usec      -= USEC_PER_SEC;
-    }
-
-  ts.tv_nsec = usec * 1000;
-
-  ret = nxsem_timedwait(&priv->waitsem, (const struct timespec *)&ts);
+  ret = nxsem_tickwait(&priv->waitsem, USEC2TICK(size * I2C_TIMEOUT_MSPB));
   if (ret < 0)
     {
-      i2cinfo("timedwait error %d\n", ret);
+      i2cinfo("nxsem_tickwait error %d\n", ret);
       return ret;
     }
 
diff --git a/arch/arm/src/stm32/stm32_1wire.c b/arch/arm/src/stm32/stm32_1wire.c
index 75c90c318d..d8697ba496 100644
--- a/arch/arm/src/stm32/stm32_1wire.c
+++ b/arch/arm/src/stm32/stm32_1wire.c
@@ -776,7 +776,6 @@ static int stm32_1wire_process(struct stm32_1wire_priv_s *priv,
                                int count)
 {
   irqstate_t irqs;
-  struct timespec abstime;
   int indx;
   int ret;
 
@@ -814,9 +813,7 @@ static int stm32_1wire_process(struct stm32_1wire_priv_s *priv,
 
           /* Wait.  Break on timeout if TX line closed to GND */
 
-          clock_gettime(CLOCK_REALTIME, &abstime);
-          abstime.tv_sec += BUS_TIMEOUT;
-          nxsem_timedwait(&priv->sem_isr, &abstime);
+          nxsem_tickwait(&priv->sem_isr, SEC2TICK(BUS_TIMEOUT));
           break;
 
         case ONEWIRETASK_WRITE:
@@ -839,9 +836,7 @@ static int stm32_1wire_process(struct stm32_1wire_priv_s *priv,
 
           /* Wait.  Break on timeout if TX line closed to GND */
 
-          clock_gettime(CLOCK_REALTIME, &abstime);
-          abstime.tv_sec += BUS_TIMEOUT;
-          nxsem_timedwait(&priv->sem_isr, &abstime);
+          nxsem_tickwait(&priv->sem_isr, SEC2TICK(BUS_TIMEOUT));
           break;
 
         case ONEWIRETASK_READ:
@@ -863,9 +858,7 @@ static int stm32_1wire_process(struct stm32_1wire_priv_s *priv,
 
           /* Wait.  Break on timeout if TX line closed to GND */
 
-          clock_gettime(CLOCK_REALTIME, &abstime);
-          abstime.tv_sec += BUS_TIMEOUT;
-          nxsem_timedwait(&priv->sem_isr, &abstime);
+          nxsem_tickwait(&priv->sem_isr, SEC2TICK(BUS_TIMEOUT));
           break;
         }
 
diff --git a/arch/arm/src/stm32l4/stm32l4_1wire.c b/arch/arm/src/stm32l4/stm32l4_1wire.c
index fea618a5e1..40aea59220 100644
--- a/arch/arm/src/stm32l4/stm32l4_1wire.c
+++ b/arch/arm/src/stm32l4/stm32l4_1wire.c
@@ -696,7 +696,6 @@ static int stm32_1wire_process(struct stm32_1wire_priv_s *priv,
                                int count)
 {
   irqstate_t irqs;
-  struct timespec abstime;
   int indx;
   int ret;
 
@@ -734,9 +733,7 @@ static int stm32_1wire_process(struct stm32_1wire_priv_s *priv,
 
           /* Wait.  Break on timeout if TX line closed to GND */
 
-          clock_gettime(CLOCK_REALTIME, &abstime);
-          abstime.tv_sec += BUS_TIMEOUT;
-          nxsem_timedwait(&priv->sem_isr, &abstime);
+          nxsem_tickwait(&priv->sem_isr, SEC2TICK(BUS_TIMEOUT));
           break;
 
         case ONEWIRETASK_WRITE:
@@ -759,9 +756,7 @@ static int stm32_1wire_process(struct stm32_1wire_priv_s *priv,
 
           /* Wait.  Break on timeout if TX line closed to GND */
 
-          clock_gettime(CLOCK_REALTIME, &abstime);
-          abstime.tv_sec += BUS_TIMEOUT;
-          nxsem_timedwait(&priv->sem_isr, &abstime);
+          nxsem_tickwait(&priv->sem_isr, SEC2TICK(BUS_TIMEOUT));
           break;
 
         case ONEWIRETASK_READ:
@@ -783,9 +778,7 @@ static int stm32_1wire_process(struct stm32_1wire_priv_s *priv,
 
           /* Wait.  Break on timeout if TX line closed to GND */
 
-          clock_gettime(CLOCK_REALTIME, &abstime);
-          abstime.tv_sec += BUS_TIMEOUT;
-          nxsem_timedwait(&priv->sem_isr, &abstime);
+          nxsem_tickwait(&priv->sem_isr, SEC2TICK(BUS_TIMEOUT));
           break;
         }
 
diff --git a/arch/risc-v/src/bl602/bl602_os_hal.c b/arch/risc-v/src/bl602/bl602_os_hal.c
index 8b32067f39..2d3e84ad99 100644
--- a/arch/risc-v/src/bl602/bl602_os_hal.c
+++ b/arch/risc-v/src/bl602/bl602_os_hal.c
@@ -1461,7 +1461,6 @@ void bl_os_sem_delete(void *semphr)
 int32_t bl_os_sem_take(void *semphr, uint32_t ticks)
 {
   int ret;
-  struct timespec timeout;
   sem_t *sem = (sem_t *)semphr;
 
   if (ticks == BL_OS_WAITING_FOREVER)
@@ -1474,19 +1473,7 @@ int32_t bl_os_sem_take(void *semphr, uint32_t ticks)
     }
   else
     {
-      ret = clock_gettime(CLOCK_REALTIME, &timeout);
-      if (ret < 0)
-        {
-          wlerr("ERROR: Failed to get time\n");
-          return false;
-        }
-
-      if (ticks)
-        {
-          bl_os_update_time(&timeout, ticks);
-        }
-
-      ret = nxsem_timedwait(sem, &timeout);
+      ret = nxsem_tickwait(sem, ticks);
       if (ret)
         {
           wlerr("ERROR: Failed to wait sem in %lu ticks\n", ticks);
diff --git a/arch/risc-v/src/esp32c3/esp32c3_ble_adapter.c b/arch/risc-v/src/esp32c3/esp32c3_ble_adapter.c
index e7d50e4d6c..cb29a5a414 100644
--- a/arch/risc-v/src/esp32c3/esp32c3_ble_adapter.c
+++ b/arch/risc-v/src/esp32c3/esp32c3_ble_adapter.c
@@ -915,7 +915,6 @@ static void esp_update_time(struct timespec *timespec, uint32_t ticks)
 static int semphr_take_wrapper(void *semphr, uint32_t block_time_ms)
 {
   int ret;
-  struct timespec timeout;
   struct bt_sem_s *bt_sem = (struct bt_sem_s *)semphr;
 
   if (block_time_ms == OSI_FUNCS_TIME_BLOCKING)
@@ -930,18 +929,11 @@ static int semphr_take_wrapper(void *semphr, uint32_t block_time_ms)
     {
       if (block_time_ms > 0)
         {
-          ret = clock_gettime(CLOCK_REALTIME, &timeout);
-          if (ret < 0)
-            {
-              wlerr("Failed to get time\n");
-              return false;
-            }
-          esp_update_time(&timeout, MSEC2TICK(block_time_ms));
-          ret = sem_timedwait(&bt_sem->sem, &timeout);
+          ret = nxsem_tickwait(&bt_sem->sem, MSEC2TICK(block_time_ms));
         }
       else
         {
-          ret = sem_trywait(&bt_sem->sem);
+          ret = nxsem_trywait(&bt_sem->sem);
         }
     }
 
diff --git a/arch/risc-v/src/esp32c3/esp32c3_i2c.c b/arch/risc-v/src/esp32c3/esp32c3_i2c.c
index 7621caf437..8b7865dc3b 100644
--- a/arch/risc-v/src/esp32c3/esp32c3_i2c.c
+++ b/arch/risc-v/src/esp32c3/esp32c3_i2c.c
@@ -838,10 +838,8 @@ static int esp32c3_i2c_sem_waitdone(struct esp32c3_i2c_priv_s *priv)
 static int esp32c3_i2c_polling_waitdone(struct esp32c3_i2c_priv_s *priv)
 {
   int ret;
-  struct timespec current_time;
-  struct timespec timeout;
-  uint64_t current_us;
-  uint64_t timeout_us;
+  clock_t current;
+  clock_t timeout;
   uint32_t status = 0;
 
   /* Get the current absolute time and add an offset as timeout.
@@ -850,19 +848,14 @@ static int esp32c3_i2c_polling_waitdone(struct esp32c3_i2c_priv_s *priv)
    * forward and backwards.
    */
 
-  clock_systime_timespec(&current_time);
-
-  timeout.tv_sec  = current_time.tv_sec  + 10;
-  timeout.tv_nsec = current_time.tv_nsec +  0;
-
-  current_us = TIMESPEC_TO_US(current_time.tv_sec, current_time.tv_nsec);
-  timeout_us = TIMESPEC_TO_US(timeout.tv_sec, timeout.tv_nsec);
+  current = clock_systime_ticks();
+  timeout = current + SEC2TICK(10);
 
   /* Loop while a transfer is in progress
    * and an error didn't occur within the timeout
    */
 
-  while ((current_us < timeout_us) && (priv->error == 0))
+  while ((current < timeout) && (priv->error == 0))
     {
       /* Check if any interrupt triggered, clear them
        * process the operation.
@@ -891,8 +884,7 @@ static int esp32c3_i2c_polling_waitdone(struct esp32c3_i2c_priv_s *priv)
 
       /* Update current time */
 
-      clock_systime_timespec(&current_time);
-      current_us = TIMESPEC_TO_US(current_time.tv_sec, current_time.tv_nsec);
+      current = clock_systime_ticks();
     }
 
   /* Return a negated value in case of timeout, and in the other scenarios
@@ -901,7 +893,7 @@ static int esp32c3_i2c_polling_waitdone(struct esp32c3_i2c_priv_s *priv)
    * scenarios.
    */
 
-  if (current_us >= timeout_us)
+  if (current >= timeout)
     {
       ret = -ETIMEDOUT;
     }
diff --git a/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c b/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c
index 42483bdac7..3f80fde166 100644
--- a/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c
+++ b/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c
@@ -1209,7 +1209,6 @@ static void esp_semphr_delete(void *semphr)
 static int32_t esp_semphr_take(void *semphr, uint32_t ticks)
 {
   int ret;
-  struct timespec timeout;
   sem_t *sem = (sem_t *)semphr;
 
   if (ticks == OSI_FUNCS_TIME_BLOCKING)
@@ -1222,19 +1221,7 @@ static int32_t esp_semphr_take(void *semphr, uint32_t ticks)
     }
   else
     {
-      ret = clock_gettime(CLOCK_REALTIME, &timeout);
-      if (ret < 0)
-        {
-          wlerr("ERROR: Failed to get time\n");
-          return false;
-        }
-
-      if (ticks)
-        {
-          esp_update_time(&timeout, ticks);
-        }
-
-      ret = nxsem_timedwait(sem, &timeout);
+      ret = nxsem_tickwait(sem, ticks);
       if (ret)
         {
           wlerr("ERROR: Failed to wait sem in %lu ticks\n", ticks);
diff --git a/arch/risc-v/src/esp32c3/esp32c3_wifi_utils.c b/arch/risc-v/src/esp32c3/esp32c3_wifi_utils.c
index 07ef6bb84f..1a4e6e3ba5 100644
--- a/arch/risc-v/src/esp32c3/esp32c3_wifi_utils.c
+++ b/arch/risc-v/src/esp32c3/esp32c3_wifi_utils.c
@@ -251,7 +251,6 @@ int esp_wifi_start_scan(struct iwreq *iwr)
 int esp_wifi_get_scan_results(struct iwreq *iwr)
 {
   int ret = OK;
-  struct timespec abstime;
   static bool scan_block = false;
   struct wifi_scan_result_s *priv = &g_scan_priv;
 
@@ -262,9 +261,7 @@ int esp_wifi_get_scan_results(struct iwreq *iwr)
         {
           scan_block = true;
           leave_critical_section(irqstate);
-          clock_gettime(CLOCK_REALTIME, &abstime);
-          abstime.tv_sec += SCAN_TIME_SEC;
-          nxsem_timedwait(&priv->scan_signal, &abstime);
+          nxsem_tickwait(&priv->scan_signal, SEC2TICK(SCAN_TIME_SEC));
           scan_block = false;
         }
       else
diff --git a/arch/xtensa/src/esp32/esp32_ble_adapter.c b/arch/xtensa/src/esp32/esp32_ble_adapter.c
index a5a6237207..2d074c9b61 100644
--- a/arch/xtensa/src/esp32/esp32_ble_adapter.c
+++ b/arch/xtensa/src/esp32/esp32_ble_adapter.c
@@ -1261,7 +1261,6 @@ static void esp_update_time(struct timespec *timespec, uint32_t ticks)
 static int semphr_take_wrapper(void *semphr, uint32_t block_time_ms)
 {
   int ret;
-  struct timespec timeout;
   sem_t *sem = (sem_t *)semphr;
 
   if (block_time_ms == OSI_FUNCS_TIME_BLOCKING)
@@ -1274,19 +1273,7 @@ static int semphr_take_wrapper(void *semphr, uint32_t block_time_ms)
     }
   else
     {
-      ret = clock_gettime(CLOCK_REALTIME, &timeout);
-      if (ret < 0)
-        {
-          wlerr("Failed to get time\n");
-          return esp_errno_trans(ret);
-        }
-
-      if (block_time_ms)
-        {
-          esp_update_time(&timeout, MSEC2TICK(block_time_ms));
-        }
-
-      ret = sem_timedwait(sem, &timeout);
+      ret = nxsem_tickwait(sem, MSEC2TICK(block_time_ms));
     }
 
   return esp_errno_trans(ret);
diff --git a/arch/xtensa/src/esp32/esp32_i2c.c b/arch/xtensa/src/esp32/esp32_i2c.c
index 6417d58f5d..c665c8d3de 100644
--- a/arch/xtensa/src/esp32/esp32_i2c.c
+++ b/arch/xtensa/src/esp32/esp32_i2c.c
@@ -772,10 +772,8 @@ static int esp32_i2c_sem_waitdone(struct esp32_i2c_priv_s *priv)
 static int esp32_i2c_polling_waitdone(struct esp32_i2c_priv_s *priv)
 {
   int ret;
-  struct timespec current_time;
-  struct timespec timeout;
-  uint64_t current_us;
-  uint64_t timeout_us;
+  clock_t current;
+  clock_t timeout;
   uint32_t status = 0;
 
   /* Get the current absolute time and add an offset as timeout.
@@ -784,19 +782,14 @@ static int esp32_i2c_polling_waitdone(struct esp32_i2c_priv_s *priv)
    * forward and backwards.
    */
 
-  clock_systime_timespec(&current_time);
-
-  timeout.tv_sec  = current_time.tv_sec  + 10;
-  timeout.tv_nsec = current_time.tv_nsec +  0;
-
-  current_us = TIMESPEC_TO_US(current_time.tv_sec, current_time.tv_nsec);
-  timeout_us = TIMESPEC_TO_US(timeout.tv_sec, timeout.tv_nsec);
+  current = clock_systime_ticks();
+  timeout = current + SEC2TICK(10);
 
   /* Loop while a transfer is in progress
    * and an error didn't occur within the timeout
    */
 
-  while ((current_us < timeout_us) && (priv->error == 0))
+  while ((current < timeout) && (priv->error == 0))
     {
       /* Check if any interrupt triggered, clear them
        * process the operation.
@@ -825,8 +818,7 @@ static int esp32_i2c_polling_waitdone(struct esp32_i2c_priv_s *priv)
 
       /* Update current time */
 
-      clock_systime_timespec(&current_time);
-      current_us = TIMESPEC_TO_US(current_time.tv_sec, current_time.tv_nsec);
+      current = clock_systime_ticks();
     }
 
   /* Return a negated value in case of timeout, and in the other scenarios
@@ -835,7 +827,7 @@ static int esp32_i2c_polling_waitdone(struct esp32_i2c_priv_s *priv)
    * scenarios.
    */
 
-  if (current_us >= timeout_us)
+  if (current >= timeout)
     {
       ret = -ETIMEDOUT;
     }
diff --git a/arch/xtensa/src/esp32/esp32_wifi_adapter.c b/arch/xtensa/src/esp32/esp32_wifi_adapter.c
index b752ca0e55..35792e4d5a 100644
--- a/arch/xtensa/src/esp32/esp32_wifi_adapter.c
+++ b/arch/xtensa/src/esp32/esp32_wifi_adapter.c
@@ -1125,7 +1125,6 @@ static void esp_semphr_delete(void *semphr)
 static int32_t esp_semphr_take(void *semphr, uint32_t ticks)
 {
   int ret;
-  struct timespec timeout;
   sem_t *sem = (sem_t *)semphr;
 
   if (ticks == OSI_FUNCS_TIME_BLOCKING)
@@ -1138,19 +1137,7 @@ static int32_t esp_semphr_take(void *semphr, uint32_t ticks)
     }
   else
     {
-      ret = clock_gettime(CLOCK_REALTIME, &timeout);
-      if (ret < 0)
-        {
-          wlerr("Failed to get time\n");
-          return false;
-        }
-
-      if (ticks)
-        {
-          esp_update_time(&timeout, ticks);
-        }
-
-      ret = nxsem_timedwait(sem, &timeout);
+      ret = nxsem_tickwait(sem, ticks);
       if (ret)
         {
           wlerr("Failed to wait sem in %d ticks\n", ticks);
diff --git a/arch/xtensa/src/esp32/esp32_wifi_utils.c b/arch/xtensa/src/esp32/esp32_wifi_utils.c
index 9ceb90eaff..d88c089b64 100644
--- a/arch/xtensa/src/esp32/esp32_wifi_utils.c
+++ b/arch/xtensa/src/esp32/esp32_wifi_utils.c
@@ -251,7 +251,6 @@ int esp_wifi_start_scan(struct iwreq *iwr)
 int esp_wifi_get_scan_results(struct iwreq *iwr)
 {
   int ret = OK;
-  struct timespec abstime;
   static bool scan_block = false;
   struct wifi_scan_result *priv = &g_scan_priv;
 
@@ -260,9 +259,7 @@ int esp_wifi_get_scan_results(struct iwreq *iwr)
       if (scan_block == false)
         {
           scan_block = true;
-          clock_gettime(CLOCK_REALTIME, &abstime);
-          abstime.tv_sec += SCAN_TIME_SEC;
-          nxsem_timedwait(&priv->scan_signal, &abstime);
+          nxsem_tickwait(&priv->scan_signal, SEC2TICK(SCAN_TIME_SEC));
           scan_block = false;
         }
       else
diff --git a/drivers/can/can.c b/drivers/can/can.c
index bebc59b777..cb9316b932 100644
--- a/drivers/can/can.c
+++ b/drivers/can/can.c
@@ -923,7 +923,6 @@ static inline ssize_t can_rtrread(FAR struct file *filep,
 {
   FAR struct can_dev_s *dev = filep->f_inode->i_private;
   FAR struct can_rtrwait_s *wait = NULL;
-  struct timespec           abstimeout;
   irqstate_t                flags;
   int                       i;
   int                       sval;
@@ -1002,15 +1001,9 @@ static inline ssize_t can_rtrread(FAR struct file *filep,
         {
           /* Then wait for the response */
 
-          ret = clock_gettime(CLOCK_REALTIME, &abstimeout);
-
-          if (ret >= 0)
-            {
-              clock_timespec_add(&abstimeout,
-                                 &request->ci_timeout,
-                                 &abstimeout);
-              ret = nxsem_timedwait(&wait->cr_sem, &abstimeout);
-            }
+          ret = nxsem_tickwait(&wait->cr_sem,
+                               SEC2TICK(request->ci_timeout.tv_sec) +
+                               NSEC2TICK(request->ci_timeout.tv_nsec));
         }
     }
 
diff --git a/drivers/contactless/pn532.c b/drivers/contactless/pn532.c
index e48ea4707d..2552bd16f4 100644
--- a/drivers/contactless/pn532.c
+++ b/drivers/contactless/pn532.c
@@ -297,10 +297,7 @@ static int pn532_wait_rx_ready(FAR struct pn532_dev_s *dev, int timeout)
   int ret = OK;
 
 #ifdef CONFIG_PN532_USE_IRQ_FLOW_CONTROL
-  struct timespec ts;
-  clock_gettime(CLOCK_REALTIME, &ts);
-  ts.tv_sec += 1;
-  nxsem_timedwait(dev->sem_rx, &ts);
+  nxsem_tickwait(dev->sem_rx, SEC2TICK(1));
 #endif
 
   /* TODO: Handle Exception bits 2, 3 */
diff --git a/drivers/wireless/ieee80211/bcm43xxx/bcmf_utils.c b/drivers/wireless/ieee80211/bcm43xxx/bcmf_utils.c
index f0bd937fcc..878434190d 100644
--- a/drivers/wireless/ieee80211/bcm43xxx/bcmf_utils.c
+++ b/drivers/wireless/ieee80211/bcm43xxx/bcmf_utils.c
@@ -85,24 +85,7 @@ void bcmf_hexdump(uint8_t *data, unsigned int len, unsigned long offset)
 
 int bcmf_sem_wait(sem_t *sem, unsigned int timeout_ms)
 {
-  struct timespec abstime;
-  unsigned int timeout_sec;
-
-  /* Get the current time */
-
-  clock_gettime(CLOCK_REALTIME, &abstime);
-
-  timeout_sec      = timeout_ms / 1000;
-  abstime.tv_sec  += timeout_sec;
-  abstime.tv_nsec += 1000 * 1000 * (timeout_ms % 1000);
-
-  if (abstime.tv_nsec >= 1000 * 1000 * 1000)
-    {
-      abstime.tv_sec++;
-      abstime.tv_nsec -= 1000 * 1000 * 1000;
-    }
-
-  return nxsem_timedwait(sem, &abstime);
+  return nxsem_tickwait(sem, MSEC2TICK(timeout_ms));
 }
 
 void bcmf_dqueue_push(dq_queue_t *queue, dq_entry_t *entry)


[incubator-nuttx] 06/06: Remove FAR from arm/risc-v/xtensa/sim/x86

Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 51cf7ba05a2b4d44c2c1099e2daa69932a665594
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sat May 14 16:01:52 2022 +0800

    Remove FAR from arm/risc-v/xtensa/sim/x86
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 arch/arm/src/stm32h7/stm32_fdcan_sock.c            | 84 +++++++++++-----------
 arch/x86/src/common/up_allocateheap.c              |  4 +-
 arch/x86/src/common/up_assert.c                    |  6 +-
 arch/x86/src/common/up_exit.c                      |  4 +-
 arch/x86/src/i486/up_createstack.c                 |  2 +-
 arch/x86/src/i486/up_releasestack.c                |  2 +-
 arch/x86/src/i486/up_stackframe.c                  |  6 +-
 arch/x86/src/qemu/qemu.h                           | 12 ++--
 arch/x86/src/qemu/qemu_keypad.c                    |  4 +-
 arch/x86/src/qemu/qemu_vga.c                       | 38 +++++-----
 arch/x86/src/qemu/qemu_vga.h                       |  2 +-
 .../samd21-xplained/src/sam_ug2832hsweg04.c        |  6 +-
 boards/arm/stm32/nucleo-g474re/src/stm32_usbdev.c  |  2 +-
 libs/libc/machine/arm/aeabi_memclr.c               |  2 +-
 libs/libc/machine/arm/aeabi_memclr4.c              |  2 +-
 libs/libc/machine/arm/aeabi_memclr8.c              |  2 +-
 libs/libc/machine/arm/aeabi_memcpy.c               |  2 +-
 libs/libc/machine/arm/aeabi_memcpy4.c              |  2 +-
 libs/libc/machine/arm/aeabi_memcpy8.c              |  2 +-
 libs/libc/machine/arm/aeabi_memmove.c              |  2 +-
 libs/libc/machine/arm/aeabi_memmove4.c             |  2 +-
 libs/libc/machine/arm/aeabi_memmove8.c             |  2 +-
 libs/libc/machine/arm/aeabi_memset.c               |  2 +-
 libs/libc/machine/arm/aeabi_memset4.c              |  2 +-
 libs/libc/machine/arm/aeabi_memset8.c              |  2 +-
 libs/libc/machine/arm/arm/arch_elf.c               |  7 +-
 libs/libc/machine/arm/armv6-m/arch_elf.c           |  7 +-
 libs/libc/machine/arm/armv7-a/arch_elf.c           |  7 +-
 libs/libc/machine/arm/armv7-m/arch_elf.c           |  7 +-
 libs/libc/machine/arm/armv7-r/arch_elf.c           |  7 +-
 libs/libc/machine/arm/armv8-m/arch_elf.c           |  7 +-
 libs/libc/machine/risc-v/common/arch_elf.c         |  7 +-
 libs/libc/machine/sim/arch_elf.c                   |  9 ++-
 libs/libc/machine/sim/arch_elf64.c                 |  7 +-
 libs/libc/machine/x86/arch_elf.c                   |  9 ++-
 libs/libc/machine/xtensa/arch_elf.c                | 13 ++--
 36 files changed, 136 insertions(+), 147 deletions(-)

diff --git a/arch/arm/src/stm32h7/stm32_fdcan_sock.c b/arch/arm/src/stm32h7/stm32_fdcan_sock.c
index 269daaf370..a86f71dff2 100644
--- a/arch/arm/src/stm32h7/stm32_fdcan_sock.c
+++ b/arch/arm/src/stm32h7/stm32_fdcan_sock.c
@@ -406,14 +406,14 @@ static bool g_apb1h_init = false;
 
 /* Common TX logic */
 
-static bool fdcan_txringfull(FAR struct fdcan_driver_s *priv);
-static int  fdcan_transmit(FAR struct fdcan_driver_s *priv);
+static bool fdcan_txringfull(struct fdcan_driver_s *priv);
+static int  fdcan_transmit(struct fdcan_driver_s *priv);
 static int  fdcan_txpoll(struct net_driver_s *dev);
 
 /* Helper functions */
 
 #ifdef CONFIG_STM32H7_FDCAN_REGDEBUG
-static void fdcan_dumpregs(FAR struct fdcan_driver_s *priv);
+static void fdcan_dumpregs(struct fdcan_driver_s *priv);
 #endif
 
 int32_t fdcan_bittiming(struct fdcan_bitseg *timing);
@@ -431,20 +431,20 @@ static void fdcan_disable_interrupts(struct fdcan_driver_s *priv);
 
 /* Interrupt handling */
 
-static void fdcan_receive(FAR struct fdcan_driver_s *priv);
-static void fdcan_receive_work(FAR void *arg);
-static void fdcan_txdone(FAR struct fdcan_driver_s *priv);
-static void fdcan_txdone_work(FAR void *arg);
+static void fdcan_receive(struct fdcan_driver_s *priv);
+static void fdcan_receive_work(void *arg);
+static void fdcan_txdone(struct fdcan_driver_s *priv);
+static void fdcan_txdone_work(void *arg);
 
-static int  fdcan_interrupt(int irq, FAR void *context,
-                            FAR void *arg);
+static int  fdcan_interrupt(int irq, void *context,
+                            void *arg);
 
-static void fdcan_check_errors(FAR struct fdcan_driver_s *priv);
+static void fdcan_check_errors(struct fdcan_driver_s *priv);
 
 /* Watchdog timer expirations */
 
 #ifdef TX_TIMEOUT_WQ
-static void fdcan_txtimeout_work(FAR void *arg);
+static void fdcan_txtimeout_work(void *arg);
 static void fdcan_txtimeout_expiry(wdparm_t arg);
 #endif
 
@@ -453,7 +453,7 @@ static void fdcan_txtimeout_expiry(wdparm_t arg);
 static int fdcan_ifup(struct net_driver_s *dev);
 static int fdcan_ifdown(struct net_driver_s *dev);
 
-static void fdcan_txavail_work(FAR void *arg);
+static void fdcan_txavail_work(void *arg);
 static int  fdcan_txavail(struct net_driver_s *dev);
 
 #ifdef CONFIG_NETDEV_IOCTL
@@ -477,7 +477,7 @@ static void fdcan_reset(struct fdcan_driver_s *priv);
  ****************************************************************************/
 
 #ifdef CONFIG_STM32H7_FDCAN_REGDEBUG
-static void fdcan_dumpregs(FAR struct fdcan_driver_s *priv)
+static void fdcan_dumpregs(struct fdcan_driver_s *priv)
 {
   printf("-------------- FDCAN Reg Dump ----------------\n");
   printf("CAN%d Base: 0x%lx\n", priv->iface_idx, priv->base);
@@ -679,7 +679,7 @@ int32_t fdcan_bittiming(struct fdcan_bitseg *timing)
  *
  ****************************************************************************/
 
-static bool fdcan_txringfull(FAR struct fdcan_driver_s *priv)
+static bool fdcan_txringfull(struct fdcan_driver_s *priv)
 {
   /* TODO: Decide if this needs to be checked every time, or just during init
    * Check that we even _have_ a Tx FIFO allocated
@@ -723,7 +723,7 @@ static bool fdcan_txringfull(FAR struct fdcan_driver_s *priv)
  *
  ****************************************************************************/
 
-static int fdcan_transmit(FAR struct fdcan_driver_s *priv)
+static int fdcan_transmit(struct fdcan_driver_s *priv)
 {
   irqstate_t flags = enter_critical_section();
 
@@ -925,8 +925,8 @@ static int fdcan_transmit(FAR struct fdcan_driver_s *priv)
 
 static int fdcan_txpoll(struct net_driver_s *dev)
 {
-  FAR struct fdcan_driver_s *priv =
-    (FAR struct fdcan_driver_s *)dev->d_private;
+  struct fdcan_driver_s *priv =
+    (struct fdcan_driver_s *)dev->d_private;
 
   /* If the polling resulted in data that should be sent out on the network,
    * the field d_len is set to a value > 0.
@@ -970,7 +970,7 @@ static int fdcan_txpoll(struct net_driver_s *dev)
  *
  ****************************************************************************/
 
-static void fdcan_receive(FAR struct fdcan_driver_s *priv)
+static void fdcan_receive(struct fdcan_driver_s *priv)
 {
   /* Check the interrupt value to determine which FIFO to read */
 
@@ -1025,11 +1025,11 @@ static void fdcan_receive(FAR struct fdcan_driver_s *priv)
  *
  ****************************************************************************/
 
-static void fdcan_receive_work(FAR void *arg)
+static void fdcan_receive_work(void *arg)
 {
   irqstate_t flags = enter_critical_section();
 
-  FAR struct fdcan_driver_s *priv = (FAR struct fdcan_driver_s *)arg;
+  struct fdcan_driver_s *priv = (struct fdcan_driver_s *)arg;
 
   /* Check which FIFO triggered this work */
 
@@ -1234,7 +1234,7 @@ static void fdcan_receive_work(FAR void *arg)
  *
  ****************************************************************************/
 
-static void fdcan_txdone(FAR struct fdcan_driver_s *priv)
+static void fdcan_txdone(struct fdcan_driver_s *priv)
 {
   /* Read and reset the interrupt flag */
 
@@ -1272,11 +1272,11 @@ static void fdcan_txdone(FAR struct fdcan_driver_s *priv)
  *
  ****************************************************************************/
 
-static void fdcan_txdone_work(FAR void *arg)
+static void fdcan_txdone_work(void *arg)
 {
   irqstate_t flags = enter_critical_section();
 
-  FAR struct fdcan_driver_s *priv = (FAR struct fdcan_driver_s *)arg;
+  struct fdcan_driver_s *priv = (struct fdcan_driver_s *)arg;
 
   /* Update counters for successful transmissions */
 
@@ -1340,8 +1340,8 @@ static void fdcan_txdone_work(FAR void *arg)
  *
  ****************************************************************************/
 
-static int fdcan_interrupt(int irq, FAR void *context,
-                           FAR void *arg)
+static int fdcan_interrupt(int irq, void *context,
+                           void *arg)
 {
   switch (irq)
     {
@@ -1399,7 +1399,7 @@ static int fdcan_interrupt(int irq, FAR void *context,
  *
  ****************************************************************************/
 
-static void fdcan_check_errors(FAR struct fdcan_driver_s *priv)
+static void fdcan_check_errors(struct fdcan_driver_s *priv)
 {
   /* Read CAN Error Logging counter (This also resets the error counter) */
 
@@ -1460,9 +1460,9 @@ static void fdcan_check_errors(FAR struct fdcan_driver_s *priv)
  *
  ****************************************************************************/
 
-static void fdcan_txtimeout_work(FAR void *arg)
+static void fdcan_txtimeout_work(void *arg)
 {
-  FAR struct fdcan_driver_s *priv = (FAR struct fdcan_driver_s *)arg;
+  struct fdcan_driver_s *priv = (struct fdcan_driver_s *)arg;
 
   struct timespec ts;
   struct timeval *now = (struct timeval *)&ts;
@@ -1503,7 +1503,7 @@ static void fdcan_txtimeout_work(FAR void *arg)
 
 static void fdcan_txtimeout_expiry(wdparm_t arg)
 {
-  FAR struct fdcan_driver_s *priv = (FAR struct fdcan_driver_s *)arg;
+  struct fdcan_driver_s *priv = (struct fdcan_driver_s *)arg;
 
   /* Schedule to perform the TX timeout processing on the worker thread */
 
@@ -1725,8 +1725,8 @@ static void fdcan_disable_interrupts(struct fdcan_driver_s *priv)
 
 static int fdcan_ifup(struct net_driver_s *dev)
 {
-  FAR struct fdcan_driver_s *priv =
-    (FAR struct fdcan_driver_s *)dev->d_private;
+  struct fdcan_driver_s *priv =
+    (struct fdcan_driver_s *)dev->d_private;
 
   /* Wake up the device and perform all initialization */
 
@@ -1774,8 +1774,8 @@ static int fdcan_ifup(struct net_driver_s *dev)
 
 static int fdcan_ifdown(struct net_driver_s *dev)
 {
-  FAR struct fdcan_driver_s *priv =
-    (FAR struct fdcan_driver_s *)dev->d_private;
+  struct fdcan_driver_s *priv =
+    (struct fdcan_driver_s *)dev->d_private;
 
   fdcan_reset(priv);
 
@@ -1801,9 +1801,9 @@ static int fdcan_ifdown(struct net_driver_s *dev)
  *
  ****************************************************************************/
 
-static void fdcan_txavail_work(FAR void *arg)
+static void fdcan_txavail_work(void *arg)
 {
-  FAR struct fdcan_driver_s *priv = (FAR struct fdcan_driver_s *)arg;
+  struct fdcan_driver_s *priv = (struct fdcan_driver_s *)arg;
 
   /* Ignore the notification if the interface is not yet up */
 
@@ -1848,8 +1848,8 @@ static void fdcan_txavail_work(FAR void *arg)
 
 static int fdcan_txavail(struct net_driver_s *dev)
 {
-  FAR struct fdcan_driver_s *priv =
-    (FAR struct fdcan_driver_s *)dev->d_private;
+  struct fdcan_driver_s *priv =
+    (struct fdcan_driver_s *)dev->d_private;
 
   /* Is our single work structure available?  It may not be if there are
    * pending interrupt actions and we will have to ignore the Tx
@@ -1888,7 +1888,7 @@ static int fdcan_txavail(struct net_driver_s *dev)
 static int fdcan_netdev_ioctl(struct net_driver_s *dev, int cmd,
                        unsigned long arg)
 {
-  FAR struct fdcan_driver_s *priv = dev->d_private;
+  struct fdcan_driver_s *priv = dev->d_private;
 
   int ret;
 
@@ -1936,7 +1936,7 @@ static int fdcan_netdev_ioctl(struct net_driver_s *dev, int cmd,
         {
           /* TODO: Add hardware-level filter... */
 
-          stm32_addextfilter(priv, (FAR struct canioc_extfilter_s *)arg);
+          stm32_addextfilter(priv, (struct canioc_extfilter_s *)arg);
         }
         break;
 
@@ -1944,7 +1944,7 @@ static int fdcan_netdev_ioctl(struct net_driver_s *dev, int cmd,
         {
           /* TODO: Delete hardware-level filter... */
 
-          stm32_delextfilter(priv, (FAR struct canioc_extfilter_s *)arg);
+          stm32_delextfilter(priv, (struct canioc_extfilter_s *)arg);
         }
         break;
 
@@ -1952,7 +1952,7 @@ static int fdcan_netdev_ioctl(struct net_driver_s *dev, int cmd,
         {
           /* TODO: Add hardware-level filter... */
 
-          stm32_addstdfilter(priv, (FAR struct canioc_stdfilter_s *)arg);
+          stm32_addstdfilter(priv, (struct canioc_stdfilter_s *)arg);
         }
         break;
 
@@ -1960,7 +1960,7 @@ static int fdcan_netdev_ioctl(struct net_driver_s *dev, int cmd,
         {
           /* TODO: Delete hardware-level filter... */
 
-          stm32_delstdfilter(priv, (FAR struct canioc_stdfilter_s *)arg);
+          stm32_delstdfilter(priv, (struct canioc_stdfilter_s *)arg);
         }
         break;
 #endif
diff --git a/arch/x86/src/common/up_allocateheap.c b/arch/x86/src/common/up_allocateheap.c
index f331178a6d..af267c18a9 100644
--- a/arch/x86/src/common/up_allocateheap.c
+++ b/arch/x86/src/common/up_allocateheap.c
@@ -64,9 +64,9 @@
  *
  ****************************************************************************/
 
-void up_allocate_heap(FAR void **heap_start, size_t *heap_size)
+void up_allocate_heap(void **heap_start, size_t *heap_size)
 {
   board_autoled_on(LED_HEAPALLOCATE);
-  *heap_start = (FAR void *)g_idle_topstack;
+  *heap_start = (void *)g_idle_topstack;
   *heap_size = CONFIG_RAM_END - g_idle_topstack;
 }
diff --git a/arch/x86/src/common/up_assert.c b/arch/x86/src/common/up_assert.c
index b8d545d0c1..f287d37d05 100644
--- a/arch/x86/src/common/up_assert.c
+++ b/arch/x86/src/common/up_assert.c
@@ -95,7 +95,7 @@ static void x86_stackdump(uint32_t sp, uint32_t stack_top)
  ****************************************************************************/
 
 #ifdef CONFIG_ARCH_USBDUMP
-static int usbtrace_syslog(FAR const char *fmt, ...)
+static int usbtrace_syslog(const char *fmt, ...)
 {
   va_list ap;
 
@@ -107,7 +107,7 @@ static int usbtrace_syslog(FAR const char *fmt, ...)
   return OK;
 }
 
-static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
+static int assert_tracecallback(struct usbtrace_s *trace, void *arg)
 {
   usbtrace_trprintf(usbtrace_syslog, trace->event, trace->value);
   return 0;
@@ -121,7 +121,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
 #ifdef CONFIG_ARCH_STACKDUMP
 static void up_dumpstate(void)
 {
-  FAR struct tcb_s *rtcb = running_task();
+  struct tcb_s *rtcb = running_task();
   uint32_t sp = up_getsp();
   uint32_t ustackbase;
   uint32_t ustacksize;
diff --git a/arch/x86/src/common/up_exit.c b/arch/x86/src/common/up_exit.c
index 46864f2d5b..646a186a62 100644
--- a/arch/x86/src/common/up_exit.c
+++ b/arch/x86/src/common/up_exit.c
@@ -61,9 +61,9 @@
  ****************************************************************************/
 
 #ifdef CONFIG_DUMP_ON_EXIT
-static void _up_dumponexit(FAR struct tcb_s *tcb, FAR void *arg)
+static void _up_dumponexit(struct tcb_s *tcb, void *arg)
 {
-  FAR struct filelist *filelist;
+  struct filelist *filelist;
   int i;
   int j;
 
diff --git a/arch/x86/src/i486/up_createstack.c b/arch/x86/src/i486/up_createstack.c
index 40d9dd4bc0..c638ba83ae 100644
--- a/arch/x86/src/i486/up_createstack.c
+++ b/arch/x86/src/i486/up_createstack.c
@@ -88,7 +88,7 @@
  *
  ****************************************************************************/
 
-int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
+int up_create_stack(struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
 {
 #ifdef CONFIG_TLS_ALIGNED
   /* The allocated stack size must not exceed the maximum possible for the
diff --git a/arch/x86/src/i486/up_releasestack.c b/arch/x86/src/i486/up_releasestack.c
index 9122ae6d6a..798638610e 100644
--- a/arch/x86/src/i486/up_releasestack.c
+++ b/arch/x86/src/i486/up_releasestack.c
@@ -75,7 +75,7 @@
  *
  ****************************************************************************/
 
-void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype)
+void up_release_stack(struct tcb_s *dtcb, uint8_t ttype)
 {
   /* Is there a stack allocated? */
 
diff --git a/arch/x86/src/i486/up_stackframe.c b/arch/x86/src/i486/up_stackframe.c
index b11d29e075..a3893e2c8e 100644
--- a/arch/x86/src/i486/up_stackframe.c
+++ b/arch/x86/src/i486/up_stackframe.c
@@ -69,9 +69,9 @@
  *
  ****************************************************************************/
 
-FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
+void *up_stack_frame(struct tcb_s *tcb, size_t frame_size)
 {
-  FAR void *ret;
+  void *ret;
 
   /* Align the frame_size */
 
@@ -89,7 +89,7 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size)
 
   /* Save the adjusted stack values in the struct tcb_s */
 
-  tcb->stack_base_ptr  = (FAR uint8_t *)tcb->stack_base_ptr + frame_size;
+  tcb->stack_base_ptr  = (uint8_t *)tcb->stack_base_ptr + frame_size;
   tcb->adj_stack_size -= frame_size;
 
   /* And return the pointer to the allocated region */
diff --git a/arch/x86/src/qemu/qemu.h b/arch/x86/src/qemu/qemu.h
index 1e60748287..e316204dce 100644
--- a/arch/x86/src/qemu/qemu.h
+++ b/arch/x86/src/qemu/qemu.h
@@ -197,7 +197,7 @@ int i486_dumpgpio(uint16_t pinset, const char *msg);
  *
  ****************************************************************************/
 
-FAR struct spi_dev_s *i486_spibus_initialize(int port);
+struct spi_dev_s *i486_spibus_initialize(int port);
 
 /****************************************************************************
  * Name:  i486_spi/ssp0/ssp1select, i486_spi/ssp0/ssp1status, and
@@ -230,11 +230,11 @@ FAR struct spi_dev_s *i486_spibus_initialize(int port);
  ****************************************************************************/
 
 #ifdef CONFIG_I486_SPI
-void  i486_spiselect(FAR struct spi_dev_s *dev,
+void  i486_spiselect(struct spi_dev_s *dev,
                      uint32_t devid, bool selected);
-uint8_t i486_spistatus(FAR struct spi_dev_s *dev, uint32_t devid);
+uint8_t i486_spistatus(struct spi_dev_s *dev, uint32_t devid);
 #ifdef CONFIG_SPI_CMDDATA
-int i486_spicmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
+int i486_spicmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd);
 #endif
 #endif
 
@@ -255,10 +255,10 @@ int i486_spicmddata(FAR struct spi_dev_s *dev, uint32_t devid, bool cmd);
  ****************************************************************************/
 
 #ifdef CONFIG_I486_SPI
-void spi_flush(FAR struct spi_dev_s *dev);
+void spi_flush(struct spi_dev_s *dev);
 #endif
 #if defined(CONFIG_I486_SSP0) || defined(CONFIG_I486_SSP1)
-void ssp_flush(FAR struct spi_dev_s *dev);
+void ssp_flush(struct spi_dev_s *dev);
 #endif
 
 /****************************************************************************
diff --git a/arch/x86/src/qemu/qemu_keypad.c b/arch/x86/src/qemu/qemu_keypad.c
index 8640342eb4..fa5e15b835 100644
--- a/arch/x86/src/qemu/qemu_keypad.c
+++ b/arch/x86/src/qemu/qemu_keypad.c
@@ -203,7 +203,7 @@ typedef enum
  * Private Function Prototypes
  ****************************************************************************/
 
-static ssize_t keypad_read(struct file *filep, FAR char *buf, size_t buflen);
+static ssize_t keypad_read(struct file *filep, char *buf, size_t buflen);
 
 /****************************************************************************
  * Private Data
@@ -267,7 +267,7 @@ static const struct file_operations g_keypadops =
  * Private Functions
  ****************************************************************************/
 
-static ssize_t keypad_read(struct file *filep, FAR char *buf, size_t buflen)
+static ssize_t keypad_read(struct file *filep, char *buf, size_t buflen)
 {
   uint_fast8_t keycode = 0;
   uint_fast8_t scancode = 0;
diff --git a/arch/x86/src/qemu/qemu_vga.c b/arch/x86/src/qemu/qemu_vga.c
index 4b2c8d8ae2..14e749af3e 100644
--- a/arch/x86/src/qemu/qemu_vga.c
+++ b/arch/x86/src/qemu/qemu_vga.c
@@ -97,22 +97,22 @@
 
 static int init_graph_vga(int width, int height, int chain4);
 static int vga_putrun(fb_coord_t row,
-                      fb_coord_t col, FAR const uint8_t *buffer,
+                      fb_coord_t col, const uint8_t *buffer,
                       size_t npixels);
-static int vga_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
+static int vga_getrun(fb_coord_t row, fb_coord_t col, uint8_t *buffer,
                       size_t npixels);
-static int vga_getvideoinfo(FAR struct lcd_dev_s *dev,
-                            FAR struct fb_videoinfo_s *vinfo);
-static int vga_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno,
-                            FAR struct lcd_planeinfo_s *pinfo);
+static int vga_getvideoinfo(struct lcd_dev_s *dev,
+                            struct fb_videoinfo_s *vinfo);
+static int vga_getplaneinfo(struct lcd_dev_s *dev, unsigned int planeno,
+                            struct lcd_planeinfo_s *pinfo);
 static int vga_getpower(struct lcd_dev_s *dev);
 static int vga_setpower(struct lcd_dev_s *dev, int power);
 static int vga_getcontrast(struct lcd_dev_s *dev);
 static int vga_setcontrast(struct lcd_dev_s *dev, unsigned int contrast);
-static ssize_t vga_read(struct file *filep, FAR char *buf, size_t buflen);
-static ssize_t vga_write(struct file *filep, FAR const char *buf,
+static ssize_t vga_read(struct file *filep, char *buf, size_t buflen);
+static ssize_t vga_write(struct file *filep, const char *buf,
                          size_t buflen);
-static off_t vga_seek(FAR struct file *filp, off_t offset, int whence);
+static off_t vga_seek(struct file *filp, off_t offset, int whence);
 
 /****************************************************************************
  * Private Data
@@ -415,22 +415,22 @@ static int init_graph_vga(int width, int height, int chain4)
 }
 
 static int vga_putrun(fb_coord_t row,
-                      fb_coord_t col, FAR const uint8_t *buffer,
+                      fb_coord_t col, const uint8_t *buffer,
                       size_t npixels)
 {
   memcpy(&g_pscreen[row*VGA_XRES + col], buffer, npixels);
   return OK;
 }
 
-static int vga_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
+static int vga_getrun(fb_coord_t row, fb_coord_t col, uint8_t *buffer,
                       size_t npixels)
 {
   memcpy(buffer, &g_pscreen[row*VGA_XRES + col], npixels);
   return OK;
 }
 
-static int vga_getvideoinfo(FAR struct lcd_dev_s *dev,
-                            FAR struct fb_videoinfo_s *vinfo)
+static int vga_getvideoinfo(struct lcd_dev_s *dev,
+                            struct fb_videoinfo_s *vinfo)
 {
   vinfo->fmt     = VGA_COLORFMT;
   vinfo->xres    = VGA_XRES;        /* Horizontal resolution in pixel columns */
@@ -439,8 +439,8 @@ static int vga_getvideoinfo(FAR struct lcd_dev_s *dev,
   return OK;
 }
 
-static int vga_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno,
-                            FAR struct lcd_planeinfo_s *pinfo)
+static int vga_getplaneinfo(struct lcd_dev_s *dev, unsigned int planeno,
+                            struct lcd_planeinfo_s *pinfo)
 {
   pinfo->putrun  = vga_putrun;      /* Put a run into LCD memory */
   pinfo->getrun  = vga_getrun;      /* Get a run from LCD memory */
@@ -470,7 +470,7 @@ static int vga_setcontrast(struct lcd_dev_s *dev, unsigned int contrast)
   return -ENOSYS;
 }
 
-static ssize_t vga_read(struct file *filep, FAR char *buf, size_t buflen)
+static ssize_t vga_read(struct file *filep, char *buf, size_t buflen)
 {
   if (buf == NULL || buflen < 1)
     {
@@ -482,7 +482,7 @@ static ssize_t vga_read(struct file *filep, FAR char *buf, size_t buflen)
   return buflen;
 }
 
-static ssize_t vga_write(struct file *filep, FAR const char *buf,
+static ssize_t vga_write(struct file *filep, const char *buf,
                          size_t buflen)
 {
   int i;
@@ -506,7 +506,7 @@ static ssize_t vga_write(struct file *filep, FAR const char *buf,
   return buflen;
 }
 
-static off_t vga_seek(FAR struct file *filp, off_t offset, int whence)
+static off_t vga_seek(struct file *filp, off_t offset, int whence)
 {
   ssize_t newpos;
 
@@ -559,7 +559,7 @@ static off_t vga_seek(FAR struct file *filp, off_t offset, int whence)
  *
  ****************************************************************************/
 
-FAR struct lcd_dev_s *qemu_vga_initialize(void)
+struct lcd_dev_s *qemu_vga_initialize(void)
 {
   int ret = init_graph_vga(VGA_XRES, VGA_YRES, 1);
   if (ret < 0)
diff --git a/arch/x86/src/qemu/qemu_vga.h b/arch/x86/src/qemu/qemu_vga.h
index bc77cde3ac..031f91bde3 100644
--- a/arch/x86/src/qemu/qemu_vga.h
+++ b/arch/x86/src/qemu/qemu_vga.h
@@ -51,7 +51,7 @@
  *
  ****************************************************************************/
 
-FAR struct lcd_dev_s *qemu_vga_initialize(void);
+struct lcd_dev_s *qemu_vga_initialize(void);
 
 void qemu_vga(void);
 
diff --git a/boards/arm/samd2l2/samd21-xplained/src/sam_ug2832hsweg04.c b/boards/arm/samd2l2/samd21-xplained/src/sam_ug2832hsweg04.c
index 13b6f20c52..94147d82d5 100644
--- a/boards/arm/samd2l2/samd21-xplained/src/sam_ug2832hsweg04.c
+++ b/boards/arm/samd2l2/samd21-xplained/src/sam_ug2832hsweg04.c
@@ -143,10 +143,10 @@
  *
  ****************************************************************************/
 
-FAR struct lcd_dev_s *board_graphics_setup(unsigned int devno)
+struct lcd_dev_s *board_graphics_setup(unsigned int devno)
 {
-  FAR struct spi_dev_s *spi;
-  FAR struct lcd_dev_s *dev;
+  struct spi_dev_s *spi;
+  struct lcd_dev_s *dev;
 
   /* Configure the OLED PORTs. This initial configuration is RESET low,
    * putting the OLED into reset state.
diff --git a/boards/arm/stm32/nucleo-g474re/src/stm32_usbdev.c b/boards/arm/stm32/nucleo-g474re/src/stm32_usbdev.c
index bbc13156e4..ca1cfcf9d1 100644
--- a/boards/arm/stm32/nucleo-g474re/src/stm32_usbdev.c
+++ b/boards/arm/stm32/nucleo-g474re/src/stm32_usbdev.c
@@ -51,7 +51,7 @@
  *
  ****************************************************************************/
 
-void stm32_usbsuspend(FAR struct usbdev_s *dev, bool resume)
+void stm32_usbsuspend(struct usbdev_s *dev, bool resume)
 {
   uinfo("resume: %d\n", resume);
 }
diff --git a/libs/libc/machine/arm/aeabi_memclr.c b/libs/libc/machine/arm/aeabi_memclr.c
index 0a36bd709c..9b195cdb41 100644
--- a/libs/libc/machine/arm/aeabi_memclr.c
+++ b/libs/libc/machine/arm/aeabi_memclr.c
@@ -28,7 +28,7 @@
  * Public Functions
  ****************************************************************************/
 
-void weak_function __aeabi_memclr(FAR void *s, size_t n)
+void weak_function __aeabi_memclr(void *s, size_t n)
 {
   memset(s, 0, n);
 }
diff --git a/libs/libc/machine/arm/aeabi_memclr4.c b/libs/libc/machine/arm/aeabi_memclr4.c
index 86eb5fce8a..029cd13abe 100644
--- a/libs/libc/machine/arm/aeabi_memclr4.c
+++ b/libs/libc/machine/arm/aeabi_memclr4.c
@@ -28,7 +28,7 @@
  * Public Functions
  ****************************************************************************/
 
-void weak_function __aeabi_memclr4(FAR void *s, size_t n)
+void weak_function __aeabi_memclr4(void *s, size_t n)
 {
   memset(s, 0, n);
 }
diff --git a/libs/libc/machine/arm/aeabi_memclr8.c b/libs/libc/machine/arm/aeabi_memclr8.c
index 9d2e4a0f47..4463903a66 100644
--- a/libs/libc/machine/arm/aeabi_memclr8.c
+++ b/libs/libc/machine/arm/aeabi_memclr8.c
@@ -28,7 +28,7 @@
  * Public Functions
  ****************************************************************************/
 
-void weak_function __aeabi_memclr8(FAR void *s, size_t n)
+void weak_function __aeabi_memclr8(void *s, size_t n)
 {
   memset(s, 0, n);
 }
diff --git a/libs/libc/machine/arm/aeabi_memcpy.c b/libs/libc/machine/arm/aeabi_memcpy.c
index dc27033d82..c74a060b38 100644
--- a/libs/libc/machine/arm/aeabi_memcpy.c
+++ b/libs/libc/machine/arm/aeabi_memcpy.c
@@ -29,7 +29,7 @@
  ****************************************************************************/
 
 void weak_function
-__aeabi_memcpy(FAR void *dest, FAR const void *src, size_t n)
+__aeabi_memcpy(void *dest, const void *src, size_t n)
 {
   memcpy(dest, src, n);
 }
diff --git a/libs/libc/machine/arm/aeabi_memcpy4.c b/libs/libc/machine/arm/aeabi_memcpy4.c
index 640f5edb9e..9b98a17222 100644
--- a/libs/libc/machine/arm/aeabi_memcpy4.c
+++ b/libs/libc/machine/arm/aeabi_memcpy4.c
@@ -29,7 +29,7 @@
  ****************************************************************************/
 
 void weak_function
-__aeabi_memcpy4(FAR void *dest, FAR const void *src, size_t n)
+__aeabi_memcpy4(void *dest, const void *src, size_t n)
 {
   memcpy(dest, src, n);
 }
diff --git a/libs/libc/machine/arm/aeabi_memcpy8.c b/libs/libc/machine/arm/aeabi_memcpy8.c
index 97d6debc1a..0146c745b4 100644
--- a/libs/libc/machine/arm/aeabi_memcpy8.c
+++ b/libs/libc/machine/arm/aeabi_memcpy8.c
@@ -29,7 +29,7 @@
  ****************************************************************************/
 
 void weak_function
-__aeabi_memcpy8(FAR void *dest, FAR const void *src, size_t n)
+__aeabi_memcpy8(void *dest, const void *src, size_t n)
 {
   memcpy(dest, src, n);
 }
diff --git a/libs/libc/machine/arm/aeabi_memmove.c b/libs/libc/machine/arm/aeabi_memmove.c
index 8ba83d1d38..b36d178c1a 100644
--- a/libs/libc/machine/arm/aeabi_memmove.c
+++ b/libs/libc/machine/arm/aeabi_memmove.c
@@ -29,7 +29,7 @@
  ****************************************************************************/
 
 void weak_function
-__aeabi_memmove(FAR void *dest, FAR const void *src, size_t n)
+__aeabi_memmove(void *dest, const void *src, size_t n)
 {
   memmove(dest, src, n);
 }
diff --git a/libs/libc/machine/arm/aeabi_memmove4.c b/libs/libc/machine/arm/aeabi_memmove4.c
index cb6e4be34c..15171d7ff6 100644
--- a/libs/libc/machine/arm/aeabi_memmove4.c
+++ b/libs/libc/machine/arm/aeabi_memmove4.c
@@ -29,7 +29,7 @@
  ****************************************************************************/
 
 void weak_function
-__aeabi_memmove4(FAR void *dest, FAR const void *src, size_t n)
+__aeabi_memmove4(void *dest, const void *src, size_t n)
 {
   memmove(dest, src, n);
 }
diff --git a/libs/libc/machine/arm/aeabi_memmove8.c b/libs/libc/machine/arm/aeabi_memmove8.c
index 5726396756..bacdaed7c0 100644
--- a/libs/libc/machine/arm/aeabi_memmove8.c
+++ b/libs/libc/machine/arm/aeabi_memmove8.c
@@ -29,7 +29,7 @@
  ****************************************************************************/
 
 void weak_function
-__aeabi_memmove8(FAR void *dest, FAR const void *src, size_t n)
+__aeabi_memmove8(void *dest, const void *src, size_t n)
 {
   memmove(dest, src, n);
 }
diff --git a/libs/libc/machine/arm/aeabi_memset.c b/libs/libc/machine/arm/aeabi_memset.c
index f60faede5c..5bb8d73012 100644
--- a/libs/libc/machine/arm/aeabi_memset.c
+++ b/libs/libc/machine/arm/aeabi_memset.c
@@ -28,7 +28,7 @@
  * Public Functions
  ****************************************************************************/
 
-void weak_function __aeabi_memset(FAR void *s, size_t n, int c)
+void weak_function __aeabi_memset(void *s, size_t n, int c)
 {
   memset(s, c, n);
 }
diff --git a/libs/libc/machine/arm/aeabi_memset4.c b/libs/libc/machine/arm/aeabi_memset4.c
index cbcd2dd459..0c51d05c9e 100644
--- a/libs/libc/machine/arm/aeabi_memset4.c
+++ b/libs/libc/machine/arm/aeabi_memset4.c
@@ -28,7 +28,7 @@
  * Public Functions
  ****************************************************************************/
 
-void weak_function __aeabi_memset4(FAR void *s, size_t n, int c)
+void weak_function __aeabi_memset4(void *s, size_t n, int c)
 {
   memset(s, c, n);
 }
diff --git a/libs/libc/machine/arm/aeabi_memset8.c b/libs/libc/machine/arm/aeabi_memset8.c
index 8d3b23eca3..d754545455 100644
--- a/libs/libc/machine/arm/aeabi_memset8.c
+++ b/libs/libc/machine/arm/aeabi_memset8.c
@@ -28,7 +28,7 @@
  * Public Functions
  ****************************************************************************/
 
-void weak_function __aeabi_memset8(FAR void *s, size_t n, int c)
+void weak_function __aeabi_memset8(void *s, size_t n, int c)
 {
   memset(s, c, n);
 }
diff --git a/libs/libc/machine/arm/arm/arch_elf.c b/libs/libc/machine/arm/arm/arch_elf.c
index e9dcf94d7d..e4fde99a25 100644
--- a/libs/libc/machine/arm/arm/arch_elf.c
+++ b/libs/libc/machine/arm/arm/arch_elf.c
@@ -63,7 +63,7 @@
  *
  ****************************************************************************/
 
-bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
+bool up_checkarch(const Elf32_Ehdr *ehdr)
 {
   /* Make sure it's an ARM executable */
 
@@ -131,8 +131,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
  *
  ****************************************************************************/
 
-int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
-                uintptr_t addr)
+int up_relocate(const Elf32_Rel *rel, const Elf32_Sym *sym, uintptr_t addr)
 {
   int32_t offset;
   unsigned int relotype;
@@ -265,7 +264,7 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
   return OK;
 }
 
-int up_relocateadd(FAR const Elf32_Rela *rel, FAR const Elf32_Sym *sym,
+int up_relocateadd(const Elf32_Rela *rel, const Elf32_Sym *sym,
                    uintptr_t addr)
 {
   berr("ERROR: RELA relocation not supported\n");
diff --git a/libs/libc/machine/arm/armv6-m/arch_elf.c b/libs/libc/machine/arm/armv6-m/arch_elf.c
index 7a43f903c6..3bdad9d599 100644
--- a/libs/libc/machine/arm/armv6-m/arch_elf.c
+++ b/libs/libc/machine/arm/armv6-m/arch_elf.c
@@ -63,7 +63,7 @@
  *
  ****************************************************************************/
 
-bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
+bool up_checkarch(const Elf32_Ehdr *ehdr)
 {
   /* Make sure it's an ARM executable */
 
@@ -122,8 +122,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
  *
  ****************************************************************************/
 
-int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
-                uintptr_t addr)
+int up_relocate(const Elf32_Rel *rel, const Elf32_Sym *sym, uintptr_t addr)
 {
   int32_t offset;
   uint32_t upper_insn;
@@ -460,7 +459,7 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
   return OK;
 }
 
-int up_relocateadd(FAR const Elf32_Rela *rel, FAR const Elf32_Sym *sym,
+int up_relocateadd(const Elf32_Rela *rel, const Elf32_Sym *sym,
                    uintptr_t addr)
 {
   berr("ERROR: RELA relocation not supported\n");
diff --git a/libs/libc/machine/arm/armv7-a/arch_elf.c b/libs/libc/machine/arm/armv7-a/arch_elf.c
index 3e724822a7..a8f7ac3367 100644
--- a/libs/libc/machine/arm/armv7-a/arch_elf.c
+++ b/libs/libc/machine/arm/armv7-a/arch_elf.c
@@ -52,7 +52,7 @@
  *
  ****************************************************************************/
 
-bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
+bool up_checkarch(const Elf32_Ehdr *ehdr)
 {
   /* Make sure it's an ARM executable */
 
@@ -124,8 +124,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
  *
  ****************************************************************************/
 
-int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
-                uintptr_t addr)
+int up_relocate(const Elf32_Rel *rel, const Elf32_Sym *sym, uintptr_t addr)
 {
   int32_t offset;
   unsigned int relotype;
@@ -475,7 +474,7 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
   return OK;
 }
 
-int up_relocateadd(FAR const Elf32_Rela *rel, FAR const Elf32_Sym *sym,
+int up_relocateadd(const Elf32_Rela *rel, const Elf32_Sym *sym,
                    uintptr_t addr)
 {
   berr("ERROR: RELA relocation not supported\n");
diff --git a/libs/libc/machine/arm/armv7-m/arch_elf.c b/libs/libc/machine/arm/armv7-m/arch_elf.c
index 6c4639c8ae..2ca96527e6 100644
--- a/libs/libc/machine/arm/armv7-m/arch_elf.c
+++ b/libs/libc/machine/arm/armv7-m/arch_elf.c
@@ -52,7 +52,7 @@
  *
  ****************************************************************************/
 
-bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
+bool up_checkarch(const Elf32_Ehdr *ehdr)
 {
   /* Make sure it's an ARM executable */
 
@@ -111,8 +111,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
  *
  ****************************************************************************/
 
-int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
-                uintptr_t addr)
+int up_relocate(const Elf32_Rel *rel, const Elf32_Sym *sym, uintptr_t addr)
 {
   int32_t offset;
   uint32_t upper_insn;
@@ -503,7 +502,7 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
   return OK;
 }
 
-int up_relocateadd(FAR const Elf32_Rela *rel, FAR const Elf32_Sym *sym,
+int up_relocateadd(const Elf32_Rela *rel, const Elf32_Sym *sym,
                    uintptr_t addr)
 {
   berr("ERROR: RELA relocation not supported\n");
diff --git a/libs/libc/machine/arm/armv7-r/arch_elf.c b/libs/libc/machine/arm/armv7-r/arch_elf.c
index 505d2d8ec3..fa8d642f66 100644
--- a/libs/libc/machine/arm/armv7-r/arch_elf.c
+++ b/libs/libc/machine/arm/armv7-r/arch_elf.c
@@ -63,7 +63,7 @@
  *
  ****************************************************************************/
 
-bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
+bool up_checkarch(const Elf32_Ehdr *ehdr)
 {
   /* Make sure it's an ARM executable */
 
@@ -131,8 +131,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
  *
  ****************************************************************************/
 
-int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
-                uintptr_t addr)
+int up_relocate(const Elf32_Rel *rel, const Elf32_Sym *sym, uintptr_t addr)
 {
   int32_t offset;
   unsigned int relotype;
@@ -258,7 +257,7 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
   return OK;
 }
 
-int up_relocateadd(FAR const Elf32_Rela *rel, FAR const Elf32_Sym *sym,
+int up_relocateadd(const Elf32_Rela *rel, const Elf32_Sym *sym,
                    uintptr_t addr)
 {
   berr("ERROR: RELA relocation not supported\n");
diff --git a/libs/libc/machine/arm/armv8-m/arch_elf.c b/libs/libc/machine/arm/armv8-m/arch_elf.c
index aa4ceae685..614efdb792 100644
--- a/libs/libc/machine/arm/armv8-m/arch_elf.c
+++ b/libs/libc/machine/arm/armv8-m/arch_elf.c
@@ -52,7 +52,7 @@
  *
  ****************************************************************************/
 
-bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
+bool up_checkarch(const Elf32_Ehdr *ehdr)
 {
   /* Make sure it's an ARM executable */
 
@@ -111,8 +111,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
  *
  ****************************************************************************/
 
-int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
-                uintptr_t addr)
+int up_relocate(const Elf32_Rel *rel, const Elf32_Sym *sym, uintptr_t addr)
 {
   int32_t offset;
   uint32_t upper_insn;
@@ -503,7 +502,7 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
   return OK;
 }
 
-int up_relocateadd(FAR const Elf32_Rela *rel, FAR const Elf32_Sym *sym,
+int up_relocateadd(const Elf32_Rela *rel, const Elf32_Sym *sym,
                    uintptr_t addr)
 {
   berr("ERROR: RELA relocation not supported\n");
diff --git a/libs/libc/machine/risc-v/common/arch_elf.c b/libs/libc/machine/risc-v/common/arch_elf.c
index 245da79e00..eb693862da 100644
--- a/libs/libc/machine/risc-v/common/arch_elf.c
+++ b/libs/libc/machine/risc-v/common/arch_elf.c
@@ -202,7 +202,7 @@ static void _calc_imm(long offset, long *imm_hi, long *imm_lo)
  *
  ****************************************************************************/
 
-bool up_checkarch(FAR const Elf_Ehdr *ehdr)
+bool up_checkarch(const Elf_Ehdr *ehdr)
 {
   /* Make sure it's an RISCV executable */
 
@@ -270,14 +270,13 @@ bool up_checkarch(FAR const Elf_Ehdr *ehdr)
  *
  ****************************************************************************/
 
-int up_relocate(FAR const Elf_Rel *rel, FAR const Elf_Sym *sym,
-                uintptr_t addr)
+int up_relocate(const Elf_Rel *rel, const Elf_Sym *sym, uintptr_t addr)
 {
   berr("Not implemented\n");
   return -ENOSYS;
 }
 
-int up_relocateadd(FAR const Elf_Rela *rel, FAR const Elf_Sym *sym,
+int up_relocateadd(const Elf_Rela *rel, const Elf_Sym *sym,
                    uintptr_t addr)
 {
   long offset;
diff --git a/libs/libc/machine/sim/arch_elf.c b/libs/libc/machine/sim/arch_elf.c
index d1cf3eb47c..304d742dfb 100644
--- a/libs/libc/machine/sim/arch_elf.c
+++ b/libs/libc/machine/sim/arch_elf.c
@@ -60,7 +60,7 @@
  *
  ****************************************************************************/
 
-bool up_checkarch(FAR const Elf32_Ehdr *hdr)
+bool up_checkarch(const Elf32_Ehdr *hdr)
 {
   return hdr->e_machine == EM_386 || hdr->e_machine == EM_486;
 }
@@ -87,10 +87,9 @@ bool up_checkarch(FAR const Elf32_Ehdr *hdr)
  *
  ****************************************************************************/
 
-int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
-                uintptr_t addr)
+int up_relocate(const Elf32_Rel *rel, const Elf32_Sym *sym, uintptr_t addr)
 {
-  FAR uint32_t *ptr = (FAR uint32_t *)addr;
+  uint32_t *ptr = (uint32_t *)addr;
 
   /* All relocations depend upon having valid symbol information. */
 
@@ -119,7 +118,7 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
   return OK;
 }
 
-int up_relocateadd(FAR const Elf32_Rela *rel, FAR const Elf32_Sym *sym,
+int up_relocateadd(const Elf32_Rela *rel, const Elf32_Sym *sym,
                    uintptr_t addr)
 {
   berr("ERROR: Not supported\n");
diff --git a/libs/libc/machine/sim/arch_elf64.c b/libs/libc/machine/sim/arch_elf64.c
index 561abae615..eff2723ff3 100644
--- a/libs/libc/machine/sim/arch_elf64.c
+++ b/libs/libc/machine/sim/arch_elf64.c
@@ -81,7 +81,7 @@
  *
  ****************************************************************************/
 
-bool up_checkarch(FAR const Elf64_Ehdr *ehdr)
+bool up_checkarch(const Elf64_Ehdr *ehdr)
 {
   /* Make sure it's an x86_64 executable */
 
@@ -140,14 +140,13 @@ bool up_checkarch(FAR const Elf64_Ehdr *ehdr)
  *
  ****************************************************************************/
 
-int up_relocate(FAR const Elf64_Rel *rel, FAR const Elf64_Sym *sym,
-                uintptr_t addr)
+int up_relocate(const Elf64_Rel *rel, const Elf64_Sym *sym, uintptr_t addr)
 {
   berr("Not implemented\n");
   return -ENOSYS;
 }
 
-int up_relocateadd(FAR const Elf64_Rela *rel, FAR const Elf64_Sym *sym,
+int up_relocateadd(const Elf64_Rela *rel, const Elf64_Sym *sym,
                    uintptr_t addr)
 {
   unsigned int relotype;
diff --git a/libs/libc/machine/x86/arch_elf.c b/libs/libc/machine/x86/arch_elf.c
index 87893d831f..e155f2dcf1 100644
--- a/libs/libc/machine/x86/arch_elf.c
+++ b/libs/libc/machine/x86/arch_elf.c
@@ -68,7 +68,7 @@
  *
  ****************************************************************************/
 
-bool up_checkarch(FAR const Elf32_Ehdr *hdr)
+bool up_checkarch(const Elf32_Ehdr *hdr)
 {
   return hdr->e_machine == EM_386 || hdr->e_machine == EM_486;
 }
@@ -95,10 +95,9 @@ bool up_checkarch(FAR const Elf32_Ehdr *hdr)
  *
  ****************************************************************************/
 
-int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
-                uintptr_t addr)
+int up_relocate(const Elf32_Rel *rel, const Elf32_Sym *sym, uintptr_t addr)
 {
-  FAR uint32_t *ptr = (FAR uint32_t *)addr;
+  uint32_t *ptr = (uint32_t *)addr;
 
   /* All relocations depend upon having valid symbol information. */
 
@@ -126,7 +125,7 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
   return OK;
 }
 
-int up_relocateadd(FAR const Elf32_Rela *rel, FAR const Elf32_Sym *sym,
+int up_relocateadd(const Elf32_Rela *rel, const Elf32_Sym *sym,
                    uintptr_t addr)
 {
   bwarn("WARNING: Not supported\n");
diff --git a/libs/libc/machine/xtensa/arch_elf.c b/libs/libc/machine/xtensa/arch_elf.c
index 504b238c79..56eded4fb8 100644
--- a/libs/libc/machine/xtensa/arch_elf.c
+++ b/libs/libc/machine/xtensa/arch_elf.c
@@ -44,7 +44,7 @@
  * Private Functions
  ****************************************************************************/
 
-static bool is_l32r(FAR const unsigned char *p)
+static bool is_l32r(const unsigned char *p)
 {
   return (p[0] & 0xf) == 1;
 }
@@ -69,7 +69,7 @@ static bool is_l32r(FAR const unsigned char *p)
  *
  ****************************************************************************/
 
-bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
+bool up_checkarch(const Elf32_Ehdr *ehdr)
 {
   /* Make sure it's an Xtensa executable */
 
@@ -127,8 +127,7 @@ bool up_checkarch(FAR const Elf32_Ehdr *ehdr)
  *
  ****************************************************************************/
 
-int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
-                uintptr_t addr)
+int up_relocate(const Elf32_Rel *rel, const Elf32_Sym *sym, uintptr_t addr)
 {
   unsigned int relotype;
 
@@ -160,7 +159,7 @@ int up_relocate(FAR const Elf32_Rel *rel, FAR const Elf32_Sym *sym,
   return OK;
 }
 
-int up_relocateadd(FAR const Elf32_Rela *rel, FAR const Elf32_Sym *sym,
+int up_relocateadd(const Elf32_Rela *rel, const Elf32_Sym *sym,
                    uintptr_t addr)
 {
   unsigned int relotype;
@@ -192,7 +191,7 @@ int up_relocateadd(FAR const Elf32_Rela *rel, FAR const Elf32_Sym *sym,
       break;
 
     case R_XTENSA_32:
-      (*(FAR uint32_t *)addr) += value;
+      (*(uint32_t *)addr) += value;
       break;
 
     case R_XTENSA_ASM_EXPAND:
@@ -201,7 +200,7 @@ int up_relocateadd(FAR const Elf32_Rela *rel, FAR const Elf32_Sym *sym,
       break;
 
     case R_XTENSA_SLOT0_OP:
-      p = (FAR unsigned char *)addr;
+      p = (unsigned char *)addr;
       if (is_l32r(p))
         {
           /* Xtensa ISA:


[incubator-nuttx] 01/06: sched: Remove start from nxsem_tickwait[_uninterruptible]

Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 22e4f1c59aacfe18790f4bec788d15c028161421
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Tue May 10 08:33:09 2022 +0800

    sched: Remove start from nxsem_tickwait[_uninterruptible]
    
    to simplify both caller and callee
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 drivers/wireless/nrf24l01.c    |  3 +--
 fs/vfs/fs_poll.c               |  2 +-
 include/nuttx/semaphore.h      | 13 ++-----------
 sched/semaphore/sem_tickwait.c | 42 +++++++++++++++---------------------------
 4 files changed, 19 insertions(+), 41 deletions(-)

diff --git a/drivers/wireless/nrf24l01.c b/drivers/wireless/nrf24l01.c
index 046d84e1ae..824b5a49c1 100644
--- a/drivers/wireless/nrf24l01.c
+++ b/drivers/wireless/nrf24l01.c
@@ -847,8 +847,7 @@ static int dosend(FAR struct nrf24l01_dev_s *dev, FAR const uint8_t *data,
 
   /* Wait for IRQ (TX_DS or MAX_RT) - but don't hang on lost IRQ */
 
-  ret = nxsem_tickwait(&dev->sem_tx, clock_systime_ticks(),
-                       MSEC2TICK(NRF24L01_MAX_TX_IRQ_WAIT));
+  ret = nxsem_tickwait(&dev->sem_tx, MSEC2TICK(NRF24L01_MAX_TX_IRQ_WAIT));
 
   /* Re-acquire the SPI bus */
 
diff --git a/fs/vfs/fs_poll.c b/fs/vfs/fs_poll.c
index 11a4a4b44d..429addd64e 100644
--- a/fs/vfs/fs_poll.c
+++ b/fs/vfs/fs_poll.c
@@ -419,7 +419,7 @@ int nx_poll(FAR struct pollfd *fds, unsigned int nfds, int timeout)
            * will return immediately.
            */
 
-          ret = nxsem_tickwait(&sem, clock_systime_ticks(), ticks);
+          ret = nxsem_tickwait(&sem, ticks);
           if (ret < 0)
             {
               if (ret == -ETIMEDOUT)
diff --git a/include/nuttx/semaphore.h b/include/nuttx/semaphore.h
index 4f24f31761..dcea5ee863 100644
--- a/include/nuttx/semaphore.h
+++ b/include/nuttx/semaphore.h
@@ -348,10 +348,6 @@ int nxsem_clockwait(FAR sem_t *sem, clockid_t clockid,
  *
  * Input Parameters:
  *   sem     - Semaphore object
- *   start   - The system time that the delay is relative to.  If the
- *             current time is not the same as the start time, then the
- *             delay will be adjust so that the end time will be the same
- *             in any event.
  *   delay   - Ticks to wait from the start time until the semaphore is
  *             posted.  If ticks is zero, then this function is equivalent
  *             to sem_trywait().
@@ -366,7 +362,7 @@ int nxsem_clockwait(FAR sem_t *sem, clockid_t clockid,
  *
  ****************************************************************************/
 
-int nxsem_tickwait(FAR sem_t *sem, clock_t start, uint32_t delay);
+int nxsem_tickwait(FAR sem_t *sem, uint32_t delay);
 
 /****************************************************************************
  * Name: nxsem_post
@@ -608,10 +604,6 @@ int nxsem_clockwait_uninterruptible(FAR sem_t *sem, clockid_t clockid,
  *
  * Input Parameters:
  *   sem     - Semaphore object
- *   start   - The system time that the delay is relative to.  If the
- *             current time is not the same as the start time, then the
- *             delay will be adjust so that the end time will be the same
- *             in any event.
  *   delay   - Ticks to wait from the start time until the semaphore is
  *             posted.  If ticks is zero, then this function is equivalent
  *             to sem_trywait().
@@ -632,8 +624,7 @@ int nxsem_clockwait_uninterruptible(FAR sem_t *sem, clockid_t clockid,
  *
  ****************************************************************************/
 
-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);
 
 #undef EXTERN
 #ifdef __cplusplus
diff --git a/sched/semaphore/sem_tickwait.c b/sched/semaphore/sem_tickwait.c
index fe30ba562b..2359b415d8 100644
--- a/sched/semaphore/sem_tickwait.c
+++ b/sched/semaphore/sem_tickwait.c
@@ -52,10 +52,6 @@
  *
  * Input Parameters:
  *   sem     - Semaphore object
- *   start   - The system time that the delay is relative to.  If the
- *             current time is not the same as the start time, then the
- *             delay will be adjust so that the end time will be the same
- *             in any event.
  *   delay   - Ticks to wait from the start time until the semaphore is
  *             posted.  If ticks is zero, then this function is equivalent
  *             to nxsem_trywait().
@@ -68,11 +64,10 @@
  *
  ****************************************************************************/
 
-int nxsem_tickwait(FAR sem_t *sem, clock_t start, uint32_t delay)
+int nxsem_tickwait(FAR sem_t *sem, uint32_t delay)
 {
   FAR struct tcb_s *rtcb = this_task();
   irqstate_t flags;
-  clock_t elapsed;
   int ret;
 
   DEBUGASSERT(sem != NULL && up_interrupt_context() == false);
@@ -108,17 +103,6 @@ int nxsem_tickwait(FAR sem_t *sem, clock_t start, uint32_t delay)
       goto out;
     }
 
-  /* Adjust the delay for any time since the delay was calculated */
-
-  elapsed = clock_systime_ticks() - start;
-  if (/* elapsed >= (UINT32_MAX / 2) || */ elapsed >= delay)
-    {
-      ret = -ETIMEDOUT;
-      goto out;
-    }
-
-  delay -= elapsed;
-
   /* Start the watchdog with interrupts still disabled */
 
   wd_start(&rtcb->waitdog, delay, nxsem_timeout, getpid());
@@ -147,10 +131,6 @@ out:
  *
  * Input Parameters:
  *   sem     - Semaphore object
- *   start   - The system time that the delay is relative to.  If the
- *             current time is not the same as the start time, then the
- *             delay will be adjust so that the end time will be the same
- *             in any event.
  *   delay   - Ticks to wait from the start time until the semaphore is
  *             posted.  If ticks is zero, then this function is equivalent
  *             to sem_trywait().
@@ -165,19 +145,27 @@ out:
  *
  ****************************************************************************/
 
-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)
 {
+  clock_t end = clock_systime_ticks() + delay;
   int ret;
 
-  do
+  for (; ; )
     {
       /* Take the semaphore (perhaps waiting) */
 
-      ret = nxsem_tickwait(sem, start, delay);
+      ret = nxsem_tickwait(sem, delay);
+      if (ret != -EINTR)
+        {
+          break;
+        }
+
+      delay = end - clock_systime_ticks();
+      if ((int32_t)delay < 0)
+        {
+          delay = 0;
+        }
     }
-  while (ret == -EINTR);
 
   return ret;
 }
-


[incubator-nuttx] 05/06: tools/nxstyle: Add kbps to the while suffix list

Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit f905563cc9f5d05a67e30c52520c4f83e0a44c0f
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri May 13 20:31:29 2022 +0800

    tools/nxstyle: Add kbps to the while suffix list
    
    and correct offset by 1 error
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 tools/nxstyle.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/nxstyle.c b/tools/nxstyle.c
index 0c19c5e0b1..a13673d40b 100644
--- a/tools/nxstyle.c
+++ b/tools/nxstyle.c
@@ -211,8 +211,11 @@ static const char *g_white_prefix[] =
 
 static const char *g_white_suffix[] =
 {
-  "kHz",
+  /* Ref:  include/nuttx/wireless/nrf24l01.h */
+
   "Mbps",
+  "kHz",
+  "kbps",
   "us",
   NULL
 };
@@ -738,7 +741,7 @@ static bool white_list(const char *ident, int lineno)
     }
 
   len2 = strlen(ident);
-  while (!isalnum(ident[len2]))
+  while (!isalnum(ident[len2 - 1]))
     {
       len2--;
     }