mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 22:20:01 +08:00
sched/clock: remove return value of clock_systime_timespec()
clock_systime_timespec() always returns 0, so there is no need to check the return value in the caller code, let us remove the return value directly. Signed-off-by: chao an <anchao.archer@bytedance.com>
This commit is contained in:
@@ -286,10 +286,7 @@ static uint64_t cisif_get_msec_time(void)
|
||||
{
|
||||
struct timespec tp;
|
||||
|
||||
if (clock_systime_timespec(&tp) < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
clock_systime_timespec(&tp);
|
||||
|
||||
return (((uint64_t)tp.tv_sec) * 1000 + tp.tv_nsec / 1000000);
|
||||
}
|
||||
|
||||
@@ -2094,15 +2094,10 @@ static int cxd56_power_on_micbias(struct cxd56_dev_s *dev)
|
||||
|
||||
/* Set mic boot time */
|
||||
|
||||
if (clock_systime_timespec(&start) < 0)
|
||||
{
|
||||
dev->mic_boot_start = 0x0ull;
|
||||
}
|
||||
else
|
||||
{
|
||||
dev->mic_boot_start = (uint64_t)start.tv_sec * 1000 +
|
||||
(uint64_t)start.tv_nsec / 1000000;
|
||||
}
|
||||
clock_systime_timespec(&start);
|
||||
|
||||
dev->mic_boot_start = (uint64_t)start.tv_sec * 1000 +
|
||||
(uint64_t)start.tv_nsec / 1000000;
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -2953,16 +2948,16 @@ static int cxd56_start(struct audio_lowerhalf_s *lower)
|
||||
if (priv->mic_boot_start != 0x0ull)
|
||||
{
|
||||
struct timespec end;
|
||||
if (clock_systime_timespec(&end) == 0)
|
||||
{
|
||||
uint64_t time = (uint64_t)end.tv_sec * 1000 +
|
||||
(uint64_t)end.tv_nsec / 1000000 -
|
||||
priv->mic_boot_start;
|
||||
|
||||
if (time < CXD56_MIC_BOOT_WAIT)
|
||||
{
|
||||
nxsig_usleep((CXD56_MIC_BOOT_WAIT - time) * 1000);
|
||||
}
|
||||
clock_systime_timespec(&end);
|
||||
|
||||
uint64_t time = (uint64_t)end.tv_sec * 1000 +
|
||||
(uint64_t)end.tv_nsec / 1000000 -
|
||||
priv->mic_boot_start;
|
||||
|
||||
if (time < CXD56_MIC_BOOT_WAIT)
|
||||
{
|
||||
nxsig_usleep((CXD56_MIC_BOOT_WAIT - time) * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,12 +64,7 @@ static void clear_mic_boot_time(void)
|
||||
static void set_mic_boot_time(void)
|
||||
{
|
||||
struct timespec start;
|
||||
if (clock_systime_timespec(&start) < 0)
|
||||
{
|
||||
g_mic_boot_start_time = 0x0ull;
|
||||
return;
|
||||
}
|
||||
|
||||
clock_systime_timespec(&start);
|
||||
g_mic_boot_start_time = (uint64_t)start.tv_sec * 1000 +
|
||||
(uint64_t)start.tv_nsec / 1000000;
|
||||
}
|
||||
@@ -79,11 +74,7 @@ static void wait_mic_boot_finish(void)
|
||||
if (g_mic_boot_start_time != 0x0ull)
|
||||
{
|
||||
struct timespec end;
|
||||
if (clock_systime_timespec(&end) < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
clock_systime_timespec(&end);
|
||||
uint64_t time = (uint64_t)end.tv_sec * 1000 +
|
||||
(uint64_t)end.tv_nsec / 1000000 -
|
||||
g_mic_boot_start_time;
|
||||
|
||||
@@ -835,14 +835,7 @@ int sht4x_register(FAR struct i2c_master_s *i2c, int devno, uint8_t addr)
|
||||
priv->addr = addr;
|
||||
priv->precision = SHT4X_PREC_HIGH;
|
||||
priv->interval = 1000000; /* 1s interval */
|
||||
err = clock_systime_timespec(&priv->last_heat);
|
||||
|
||||
if (err < 0)
|
||||
{
|
||||
snerr("ERROR: Failed to get timespec: %d\n", err);
|
||||
kmm_free(priv);
|
||||
return err;
|
||||
}
|
||||
clock_systime_timespec(&priv->last_heat);
|
||||
|
||||
/* Allow heat immediately after registration since in theory the sensor has
|
||||
* never had its heater activated yet.
|
||||
|
||||
+2
-11
@@ -1230,11 +1230,7 @@ static bool try_repeat(int sec, int usec, FAR isx019_dev_t *priv,
|
||||
struct timespec now;
|
||||
struct timespec delta;
|
||||
|
||||
ret = clock_systime_timespec(&start);
|
||||
if (ret < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
clock_systime_timespec(&start);
|
||||
|
||||
while (1)
|
||||
{
|
||||
@@ -1245,12 +1241,7 @@ static bool try_repeat(int sec, int usec, FAR isx019_dev_t *priv,
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = clock_systime_timespec(&now);
|
||||
if (ret < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
clock_systime_timespec(&now);
|
||||
clock_timespec_subtract(&now, &start, &delta);
|
||||
if ((delta.tv_sec > sec) ||
|
||||
((delta.tv_sec == sec) &&
|
||||
|
||||
@@ -731,13 +731,13 @@ clock_t clock_systime_ticks(void);
|
||||
* ts - Location to return the time
|
||||
*
|
||||
* Returned Value:
|
||||
* OK (0) on success; a negated errno value on failure.
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int clock_systime_timespec(FAR struct timespec *ts);
|
||||
void clock_systime_timespec(FAR struct timespec *ts);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: clock_cpuload
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
From a120e0e698ff3f7af8bfee34a47051f13b74aac0 Mon Sep 17 00:00:00 2001
|
||||
From: chao an <anchao.archer@bytedance.com>
|
||||
Date: Thu, 9 Oct 2025 19:39:01 +0800
|
||||
Subject: [PATCH] libmetal/nuttx: Update function prototype changes
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
clock_systime_timespec() always returns 0, so there is no need to
|
||||
check the return value in the caller code, let us remove the return
|
||||
value directly.
|
||||
|
||||
From:
|
||||
int clock_systime_timespec(FAR struct timespec *ts)
|
||||
To:
|
||||
void clock_systime_timespec(FAR struct timespec *ts)
|
||||
|
||||
Fix build break:
|
||||
|
||||
libmetal/lib/system/nuttx/time.c: In function ‘metal_get_timestamp’:
|
||||
libmetal/lib/system/nuttx/time.c:21:11: error: void value not ignored as it ought to be
|
||||
21 | r = clock_systime_timespec(&tp);
|
||||
| ^
|
||||
make[1]: *** [Makefile:46: libmetal/lib/system/nuttx/time.o] Error 1
|
||||
|
||||
Change-Id: I88443c4a5725bd269a05c8a503bd5095b082bfbe
|
||||
---
|
||||
lib/system/nuttx/time.c | 13 ++++++-------
|
||||
1 file changed, 6 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/lib/system/nuttx/time.c libmetal/lib/system/nuttx/time.c
|
||||
index 986f1ba..f06725d 100644
|
||||
--- a/lib/system/nuttx/time.c
|
||||
+++ libmetal/lib/system/nuttx/time.c
|
||||
@@ -14,14 +14,13 @@
|
||||
|
||||
unsigned long long metal_get_timestamp(void)
|
||||
{
|
||||
- unsigned long long t = 0;
|
||||
+ unsigned long long t;
|
||||
struct timespec tp;
|
||||
- int r;
|
||||
|
||||
- r = clock_systime_timespec(&tp);
|
||||
- if (!r) {
|
||||
- t = (unsigned long long)tp.tv_sec * NSEC_PER_SEC;
|
||||
- t += tp.tv_nsec;
|
||||
- }
|
||||
+ clock_systime_timespec(&tp);
|
||||
+
|
||||
+ t = (unsigned long long)tp.tv_sec * NSEC_PER_SEC;
|
||||
+ t += tp.tv_nsec;
|
||||
+
|
||||
return t;
|
||||
}
|
||||
--
|
||||
2.43.0
|
||||
|
||||
@@ -48,6 +48,8 @@ if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libmetal)
|
||||
${CMAKE_CURRENT_LIST_DIR}/0005-libmetal-cmake-set-HAVE_STDATOMIC_H-default-true-in-.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0006-lib-system-nuttx-io.c-include-stddef.h-in-nuttx-io.c.patch
|
||||
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
|
||||
${CMAKE_CURRENT_LIST_DIR}/0007-libmetal-nuttx-Update-function-prototype-changes.patch
|
||||
DOWNLOAD_NO_PROGRESS true
|
||||
TIMEOUT 30)
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ libmetal.zip:
|
||||
$(Q) patch -p0 < 0004-lib-system-nuttx-fix-unused-parameter-compile-error.patch
|
||||
$(Q) patch -p0 < 0005-libmetal-cmake-set-HAVE_STDATOMIC_H-default-true-in-.patch
|
||||
$(Q) patch -p0 < 0006-lib-system-nuttx-io.c-include-stddef.h-in-nuttx-io.c.patch
|
||||
$(Q) patch -p0 < 0007-libmetal-nuttx-Update-function-prototype-changes.patch
|
||||
|
||||
.libmetal_headers: libmetal.zip
|
||||
else
|
||||
|
||||
@@ -52,14 +52,13 @@
|
||||
* ts - Location to return the time
|
||||
*
|
||||
* Returned Value:
|
||||
* Current version almost always returns OK. Currently errors are
|
||||
* possible with CONFIG_RTC_HIRES only.
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int clock_systime_timespec(FAR struct timespec *ts)
|
||||
void clock_systime_timespec(FAR struct timespec *ts)
|
||||
{
|
||||
#ifdef CONFIG_RTC_HIRES
|
||||
if (g_rtc_enabled)
|
||||
@@ -84,6 +83,4 @@ int clock_systime_timespec(FAR struct timespec *ts)
|
||||
#else
|
||||
clock_ticks2time(ts, g_system_ticks);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user