Module Name: src
Committed By: pgoyette
Date: Sun Jul 24 05:39:29 UTC 2016
Modified Files:
src/sys/kern [pgoyette-localcount]: subr_autoconf.c
src/sys/sys [pgoyette-localcount]: device.h
Log Message:
Add a device_acquire() for when we need to grab a reference and we
already have a pointer to the device.
To generate a diff of this commit:
cvs rdiff -u -r1.246.2.5 -r1.246.2.6 src/sys/kern/subr_autoconf.c
cvs rdiff -u -r1.149.2.2 -r1.149.2.3 src/sys/sys/device.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/subr_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.246.2.5 src/sys/kern/subr_autoconf.c:1.246.2.6
--- src/sys/kern/subr_autoconf.c:1.246.2.5 Fri Jul 22 12:03:15 2016
+++ src/sys/kern/subr_autoconf.c Sun Jul 24 05:39:29 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.246.2.5 2016/07/22 12:03:15 pgoyette Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.246.2.6 2016/07/24 05:39:29 pgoyette Exp $ */
/*
* Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.246.2.5 2016/07/22 12:03:15 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.246.2.6 2016/07/24 05:39:29 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -2238,6 +2238,19 @@ config_alldevs_exit(struct alldevs_foray
}
/*
+ * device_acquire:
+ *
+ * Acquire a reference to the device.
+ */
+void
+device_acquire(device_t dv)
+{
+
+ if (dv->dv_localcnt != NULL)
+ localcount_acquire(dv->dv_localcnt);
+}
+
+/*
* device_lookup:
*
* Look up a device instance for a given driver.
@@ -2274,7 +2287,7 @@ device_lookup_acquire(cfdriver_t cd, int
else if ((dv = cd->cd_devs[unit]) != NULL && dv->dv_del_gen != 0)
dv = NULL;
if (dv != NULL)
- localcount_acquire(dv->dv_localcnt);
+ device_acquire(dv);
mutex_exit(&alldevs_mtx);
return dv;
@@ -2284,7 +2297,7 @@ device_lookup_acquire(cfdriver_t cd, int
* device_release:
*
* Release the reference that was created by an earlier call to
- * device_lookup_acquire().
+ * device_acquire() or device_lookup_acquire().
*/
void
device_release(device_t dv)
Index: src/sys/sys/device.h
diff -u src/sys/sys/device.h:1.149.2.2 src/sys/sys/device.h:1.149.2.3
--- src/sys/sys/device.h:1.149.2.2 Sat Jul 16 22:06:42 2016
+++ src/sys/sys/device.h Sun Jul 24 05:39:28 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: device.h,v 1.149.2.2 2016/07/16 22:06:42 pgoyette Exp $ */
+/* $NetBSD: device.h,v 1.149.2.3 2016/07/24 05:39:28 pgoyette Exp $ */
/*
* Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -491,6 +491,7 @@ void null_childdetached(device_t, device
device_t device_lookup(cfdriver_t, int);
device_t device_lookup_acquire(cfdriver_t, int);
+void device_acquire(device_t);
void device_release(device_t);
void *device_lookup_private(cfdriver_t, int);
void *device_lookup_private_acquire(cfdriver_t, int);