Files
u-boot/include/linux/percpu_counter.h
Simon Glass 3b4667ed88 ext4l: Add super.c to build
Add super.c to the ext4l Makefile and provide the infrastructure
needed to compile it:

- Add stubs for block device operations (bdev_file_open_by_dev,
  bdev_fput, bdev_getblk, submit_bh, trylock_buffer)
- Add stubs for NFS export helpers (generic_fh_to_dentry/parent)
- Add stubs for filesystem operations (sync_filesystem, dquot_suspend)
- Add stubs for string operations (strreplace, strtomem_pad)
- Add stubs for memory allocation (alloc_inode_sb, kvzalloc)
- Add stubs for ratelimit, workqueue, and trace functions
- Add fs_context and fs_parameter structures for mount options
- Add blk_holder_ops structure for block device holder operations
- Add pragma to suppress unused function/variable warnings
- Add __maybe_unused to __init/__exit macros in init.h

The only change to super.c itself is replacing the Linux kernel
includes with the U-Boot compatibility header ext4_uboot.h.

Series-to: concept
Cover-letter:
ext4l: Add more ext4 files to the build (part D)
This series continues the ext4l port by adding super.c to the build. The
super.c file contains the superblock operations and filesystem
registration code from the kernel's ext4 driver.

To support this effort compilation, this series adds numerous stubs and
compatibility shims for Linux kernel interfaces not available in
U-Boot, including block device operations, filesystem context
handling, NFS export helpers, and various utility functions.

In particular, fs/ext4l/ext4_uboot.h contains a lot of U-Boot specific
declarations and stubs, with fs/ext4l/stub.c containing various others.

The goal is to eventually have a fully functional ext4 implementation
ported from Linux that can be used for both reading and writing ext4
filesystems in U-Boot.
END

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-20 14:09:14 -07:00

83 lines
1.7 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
/*
* A simple "approximate counter" for use in ext2 and ext3 superblocks.
*
* WARNING: these things are HUGE. 4 kbytes per counter on 32-way P4.
*
* Stub definitions for percpu counters.
* U-Boot is single-threaded, use simple counters.
*/
#ifndef _LINUX_PERCPU_COUNTER_H
#define _LINUX_PERCPU_COUNTER_H
#include <linux/types.h>
struct percpu_counter {
s64 count;
s64 counter; /* Alias for count - some code uses this name */
};
static inline int percpu_counter_init(struct percpu_counter *fbc, s64 amount,
gfp_t gfp)
{
fbc->count = amount;
fbc->counter = amount;
return 0;
}
static inline void percpu_counter_destroy(struct percpu_counter *fbc)
{
}
static inline void percpu_counter_set(struct percpu_counter *fbc, s64 amount)
{
fbc->count = amount;
}
static inline void percpu_counter_add(struct percpu_counter *fbc, s64 amount)
{
fbc->count += amount;
}
static inline void percpu_counter_sub(struct percpu_counter *fbc, s64 amount)
{
fbc->count -= amount;
}
static inline void percpu_counter_inc(struct percpu_counter *fbc)
{
fbc->count++;
}
static inline void percpu_counter_dec(struct percpu_counter *fbc)
{
fbc->count--;
}
static inline s64 percpu_counter_read(struct percpu_counter *fbc)
{
return fbc->count;
}
static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc)
{
return fbc->count > 0 ? fbc->count : 0;
}
static inline s64 percpu_counter_sum(struct percpu_counter *fbc)
{
return fbc->count;
}
static inline s64 percpu_counter_sum_positive(struct percpu_counter *fbc)
{
return fbc->count > 0 ? fbc->count : 0;
}
static inline bool percpu_counter_initialized(struct percpu_counter *fbc)
{
return true;
}
#endif /* _LINUX_PERCPU_COUNTER_H */