From: Simon Glass <simon.glass@canonical.com>
Move the KMEM_CACHE() convenience macro to include/linux/slab.h where
it belongs with other kmem_cache functions. This macro creates a named
cache for a specific structure type.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
fs/ext4l/ext4_uboot.h | 3 +--
include/linux/slab.h | 10 ++++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
@@ -297,8 +297,7 @@ int __ext4_xattr_set_credits(struct super_block *sb, struct inode *inode,
/* Memory allocation - use linux/slab.h which is already available */
#include <linux/slab.h>
-/* KMEM_CACHE macro - use kmem_cache_create */
-#define KMEM_CACHE(s, flags) kmem_cache_create(#s, sizeof(struct s), 0, flags, NULL)
+/* KMEM_CACHE macro is in linux/slab.h */
/*
* RB tree operations - use real rbtree implementation from lib/rbtree.c
@@ -117,6 +117,16 @@ struct kmem_cache {
struct kmem_cache *get_mem(int element_sz);
#define kmem_cache_create(a, sz, c, d, e) ({ (void)(a); (void)(e); get_mem(sz); })
+
+/**
+ * KMEM_CACHE - shorthand for creating a named kmem_cache
+ * @s: struct type name
+ * @flags: cache creation flags
+ *
+ * Creates a cache for objects of type struct @s with the specified flags.
+ */
+#define KMEM_CACHE(s, flags) kmem_cache_create(#s, sizeof(struct s), 0, flags, NULL)
+
void *kmem_cache_alloc(struct kmem_cache *obj, gfp_t flag);
static inline void *kmem_cache_zalloc(struct kmem_cache *obj, gfp_t flags)