From patchwork Mon Dec 22 11:56:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1032 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=1766404627; bh=OLyoAH9IljX1FqYXRMeGmJskNWnnOTRhCcDfFshkTEg=; 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=UFdhzMiTaJ0hkPr59hnNTxCCj5VLnEFnSimU+vpgcETAfkgkKK3cD1OJkOdO1Brsh 5sw22ZIawhsFvDXJRRtwN+H40Amkh44xcuz2CA04vS+k4hW4M13wHKpn7gToIN4VXG mRu+u6bgc1jq8FWQeOUcTVm7Y8sh96B26OZwLfVaiTOWtBnJxneIRHC9H/RrP+pWlu TiVAR7h01T+fAFSL/YzPN19phTaDovhYsbY5xLC6nV2o6r3IvCUepk7RQL1Y2ZHEPE dSkxrDYhp7rsWZKvYuKDU7/vgo0kfMO5rg559NXvygAQuB5hxhLkLawyrLyxjuDxH3 F6Uepa+gliAOw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 55CD464D3E for ; Mon, 22 Dec 2025 04:57: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 GuvDO1_cO8k7 for ; Mon, 22 Dec 2025 04:57:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766404627; bh=OLyoAH9IljX1FqYXRMeGmJskNWnnOTRhCcDfFshkTEg=; 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=UFdhzMiTaJ0hkPr59hnNTxCCj5VLnEFnSimU+vpgcETAfkgkKK3cD1OJkOdO1Brsh 5sw22ZIawhsFvDXJRRtwN+H40Amkh44xcuz2CA04vS+k4hW4M13wHKpn7gToIN4VXG mRu+u6bgc1jq8FWQeOUcTVm7Y8sh96B26OZwLfVaiTOWtBnJxneIRHC9H/RrP+pWlu TiVAR7h01T+fAFSL/YzPN19phTaDovhYsbY5xLC6nV2o6r3IvCUepk7RQL1Y2ZHEPE dSkxrDYhp7rsWZKvYuKDU7/vgo0kfMO5rg559NXvygAQuB5hxhLkLawyrLyxjuDxH3 F6Uepa+gliAOw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 443B864D59 for ; Mon, 22 Dec 2025 04:57:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766404625; bh=UW07Wny9in71ex8xLQGUzi3rVnKt8D8uaoavruJiK74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aSufuMmq4KFGlLHp6uDcPKDMQdJMQRIDRpCxMDmByajJ4cy7GbJJFGub/QeDmp8/R DhD+Y/7ZRnXCvyZBPWf/7Ux4pVFvAeqhFXmIOwtTHzrJ6a5gtP0JXLHF/xQjmHmkOC T+528hlV4dgfWAWmDv79ubPGniRxBb8SkUrnhh4WD7h7nY/I8OhR6NUYg2KtGOXpLc +uQkOwrnSkGAHY1sWkmbOG0t3RHW+p+5qx0mBIFzAVznjU9p+MK0ja1G2jOHnYETqO 583HoD1VEA5IVVbNLJ7B9nPmxqxkwUbnCUeK+dtM/QYJO6IBhYlfkyQf86PsvS7YGA Uoh6qJu7KDR4g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2A39864D3E; Mon, 22 Dec 2025 04:57: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 wtM1G-EvjuSd; Mon, 22 Dec 2025 04:57:05 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766404621; bh=4kqFfLi4fUKzedG0CJFcKOE1d3Y0UTumy0fIG29AW18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OR/7Jxv5/xEwh0w2w6hC6wEU8V/6NojWkZk+fLRzlZUKMTQTdiJityGBC7qCVzY3B urZ+XGWCNTtxma49QDdRCq8WZImnQWQ4AOXrq63pkHHY3gzTGp+APFkFheF9Ym88d/ 6wyGHZkfmPjNmeb3XxuVgqLoQQKES1SUjIzBercXJG00Xghd6aaT+OvC8J2Y3+T5iW MD0HJDV/fY94JBguzJ04fEU+6CFNm8wE5Ore2fKk2oC+VcKN4ZbzlzuKn9tAsEj1vk 1XihuyjlVgItxWlv6xLwI0O8NgTfnDGd6hgAWS3IuXOP+gFmt1EmY0YaZsgqXaoctz eTkBrfrDOENdg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id CD08C64C31; Mon, 22 Dec 2025 04:57:00 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 04:56:06 -0700 Message-ID: <20251222115639.700578-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251222115639.700578-1-sjg@u-boot.org> References: <20251222115639.700578-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: HXQXS2YDK43WEDN52TGEK5MNWFU7INYK X-Message-ID-Hash: HXQXS2YDK43WEDN52TGEK5MNWFU7INYK 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 02/26] linux: Move common types to types.h 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 Move ktime_t, sector_t, blkcnt_t, atomic_t, and atomic64_t to linux/types.h to match Linux kernel header organisation. Remove the duplicate definitions from linux/compat.h and fs/ext4l/ext4_uboot.h since they are now in the canonical location. Co-developed-by: Claude Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 24 ++++++++++-------------- include/linux/compat.h | 16 +--------------- include/linux/types.h | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 1ad9ad7f47a..d0e60c02d77 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -2,6 +2,9 @@ /* * U-Boot compatibility header for ext4l filesystem * + * Copyright 2025 Canonical Ltd + * Written by Simon Glass + * * This provides minimal definitions to allow Linux ext4 code to compile * in U-Boot. */ @@ -52,8 +55,11 @@ struct timespec64 { long tv_nsec; }; -/* ktime_t - kernel time type */ -typedef s64 ktime_t; +/* + * ktime_t, sector_t are in linux/types.h + * atomic_t, atomic64_t are in asm-generic/atomic.h + */ +#include /* Jiffy constants */ #define MAX_JIFFY_OFFSET ((~0UL >> 1) - 1) @@ -61,16 +67,7 @@ typedef s64 ktime_t; /* Block device name size */ #define BDEVNAME_SIZE 32 -/* Atomic types - stubs for single-threaded U-Boot */ -typedef struct { int counter; } atomic_t; -typedef struct { long counter; } atomic64_t; - -#define atomic_read(v) ((v)->counter) -#define atomic_set(v, i) ((v)->counter = (i)) -#define atomic_inc(v) ((v)->counter++) -#define atomic_dec(v) ((v)->counter--) -#define atomic64_read(v) ((v)->counter) -#define atomic64_set(v, i) ((v)->counter = (i)) +/* Extra atomic operations not in asm-generic/atomic.h */ #define atomic_dec_if_positive(v) (--(v)->counter) /* SMP stubs - U-Boot is single-threaded */ @@ -510,8 +507,7 @@ struct sb_writers { /* mapping_large_folio_support stub */ #define mapping_large_folio_support(m) (0) -/* sector_t - needed before buffer_head.h */ -typedef unsigned long sector_t; +/* sector_t is now in linux/types.h */ /* Buffer head - from linux/buffer_head.h */ #include diff --git a/include/linux/compat.h b/include/linux/compat.h index 26f0ef3f101..df67b775b5b 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -110,21 +110,7 @@ static inline void led_trigger_event(struct led_trigger *trigger, /* uapi/linux/limits.h */ #define XATTR_LIST_MAX 65536 /* size of extended attribute namelist (64k) */ -/** - * The type used for indexing onto a disc or disc partition. - * - * Linux always considers sectors to be 512 bytes long independently - * of the devices real block size. - * - * blkcnt_t is the type of the inode's block count. - */ -#ifdef CONFIG_LBDAF -typedef u64 sector_t; -typedef u64 blkcnt_t; -#else -typedef unsigned long sector_t; -typedef unsigned long blkcnt_t; -#endif +/* sector_t and blkcnt_t are now defined in linux/types.h */ /* character device */ diff --git a/include/linux/types.h b/include/linux/types.h index 9df930afd13..957284d37ab 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -151,6 +151,20 @@ typedef __u32 __bitwise __wsum; typedef unsigned __bitwise__ gfp_t; +/* Nanosecond scalar representation for kernel time values */ +typedef s64 ktime_t; + +/** + * The type used for indexing onto a disc or disc partition. + * + * Linux always considers sectors to be 512 bytes long independently + * of the devices real block size. + * + * blkcnt_t is the type of the inode's block count. + */ +typedef u64 sector_t; +typedef u64 blkcnt_t; + #ifdef __linux__ struct ustat { __kernel_daddr_t f_tfree;