Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e24edca authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar
Browse files

locking/atomic, kref: Add KREF_INIT()



Since we need to change the implementation, stop exposing internals.

Provide KREF_INIT() to allow static initialization of struct kref.

Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 2b0b2111
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -1070,7 +1070,7 @@ static int bm_rw(struct drbd_device *device, const unsigned int flags, unsigned
		.done = 0,
		.done = 0,
		.flags = flags,
		.flags = flags,
		.error = 0,
		.error = 0,
		.kref = { ATOMIC_INIT(2) },
		.kref = KREF_INIT(2),
	};
	};


	if (!get_ldev_if_state(device, D_ATTACHING)) {  /* put is in drbd_bm_aio_ctx_destroy() */
	if (!get_ldev_if_state(device, D_ATTACHING)) {  /* put is in drbd_bm_aio_ctx_destroy() */
+1 −1
Original line number Original line Diff line number Diff line
@@ -256,7 +256,7 @@ struct fuse_io_priv {


#define FUSE_IO_PRIV_SYNC(f) \
#define FUSE_IO_PRIV_SYNC(f) \
{					\
{					\
	.refcnt = { ATOMIC_INIT(1) },	\
	.refcnt = KREF_INIT(1),		\
	.async = 0,			\
	.async = 0,			\
	.file = f,			\
	.file = f,			\
}
}
+2 −0
Original line number Original line Diff line number Diff line
@@ -24,6 +24,8 @@ struct kref {
	atomic_t refcount;
	atomic_t refcount;
};
};


#define KREF_INIT(n)	{ .refcount = ATOMIC_INIT(n), }

/**
/**
 * kref_init - initialize object.
 * kref_init - initialize object.
 * @kref: object in question.
 * @kref: object in question.
+1 −3
Original line number Original line Diff line number Diff line
@@ -23,9 +23,7 @@ int version_string(LINUX_VERSION_CODE);
#endif
#endif


struct uts_namespace init_uts_ns = {
struct uts_namespace init_uts_ns = {
	.kref = {
	.kref = KREF_INIT(2),
		.refcount	= ATOMIC_INIT(2),
	},
	.name = {
	.name = {
		.sysname	= UTS_SYSNAME,
		.sysname	= UTS_SYSNAME,
		.nodename	= UTS_NODENAME,
		.nodename	= UTS_NODENAME,
+1 −3
Original line number Original line Diff line number Diff line
@@ -68,9 +68,7 @@ static inline int mk_pid(struct pid_namespace *pid_ns,
 * the scheme scales to up to 4 million PIDs, runtime.
 * the scheme scales to up to 4 million PIDs, runtime.
 */
 */
struct pid_namespace init_pid_ns = {
struct pid_namespace init_pid_ns = {
	.kref = {
	.kref = KREF_INIT(2),
		.refcount       = ATOMIC_INIT(2),
	},
	.pidmap = {
	.pidmap = {
		[ 0 ... PIDMAP_ENTRIES-1] = { ATOMIC_INIT(BITS_PER_PAGE), NULL }
		[ 0 ... PIDMAP_ENTRIES-1] = { ATOMIC_INIT(BITS_PER_PAGE), NULL }
	},
	},