From patchwork Sat Jan 17 01:14:23 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1561 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768612507; bh=qY70FDJFS9asyIX4IM7RqmIlq5RKEJhMtLGSTiUiMZE=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Rj/eVG3reTgkD8/GIY179hHdsAY0zcdZ+sPDCBX/P0yaqp7kpF3RO6uHC7sxhtwU1 wFhkeehLXpvH26U4xuzqvptmYXA82zZrtN8P7Qz+zF/wzVhnhkf/DLhW8Vs5RSimlf FyF/eP0xb6DZJK0utVKujL3xJXP6xug68QIsyqotIu+oa8AwtUAuWkPi1qmpEsbR4H RsPnUJD79A8+UCoJ1Kwwpk6pVnTU672JWCs4/BwvwREb5gjRUV9jFDtFGcRmhP+DA4 wYkTRF2SKlNj9j1JcrEtUIFRAmy/8btAxEOBzEqnDEtcpJBH+YNUx0JZuQ/fDc4JWn L5uyOwiStoVaQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8F333693F7 for ; Fri, 16 Jan 2026 18:15:07 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id dPeoYcnWqK52 for ; Fri, 16 Jan 2026 18:15:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768612507; bh=qY70FDJFS9asyIX4IM7RqmIlq5RKEJhMtLGSTiUiMZE=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Rj/eVG3reTgkD8/GIY179hHdsAY0zcdZ+sPDCBX/P0yaqp7kpF3RO6uHC7sxhtwU1 wFhkeehLXpvH26U4xuzqvptmYXA82zZrtN8P7Qz+zF/wzVhnhkf/DLhW8Vs5RSimlf FyF/eP0xb6DZJK0utVKujL3xJXP6xug68QIsyqotIu+oa8AwtUAuWkPi1qmpEsbR4H RsPnUJD79A8+UCoJ1Kwwpk6pVnTU672JWCs4/BwvwREb5gjRUV9jFDtFGcRmhP+DA4 wYkTRF2SKlNj9j1JcrEtUIFRAmy/8btAxEOBzEqnDEtcpJBH+YNUx0JZuQ/fDc4JWn L5uyOwiStoVaQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 75990693E9 for ; Fri, 16 Jan 2026 18:15:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768612505; bh=PPIm5C8/C7+emaVFu69cRFFU0Ol5wNrIjjNcfjMUuFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vBxZ+e8YLsztSGqr9ULFBvrMCJhPwQ7qi7kpZ8Ai1F/n60BUxkyy/i3qtzxD4GrJN QegAoqs/EocKbXkyuQgjqzDPKZo9DVX4yXFwjAtGUaKUlUbqd729KBJGi+mNkGRakw L3FydqtuEPL1ZOZMhxZeoEPT3o0vQlKk1QM0vBXZ+OaGxLkQsfwd9GKJCjMyyv3AMo Gp5iESgySvdG2WzkZfyzGWqxGeALNXgPLVr/K/8x2U3/UZcL33WyEzXA1wBM3QS+lp UWY0iHncLIxt+pDc6vbzmG7dqfFvHsLqk0q2UkvdSKXuXedRNIbmZVhJMJLFz8tWPP 2LZe900utxzOQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 511426913F; Fri, 16 Jan 2026 18:15:05 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id cue2rIVOEBId; Fri, 16 Jan 2026 18:15:05 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768612501; bh=FOYLRzu8wvSnyC4CP+cSDvEAUy+aLNMpffdv11mnIQM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HqdN3UI8PUuNXYVNFN0frigplAFBxuZhOBPNQT8PlyRWNgXUP6TsfA/GC+Q7ulKlw ymAJfWbnK9MiG4hZwo5FXVkqXn/kNvyxaEl+SAdZp8v7kgsSmd22j9SEtbXg4mVJ7d RoGnnrkFyi661bOqk0nNhR69CK07iduHSK1UgrPhKt2xO2LmeESpDRypDQERsPzRG9 AtJ/gGbiNSY+NJ7I16uaiuHDa1zULpV4+QVWzjteciyz4bXkQzcWdFdER8g7uxI0lQ e4xH/MvP+WD9gXC2Uc3MPLS9mHou9gma2P/T5Gs2MB6fK4yIZnpcDbb4gbI5/F/BPw ALQyi08R9yEEg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F3EAD693F7; Fri, 16 Jan 2026 18:15:00 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 16 Jan 2026 18:14:23 -0700 Message-ID: <20260117011448.3007171-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260117011448.3007171-1-sjg@u-boot.org> References: <20260117011448.3007171-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: M7UW5BWOAUZ3YGAWMUJ7NESR7Q475VNQ X-Message-ID-Hash: M7UW5BWOAUZ3YGAWMUJ7NESR7Q475VNQ X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 01/19] linux: Add ktime.h header with time functions List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The ext4l filesystem uses several ktime functions which are currently defined inline in ext4_uboot.h. Create a new linux/ktime.h header file with these stub implementations to better match the Linux kernel structure. This reduces duplication and makes ext4_uboot.h smaller. Functions moved: - ktime_get() - ktime_to_ns() - ktime_sub() - ktime_add_ns() - ktime_get_ns() Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 25 ++-------------- include/linux/ktime.h | 70 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 22 deletions(-) create mode 100644 include/linux/ktime.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 91e0ce95467..04872c0a34e 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1032,26 +1032,8 @@ static inline void shrinker_free(struct shrinker *s) { } -/* ktime functions */ -static inline ktime_t ktime_get(void) -{ - return 0; -} - -static inline s64 ktime_to_ns(ktime_t kt) -{ - return kt; -} - -static inline ktime_t ktime_sub(ktime_t a, ktime_t b) -{ - return a - b; -} - -static inline ktime_t ktime_add_ns(ktime_t kt, s64 ns) -{ - return kt + ns; -} +/* ktime functions - use linux/ktime.h */ +#include /* hrtimer stubs */ #define HRTIMER_MODE_ABS 0 @@ -1983,8 +1965,7 @@ int IOPRIO_PRIO_VALUE(int class, int data); void *kvzalloc(size_t size, gfp_t flags); #define kvmalloc(size, flags) kvzalloc(size, flags) -/* Time operations */ -#define ktime_get_ns() (0ULL) +/* Time operations - ktime_get_ns is in linux/ktime.h */ /* nsecs_to_jiffies is in linux/jiffies.h */ /* Superblock write operations */ diff --git a/include/linux/ktime.h b/include/linux/ktime.h new file mode 100644 index 00000000000..c853e694823 --- /dev/null +++ b/include/linux/ktime.h @@ -0,0 +1,70 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * ktime_t - nanosecond-resolution time format. + * + * Stub implementation for U-Boot. + */ +#ifndef _LINUX_KTIME_H +#define _LINUX_KTIME_H + +#include + +/* ktime_t is defined in linux/types.h */ + +/** + * ktime_get() - get current time + * + * U-Boot stub - returns 0 as we don't track real time during operations. + * + * Return: current time as ktime_t (always 0) + */ +static inline ktime_t ktime_get(void) +{ + return 0; +} + +/** + * ktime_to_ns() - convert ktime_t to nanoseconds + * @kt: the ktime_t value to convert + * + * Return: the nanosecond value + */ +static inline s64 ktime_to_ns(ktime_t kt) +{ + return kt; +} + +/** + * ktime_sub() - subtract two ktime_t values + * @a: first ktime_t value + * @b: second ktime_t value + * + * Return: a - b + */ +static inline ktime_t ktime_sub(ktime_t a, ktime_t b) +{ + return a - b; +} + +/** + * ktime_add_ns() - add nanoseconds to a ktime_t value + * @kt: base ktime_t value + * @ns: nanoseconds to add + * + * Return: kt + ns + */ +static inline ktime_t ktime_add_ns(ktime_t kt, s64 ns) +{ + return kt + ns; +} + +/** + * ktime_get_ns() - get current time in nanoseconds + * + * U-Boot stub - returns 0. + * + * Return: current time in nanoseconds (always 0) + */ +#define ktime_get_ns() (0ULL) + +#endif /* _LINUX_KTIME_H */