From 98f0006674af3dcdd1d7c3301118abf5cbbf5997 Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Fri, 11 Oct 2024 11:08:58 +0800 Subject: [PATCH 1/5] rpmsg/rpmsg_virtio.h: include to fix compile error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /data/project/code/apache/nuttx/include/nuttx/rpmsg/rpmsg_virtio.h:176:28: error: field ‘rsc_tbl_hdr’ has incomplete type 176 | struct resource_table rsc_tbl_hdr; | ^~~~~~~~~~~ /data/project/code/apache/nuttx/include/nuttx/rpmsg/rpmsg_virtio.h:178:28: error: field ‘log_trace’ has incomplete type 178 | struct fw_rsc_trace log_trace; | ^~~~~~~~~ /data/project/code/apache/nuttx/include/nuttx/rpmsg/rpmsg_virtio.h:179:28: error: field ‘rpmsg_vdev’ has incomplete type 179 | struct fw_rsc_vdev rpmsg_vdev; | ^~~~~~~~~~ /data/project/code/apache/nuttx/include/nuttx/rpmsg/rpmsg_virtio.h:180:28: error: field ‘rpmsg_vring0’ has incomplete type 180 | struct fw_rsc_vdev_vring rpmsg_vring0; | ^~~~~~~~~~~~ /data/project/code/apache/nuttx/include/nuttx/rpmsg/rpmsg_virtio.h:181:28: error: field ‘rpmsg_vring1’ has incomplete type 181 | struct fw_rsc_vdev_vring rpmsg_vring1; | ^~~~~~~~~~~~ /data/project/code/apache/nuttx/include/nuttx/rpmsg/rpmsg_virtio.h:182:28: error: field ‘config’ has incomplete type 182 | struct fw_rsc_config config; Signed-off-by: Bowen Wang --- include/nuttx/rpmsg/rpmsg_virtio.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/nuttx/rpmsg/rpmsg_virtio.h b/include/nuttx/rpmsg/rpmsg_virtio.h index e6ac1d547d276..52e0e131537c5 100644 --- a/include/nuttx/rpmsg/rpmsg_virtio.h +++ b/include/nuttx/rpmsg/rpmsg_virtio.h @@ -33,6 +33,7 @@ #include #include +#include /**************************************************************************** * Pre-processor Definitions From bbe28d37559586ff7baeb095fbbdc2e0e237da01 Mon Sep 17 00:00:00 2001 From: buxiasen Date: Tue, 8 Oct 2024 13:44:35 +0800 Subject: [PATCH 2/5] rpmsg/virtio: fix compile issue, feature uint32_t to uint64_t Has change the virtio feature bit to 64bit, so rpmsg virtio need change to 64bit too. Signed-off-by: buxiasen --- drivers/rpmsg/rpmsg_virtio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/rpmsg/rpmsg_virtio.c b/drivers/rpmsg/rpmsg_virtio.c index be3c7feb6e921..5d3a10cecbacd 100644 --- a/drivers/rpmsg/rpmsg_virtio.c +++ b/drivers/rpmsg/rpmsg_virtio.c @@ -81,9 +81,9 @@ static int rpmsg_virtio_create_virtqueues_(FAR struct virtio_device *vdev, static uint8_t rpmsg_virtio_get_status_(FAR struct virtio_device *dev); static void rpmsg_virtio_set_status_(FAR struct virtio_device *dev, uint8_t status); -static uint32_t rpmsg_virtio_get_features_(FAR struct virtio_device *dev); +static uint64_t rpmsg_virtio_get_features_(FAR struct virtio_device *dev); static void rpmsg_virtio_set_features(FAR struct virtio_device *dev, - uint32_t feature); + uint64_t feature); static void rpmsg_virtio_notify(FAR struct virtqueue *vq); /**************************************************************************** @@ -181,7 +181,7 @@ static void rpmsg_virtio_set_status_(FAR struct virtio_device *vdev, priv->rsc->rpmsg_vdev.status = status; } -static uint32_t rpmsg_virtio_get_features_(FAR struct virtio_device *vdev) +static uint64_t rpmsg_virtio_get_features_(FAR struct virtio_device *vdev) { FAR struct rpmsg_virtio_priv_s *priv = rpmsg_virtio_get_priv(vdev); @@ -189,7 +189,7 @@ static uint32_t rpmsg_virtio_get_features_(FAR struct virtio_device *vdev) } static void rpmsg_virtio_set_features(FAR struct virtio_device *vdev, - uint32_t features) + uint64_t features) { FAR struct rpmsg_virtio_priv_s *priv = rpmsg_virtio_get_priv(vdev); From 189ce284380fb18fa25b2de589b854f5c1378038 Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Fri, 11 Oct 2024 10:50:34 +0800 Subject: [PATCH 3/5] rpmsg_virtio: move notify_wait_cb to struct rpmsg_virtio_device notify_wait_cb has been moved to struct rpmsg_virtio_device, so change rpmsg_virtio.c transport too. Signed-off-by: Bowen Wang --- drivers/rpmsg/rpmsg_virtio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/rpmsg/rpmsg_virtio.c b/drivers/rpmsg/rpmsg_virtio.c index 5d3a10cecbacd..044b7691e4115 100644 --- a/drivers/rpmsg/rpmsg_virtio.c +++ b/drivers/rpmsg/rpmsg_virtio.c @@ -582,7 +582,7 @@ static int rpmsg_virtio_start(FAR struct rpmsg_virtio_priv_s *priv) } priv->rvdev.rdev.ns_unbind_cb = rpmsg_ns_unbind; - priv->rvdev.rdev.notify_wait_cb = rpmsg_virtio_notify_wait; + priv->rvdev.notify_wait_cb = rpmsg_virtio_notify_wait; RPMSG_VIRTIO_REGISTER_CALLBACK(priv->dev, rpmsg_virtio_callback, priv); @@ -604,7 +604,7 @@ static int rpmsg_virtio_start(FAR struct rpmsg_virtio_priv_s *priv) static int rpmsg_virtio_thread(int argc, FAR char *argv[]) { FAR struct rpmsg_virtio_priv_s *priv = (FAR struct rpmsg_virtio_priv_s *) - ((uintptr_t)strtoul(argv[2], NULL, 0)); + ((uintptr_t)strtoul(argv[2], NULL, 16)); int ret; priv->tid = nxsched_gettid(); From a6470063c073a7f81b5ccef42b50da12e58a41b7 Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Fri, 11 Oct 2024 10:57:36 +0800 Subject: [PATCH 4/5] sim:rpserver_virtio and rpproxy_virtio: add rpmsg_virtio config for sim add rpserver_virtio and rproxy_virtio to verify the rpmsg virtio transport Signed-off-by: Bowen Wang --- .../sim/sim/configs/rpproxy_virtio/defconfig | 86 ++++++++++++++ .../sim/sim/configs/rpserver_virtio/defconfig | 111 ++++++++++++++++++ boards/sim/sim/sim/src/sim_bringup.c | 8 ++ 3 files changed, 205 insertions(+) create mode 100644 boards/sim/sim/sim/configs/rpproxy_virtio/defconfig create mode 100644 boards/sim/sim/sim/configs/rpserver_virtio/defconfig diff --git a/boards/sim/sim/sim/configs/rpproxy_virtio/defconfig b/boards/sim/sim/sim/configs/rpproxy_virtio/defconfig new file mode 100644 index 0000000000000..f0bfad2d0f8d8 --- /dev/null +++ b/boards/sim/sim/sim/configs/rpproxy_virtio/defconfig @@ -0,0 +1,86 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_NET_ETHERNET is not set +CONFIG_ARCH="sim" +CONFIG_ARCH_BOARD="sim" +CONFIG_ARCH_BOARD_SIM=y +CONFIG_ARCH_CHIP="sim" +CONFIG_ARCH_SIM=y +CONFIG_BLK_RPMSG=y +CONFIG_BOARDCTL_POWEROFF=y +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FS=y +CONFIG_DEBUG_FS_ERROR=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEV_RPMSG=y +CONFIG_DEV_SIMPLE_ADDRENV=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXAMPLES_RPMSGSOCKET=y +CONFIG_FS_PROCFS=y +CONFIG_FS_RPMSGFS=y +CONFIG_IDLETHREAD_STACKSIZE=4096 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INPUT=y +CONFIG_LIBC_HOSTNAME="proxy" +CONFIG_MTD=y +CONFIG_MTD_BYTE_WRITE=y +CONFIG_NDEBUG=y +CONFIG_NET=y +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDB_DNSCLIENT_MAXRESPONSE=176 +CONFIG_NETDB_DNSCLIENT_RECV_TIMEOUT=3 +CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x771d1d1d +CONFIG_NETUTILS_IPERF=y +CONFIG_NET_RPMSG=y +CONFIG_NET_USRSOCK=y +CONFIG_NET_USRSOCK_ICMP=y +CONFIG_NET_USRSOCK_RPMSG=y +CONFIG_NET_USRSOCK_RPMSG_CPUNAME="server" +CONFIG_NET_USRSOCK_TCP=y +CONFIG_NET_USRSOCK_UDP=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_PROMPT_STRING="proxy> " +CONFIG_NSH_READLINE=y +CONFIG_OPENAMP_DEBUG=y +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_READLINE_TABCOMPLETION=y +CONFIG_RPMSGMTD=y +CONFIG_RPMSG_PING=y +CONFIG_RPMSG_UART=y +CONFIG_RPMSG_VIRTIO=y +CONFIG_RTC=y +CONFIG_RTC_ARCH=y +CONFIG_RTC_DRIVER=y +CONFIG_RTC_EXTERNAL=y +CONFIG_RTC_RPMSG=y +CONFIG_RTC_RPMSG_SERVER_NAME="server" +CONFIG_SCHED_CHILD_STATUS=y +CONFIG_SCHED_HAVE_PARENT=y +CONFIG_SCHED_WAITPID=y +CONFIG_SENSORS=y +CONFIG_SENSORS_RPMSG=y +CONFIG_SIG_DEFAULT=y +CONFIG_SIM_M32=y +CONFIG_SYSLOG_PREFIX=y +CONFIG_SYSLOG_PREFIX_STRING="proxy" +CONFIG_SYSLOG_RPMSG=y +CONFIG_SYSLOG_RPMSG_SERVER_NAME="server" +CONFIG_SYSLOG_TIMESTAMP=y +CONFIG_SYSTEM_CLE=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_PING=y +CONFIG_UINPUT_BUTTONS=y +CONFIG_UINPUT_KEYBOARD=y +CONFIG_UINPUT_RPMSG=y +CONFIG_UINPUT_TOUCH=y +CONFIG_UORB=y +CONFIG_UORB_LISTENER=y +CONFIG_USENSOR=y diff --git a/boards/sim/sim/sim/configs/rpserver_virtio/defconfig b/boards/sim/sim/sim/configs/rpserver_virtio/defconfig new file mode 100644 index 0000000000000..58c859085e26d --- /dev/null +++ b/boards/sim/sim/sim/configs/rpserver_virtio/defconfig @@ -0,0 +1,111 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +CONFIG_ARCH="sim" +CONFIG_ARCH_BOARD="sim" +CONFIG_ARCH_BOARD_SIM=y +CONFIG_ARCH_CHIP="sim" +CONFIG_ARCH_SIM=y +CONFIG_BLK_RPMSG_SERVER=y +CONFIG_BOARDCTL_POWEROFF=y +CONFIG_BUILTIN=y +CONFIG_CLK=y +CONFIG_CLK_RPMSG=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FS=y +CONFIG_DEBUG_FS_ERROR=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEV_RPMSG_SERVER=y +CONFIG_DEV_SIMPLE_ADDRENV=y +CONFIG_EXAMPLES_RPMSGSOCKET=y +CONFIG_FS_HOSTFS=y +CONFIG_FS_PROCFS=y +CONFIG_FS_RPMSGFS_SERVER=y +CONFIG_IDLETHREAD_STACKSIZE=4096 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INPUT=y +CONFIG_IOB_BUFSIZE=256 +CONFIG_IOB_NBUFFERS=512 +CONFIG_IOB_THROTTLE=32 +CONFIG_IOEXPANDER=y +CONFIG_IOEXPANDER_RPMSG=y +CONFIG_LIBC_HOSTNAME="server" +CONFIG_MTD=y +CONFIG_MTD_BYTE_WRITE=y +CONFIG_NDEBUG=y +CONFIG_NET=y +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDB_DNSCLIENT_MAXRESPONSE=176 +CONFIG_NETDB_DNSCLIENT_RECV_TIMEOUT=3 +CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x771d1d1d +CONFIG_NETDEV_STATISTICS=y +CONFIG_NETINIT_DHCPC=y +CONFIG_NETINIT_THREAD=y +CONFIG_NETUTILS_DHCPC=y +CONFIG_NETUTILS_IPERF=y +CONFIG_NET_BROADCAST=y +CONFIG_NET_ICMP_SOCKET=y +CONFIG_NET_LOOPBACK=y +CONFIG_NET_RPMSG=y +CONFIG_NET_RPMSG_DRV=y +CONFIG_NET_STATISTICS=y +CONFIG_NET_TCP=y +CONFIG_NET_TCPBACKLOG=y +CONFIG_NET_TCP_WRITE_BUFFERS=y +CONFIG_NET_UDP=y +CONFIG_NET_UDP_WRITE_BUFFERS=y +CONFIG_NET_USRSOCK_RPMSG_SERVER=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_PROMPT_STRING="server> " +CONFIG_NSH_READLINE=y +CONFIG_OPENAMP_DEBUG=y +CONFIG_RAMMTD=y +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_READLINE_TABCOMPLETION=y +CONFIG_REGULATOR=y +CONFIG_REGULATOR_RPMSG=y +CONFIG_RPMSGMTD_SERVER=y +CONFIG_RPMSG_PING=y +CONFIG_RPMSG_UART=y +CONFIG_RPMSG_VIRTIO=y +CONFIG_RTC=y +CONFIG_RTC_ARCH=y +CONFIG_RTC_DRIVER=y +CONFIG_RTC_RPMSG=y +CONFIG_RTC_RPMSG_SERVER=y +CONFIG_SCHED_CHILD_STATUS=y +CONFIG_SCHED_HAVE_PARENT=y +CONFIG_SCHED_WAITPID=y +CONFIG_SENSORS=y +CONFIG_SENSORS_RPMSG=y +CONFIG_SIG_DEFAULT=y +CONFIG_SIM_HOSTFS=y +CONFIG_SIM_M32=y +CONFIG_SIM_NETDEV=y +CONFIG_SIM_NET_BRIDGE=y +CONFIG_SIM_RPMSG_MASTER=y +CONFIG_SIM_UART0_NAME="/dev/ttyUSB0" +CONFIG_SIM_UART_NUMBER=1 +CONFIG_SYSLOG_PREFIX=y +CONFIG_SYSLOG_PREFIX_STRING="server" +CONFIG_SYSLOG_RPMSG_SERVER=y +CONFIG_SYSLOG_TIMESTAMP=y +CONFIG_SYSTEM_CLE=y +CONFIG_SYSTEM_CUTERM=y +CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE="/dev/ttyproxy" +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_PING=y +CONFIG_TTY_SIGINT=y +CONFIG_UINPUT_BUTTONS=y +CONFIG_UINPUT_KEYBOARD=y +CONFIG_UINPUT_RPMSG=y +CONFIG_UINPUT_TOUCH=y +CONFIG_UORB=y +CONFIG_UORB_LISTENER=y +CONFIG_USENSOR=y diff --git a/boards/sim/sim/sim/src/sim_bringup.c b/boards/sim/sim/sim/src/sim_bringup.c index 8c7fecbd25915..8411ec7f44649 100644 --- a/boards/sim/sim/sim/src/sim_bringup.c +++ b/boards/sim/sim/sim/src/sim_bringup.c @@ -483,6 +483,14 @@ int sim_bringup(void) # endif #endif +#ifdef CONFIG_RPMSG_VIRTIO +# ifdef CONFIG_SIM_RPMSG_MASTER + sim_rpmsg_virtio_init("server-proxy", "proxy", true); +# else + sim_rpmsg_virtio_init("server-proxy", "server", false); +# endif +#endif + #ifdef CONFIG_DEV_RPMSG rpmsgdev_register("server", "/dev/console", "/dev/server-console", 0); rpmsgdev_register("server", "/dev/null", "/dev/server-null", 0); From 48e5f5c83b88527b750d2d1c80ec2ad09ce29b34 Mon Sep 17 00:00:00 2001 From: Bowen Wang Date: Thu, 17 Oct 2024 17:06:11 +0800 Subject: [PATCH 5/5] MacOs: fix the sim compile warning in MacOS CC: clk/clk_fixed_rate.c clk/clk_divider.c:177:14: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value] return abs(rate - now) < abs(rate - best); ^ clk/clk_divider.c:177:14: note: remove the call to 'abs' since unsigned values cannot be negative return abs(rate - now) < abs(rate - best); ^~~ clk/clk_divider.c:177:32: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value] return abs(rate - now) < abs(rate - best); ^ clk/clk_divider.c:177:32: note: remove the call to 'abs' since unsigned values cannot be negative return abs(rate - now) < abs(rate - best); ^~~ CC: mm_heap/mm_initialize.c 2 warnings generated. clk/clk.c:1324:11: warning: variable 'irqflags' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (clk->parents == NULL) ^~~~~~~~~~~~~~~~~~~~ clk/clk.c:1341:19: note: uninitialized use occurs here clk_list_unlock(irqflags); ^~~~~~~~ clk/clk.c:1324:7: note: remove the 'if' if its condition is always false if (clk->parents == NULL) ^~~~~~~~~~~~~~~~~~~~~~~~~ clk/clk.c:1255:22: note: initialize the variable 'irqflags' to silence this warning irqstate_t irqflags; ^ = 0 CC: clk/clk_mux.c clk/clk_multiplier.c:110:14: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value] return abs(rate - new) < abs(rate - best); ^ clk/clk_multiplier.c:110:14: note: remove the call to 'abs' since unsigned values cannot be negative return abs(rate - new) < abs(rate - best); ^~~ clk/clk_multiplier.c:110:32: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value] return abs(rate - new) < abs(rate - best); ^ clk/clk_multiplier.c:110:32: note: remove the call to 'abs' since unsigned values cannot be negative return abs(rate - new) < abs(rate - best); ^~~ clk/clk_mux.c:47:14: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value] return abs(now - rate) < abs(best - rate); ^ clk/clk_mux.c:47:14: note: remove the call to 'abs' since unsigned values cannot be negative return abs(now - rate) < abs(best - rate); ^~~ clk/clk_mux.c:47:32: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value] return abs(now - rate) < abs(best - rate); ^ clk/clk_mux.c:47:32: note: remove the call to 'abs' since unsigned values cannot be negative return abs(now - rate) < abs(best - rate); ^~~ AS: sim/sim_fork_x86.S 2 warnings generated. 1 warning2 warnings generated. generated. iperf.c:325:14: warning: format specifies type 'uintmax_t' (aka 'unsigned long long') but the argument has type 'unsigned long' [-Wformat] now_len -last_len, ^~~~~~~~~~~~~~~~~ iperf.c:340:14: warning: format specifies type 'uintmax_t' (aka 'unsigned long long') but the argument has type 'uintmax_t' (aka 'unsigned long') [-Wformat] now_len, ^~~~~~~ CC: misc/rpmsgblk_server.c 2 warnings generated. :28: warning: format specifies type 'uintmax_t' (aka 'unsigned long long') but the argument has type 'uintmax_t' (aka 'unsigned long') [-Wformat] (uintmax_t)skip); ^~~~~~~~~~~~~~~ nsh_dbgcmds.c:473:20: warning: format specifies type 'uintmax_t' (aka 'unsigned long long') but the argument has type 'uintmax_t' (aka 'unsigned long') [-Wformat] (uintmax_t)position); ^~~~~~~~~~~~~~~~~~~ CC: nsh_main.c 2 warnings generated. return INTMAX_MIN; ~~~~~~ ^~~~~~~~~~ CC: nsh_system.c note: expanded from macro 'INTMAX_MIN' ^~~~~~~~~ /Users/vela/work/nuttx/include/stdint.h:65:41: note: expanded from macro 'INT64_MIN' ~~~~~~~~~~~^~~ inttypes/lib_strtoimax.c:103:37: warning: implicit conversion from 'long long' to 'intmax_t' (aka 'long') changes value from -9223372036854775808 to 0 [-Wconstant-conversion] return (accum == limit) ? INTMAX_MIN : -(intmax_t)accum; ~~~~~~ ^~~~~~~~~~ /Users/vela/work/nuttx/include/stdint.h:136:29: note: expanded from macro 'INTMAX_MIN' ^~~~~~~~~ /Users/vela/work/nuttx/include/stdint.h:65:41: note: expanded from macro 'INT64_MIN' ~~~~~~~~~~~^~~ inttypes/lib_strtoimax.c:106:17: warning: result of comparison of constant 9223372036854775807 with expression of type 'uintmax_t' (aka 'unsigned long') is always false [-Wtautological-constant-out-of-range-compare] if (accum > INTMAX_MAX) ~~~~~ ^ ~~~~~~~~~~ inttypes/lib_strtoimax.c:109:18: warning: implicit conversion from 'long long' to 'intmax_t' (aka 'long') changes value from 9223372036854775807 to -1 [-Wconstant-conversion] return INTMAX_MAX; ~~~~~~ ^~~~~~~~~~ /Users/vela/work/nuttx/include/stdint.h:137:29: note: expanded from macro 'INTMAX_MAX' ^~~~~~~~~ /Users/vela/work/nuttx/include/stdint.h:66:29: note: expanded from macro 'INT64_MAX' ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/vela/work/nuttx/include/arch/inttypes.h:35:23: note: expanded from macro 'INT64_C' ^~~~~~~ :12:1: note: expanded from here 9223372036854775807ll ^~~~~~~~~~~~~~~~~~~~~ syslog/vsyslog.c:212:32: warning: format specifies type 'uintmax_t' (aka 'unsigned long long') but the argument has type 'uintmax_t' (aka 'unsigned long') [-Wformat] , (uintmax_t)ts.tv_sec ^~~~~~~~~~~~~~~~~~~~ CC: iob/iob_free.c 4 warnings generated. 1 warning generated. CC: mqueue/mq_msgqalloc.c inttypes/lib_strtoumax.c:91:23: warning: implicit conversion from 'unsigned long long' to 'uintmax_t' (aka 'unsigned long') changes value from 18446744073709551615 to 4294967295 [-Wconstant-conversion] accum = UINTMAX_MAX; ~ ^~~~~~~~~~~ /Users/vela/work/nuttx/include/stdint.h:140:29: note: expanded from macro 'UINTMAX_MAX' ^~~~~~~~~~ /Users/vela/work/nuttx/include/stdint.h:67:29: note: expanded from macro 'UINT64_MAX' ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/vela/work/nuttx/include/arch/inttypes.h:36:23: note: expanded from macro 'UINT64_C' ^~~~~~~~ :8:1: note: expanded from here 18446744073709551615ull ^~~~~~~~~~~~~~~~~~~~~~~ CC: icmp/icmp_ioctl.c 1 warning generated. time/lib_strftime.c:584:52: warning: format specifies type 'uintmax_t' (aka 'unsigned long long') but the argument has type 'uintmax_t' (aka 'unsigned long') [-Wformat] len = snprintf(dest, chleft, "%ju", (uintmax_t)mktime(&tmp)); ~~~ ^~~~~~~~~~~~~~~~~~~~~~~ %ju Signed-off-by: Bowen Wang --- drivers/clk/clk.c | 3 ++- drivers/clk/clk.h | 8 ++++++++ drivers/clk/clk_divider.c | 2 +- drivers/clk/clk_multiplier.c | 2 +- drivers/clk/clk_mux.c | 2 +- drivers/syslog/vsyslog.c | 2 +- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index fc2a6d751bc11..522829b1ac64f 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1337,8 +1337,9 @@ FAR struct clk_s *clk_register(FAR const char *name, return clk; } -out: clk_list_unlock(irqflags); + +out: if (clk->parents) { kmm_free(clk->parents); diff --git a/drivers/clk/clk.h b/drivers/clk/clk.h index 917e565e2cda2..c06095cbad0bd 100644 --- a/drivers/clk/clk.h +++ b/drivers/clk/clk.h @@ -57,6 +57,14 @@ static inline uint32_t clk_read(uint32_t reg) return *((volatile uint32_t *)(uintptr_t)reg); } +static inline bool clk_is_best_rate_closest(uint32_t rate, uint32_t now, + uint32_t best) +{ + uint32_t rate1 = rate > now ? (rate - now) : (now - rate); + uint32_t rate2 = rate > best ? (rate - best) : (best - rate); + return rate1 < rate2; +} + static inline uint32_t gcd(uint32_t a, uint32_t b) { uint32_t r; diff --git a/drivers/clk/clk_divider.c b/drivers/clk/clk_divider.c index 7490e3dd4af4c..079d8f7fd3d34 100644 --- a/drivers/clk/clk_divider.c +++ b/drivers/clk/clk_divider.c @@ -174,7 +174,7 @@ static bool _is_best_div(uint32_t rate, uint32_t now, { if (flags & CLK_DIVIDER_ROUND_CLOSEST) { - return abs(rate - now) < abs(rate - best); + return clk_is_best_rate_closest(rate, now, best); } return now <= rate && now > best; diff --git a/drivers/clk/clk_multiplier.c b/drivers/clk/clk_multiplier.c index 0be6bbaa6e67f..a25c34be08bba 100644 --- a/drivers/clk/clk_multiplier.c +++ b/drivers/clk/clk_multiplier.c @@ -107,7 +107,7 @@ static bool __is_best_rate(uint32_t rate, uint32_t new, { if (flags & CLK_MULT_ROUND_CLOSEST) { - return abs(rate - new) < abs(rate - best); + return clk_is_best_rate_closest(rate, new, best); } return new >= rate && new < best; diff --git a/drivers/clk/clk_mux.c b/drivers/clk/clk_mux.c index fc7c4ae768e64..aef92cd04ef18 100644 --- a/drivers/clk/clk_mux.c +++ b/drivers/clk/clk_mux.c @@ -44,7 +44,7 @@ static bool mux_is_better_rate(uint32_t rate, uint32_t now, { if (flags & CLK_MUX_ROUND_CLOSEST) { - return abs(now - rate) < abs(best - rate); + return clk_is_best_rate_closest(rate, now, best); } return now <= rate && now > best; diff --git a/drivers/syslog/vsyslog.c b/drivers/syslog/vsyslog.c index 2948ace47e37e..0a825166493d5 100644 --- a/drivers/syslog/vsyslog.c +++ b/drivers/syslog/vsyslog.c @@ -165,7 +165,7 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap) "[%s] " # endif # else - "[%5jd.%06ld] " + "[%5ju.%06ld] " # endif #endif