From c04a26ee892d440979a84b891d6fac14cd4686f1 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Tue, 6 Feb 2018 20:45:45 +0100 Subject: kern/sref: allow custom initial values --- kern/sref.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'kern/sref.c') diff --git a/kern/sref.c b/kern/sref.c index 404d993f..f145f80e 100644 --- a/kern/sref.c +++ b/kern/sref.c @@ -991,13 +991,16 @@ sref_report_periodic_event(void) void sref_counter_init(struct sref_counter *counter, + unsigned long init_value, struct sref_weakref *weakref, sref_noref_fn_t noref_fn) { + assert(init_value != 0); + counter->noref_fn = noref_fn; spinlock_init(&counter->lock); counter->flags = 0; - counter->value = 1; + counter->value = init_value; counter->weakref = weakref; if (weakref) { -- cgit v1.2.3