[Concept,10/14] linux: slab: Convert kmem_cache functions to declarations

Message ID 20251230205157.3383926-11-sjg@u-boot.org
State New
Headers
Series ext4l: Linux adaptation patches for ext4 write support |

Commit Message

Simon Glass Dec. 30, 2025, 8:51 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Convert kmem_cache_free() and kmem_cache_destroy() from inline
functions to declarations, so implementations can be provided in
lib/linux_compat.c

Also simplify kmem_cache_create macro.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 include/linux/slab.h | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
  

Patch

diff --git a/include/linux/slab.h b/include/linux/slab.h
index 2b374641534..599916218d7 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -84,14 +84,15 @@  static inline void *krealloc(const void *p, size_t new_size, gfp_t flags)
 
 void *kmemdup(const void *src, size_t len, gfp_t gfp);
 
-/* kmem_cache stubs */
 struct kmem_cache {
 	int sz;
 };
 
 struct kmem_cache *get_mem(int element_sz);
-#define kmem_cache_create(a, sz, c, d, e)	({ (void)(a); (void)(e); get_mem(sz); })
+#define kmem_cache_create(a, sz, c, d, e)	get_mem(sz)
 void *kmem_cache_alloc(struct kmem_cache *obj, gfp_t flag);
+void kmem_cache_free(struct kmem_cache *cachep, void *obj);
+void kmem_cache_destroy(struct kmem_cache *cachep);
 
 static inline void *kmem_cache_zalloc(struct kmem_cache *obj, gfp_t flags)
 {
@@ -102,14 +103,4 @@  static inline void *kmem_cache_zalloc(struct kmem_cache *obj, gfp_t flags)
 	return ret;
 }
 
-static inline void kmem_cache_free(struct kmem_cache *cachep, void *obj)
-{
-	free(obj);
-}
-
-static inline void kmem_cache_destroy(struct kmem_cache *cachep)
-{
-	free(cachep);
-}
-
 #endif /* _LINUX_SLAB_H */