linux: Move common types to types.h

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 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
This commit is contained in:
Simon Glass
2025-12-21 12:31:22 -07:00
parent 7caf11dbaf
commit e911e32822
3 changed files with 25 additions and 29 deletions

View File

@@ -2,6 +2,9 @@
/*
* U-Boot compatibility header for ext4l filesystem
*
* Copyright 2025 Canonical Ltd
* Written by Simon Glass <simon.glass@canonical.com>
*
* 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 <asm-generic/atomic.h>
/* 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 <linux/buffer_head.h>

View File

@@ -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 */

View File

@@ -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;