Make initializer for statically declared krefs
PATCH 1/1 Make initializer for statically declared krefs
Since the struct kref already has the _get, _put and _init routines, this seems useful to have an initializer for those statically declared (like for atomic_t or spinlock_t).
Signed-off-by Pavel Emelyanov <[email protected]>
---
include/linux/kref.h +2 -0
@@ -24,6 +24,8 @@ struct kref {atomic_t refcount; }; +#define INIT_KREF (count) { .refcount = ATOMIC_INIT(count), } +void kref_init (struct kref *kref);void kref_get (struct kref *kref);int kref_put (struct kref *kref,void (*release) (struct kref *kref));
init/version.c +1 -3
@@ -19,9 +19,7 @@int version_string (LINUX_VERSION_CODE );struct uts_namespace init_uts_ns = { - .kref = { - .refcount =ATOMIC_INIT (2 ), - }, + .kref =INIT_KREF (2 ), .name = { .sysname =UTS_SYSNAME , .nodename =UTS_NODENAME ,
ipc/util.c +1 -3
@@ -45,9 +45,7 @@ struct ipc_proc_iface { };struct ipc_namespace init_ipc_ns = { - .kref = { - .refcount =ATOMIC_INIT (2 ), - }, + .kref =INIT_KREF (2 ), };static struct ipc_namespace *clone_ipc_ns (struct ipc_namespace *old_ns)
kernel/pid.c +1 -3
@@ -69,9 +69,7 @@ static inline int mk_pid(struct pid_name* the scheme scales to up to 4 million PIDs, runtime. */ struct pid_namespace init_pid_ns = { - .kref = { - .refcount =ATOMIC_INIT (2 ), - }, + .kref =INIT_KREF (2 ), .pidmap = { [0 ...PIDMAP_ENTRIES -1 ] = {ATOMIC_INIT (BITS_PER_PAGE ),NULL } },
kernel/user_namespace.c +1 -3
@@ -11,9 +11,7 @@#include <linux/user_namespace.h> struct user_namespace init_user_ns = { - .kref = { - .refcount =ATOMIC_INIT (2 ), - }, + .kref =INIT_KREF (2 ), .root_user = &root_user, };
Quoted 5 lines · Pavel Emelyanov
Since the struct kref already has the
_get,_putand_initroutines, this seems useful to have an initializer for those statically declared (like foratomic_torspinlock_t).Signed-off-by Pavel Emelyanov <[email protected]>
Sure.
Acked-by Serge Hallyn <[email protected]>
Quoted 74 lines
---
include/linux/kref.h +2
-0@@ -24,6 +24,8 @@ struct kref {atomic_t refcount; }; +#define INIT_KREF (count) { .refcount = ATOMIC_INIT(count), } +void kref_init (struct kref *kref);void kref_get (struct kref *kref);int kref_put (struct kref *kref,void (*release) (struct kref *kref));init/version.c +1
-3@@ -19,9 +19,7 @@int version_string (LINUX_VERSION_CODE );struct uts_namespace init_uts_ns = { - .kref = { - .refcount =ATOMIC_INIT (2 ), - }, + .kref =INIT_KREF (2 ), .name = { .sysname =UTS_SYSNAME , .nodename =UTS_NODENAME ,ipc/util.c +1
-3@@ -45,9 +45,7 @@ struct ipc_proc_iface { };struct ipc_namespace init_ipc_ns = { - .kref = { - .refcount =ATOMIC_INIT (2 ), - }, + .kref =INIT_KREF (2 ), };static struct ipc_namespace *clone_ipc_ns (struct ipc_namespace *old_ns)kernel/pid.c +1
-3@@ -69,9 +69,7 @@ static inline int mk_pid(struct pid_name* the scheme scales to up to 4 million PIDs, runtime. */ struct pid_namespace init_pid_ns = { - .kref = { - .refcount =ATOMIC_INIT (2 ), - }, + .kref =INIT_KREF (2 ), .pidmap = { [0 ...PIDMAP_ENTRIES -1 ] = {ATOMIC_INIT (BITS_PER_PAGE ),NULL } },kernel/user_namespace.c +1
-3@@ -11,9 +11,7 @@#include <linux/user_namespace.h> struct user_namespace init_user_ns = { - .kref = { - .refcount =ATOMIC_INIT (2 ), - }, + .kref =INIT_KREF (2 ), .root_user = &root_user, };