Skip to content

Commit 63440d1

Browse files
Christoph Hellwigbrauner
authored andcommitted
lockref: add a lockref_init helper
Add a helper to initialize the lockdep, that is initialize the spinlock and set a value. Having to open code them isn't a big deal, but having an initializer feels right for a proper primitive. Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 25d8060 commit 63440d1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

include/linux/lockref.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ struct lockref {
3434
};
3535
};
3636

37+
/**
38+
* lockref_init - Initialize a lockref
39+
* @lockref: pointer to lockref structure
40+
* @count: initial count
41+
*/
42+
static inline void lockref_init(struct lockref *lockref, unsigned int count)
43+
{
44+
spin_lock_init(&lockref->lock);
45+
lockref->count = count;
46+
}
47+
3748
void lockref_get(struct lockref *lockref);
3849
int lockref_put_return(struct lockref *lockref);
3950
bool lockref_get_not_zero(struct lockref *lockref);

0 commit comments

Comments
 (0)