Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/pgoyette-localcount]: src/sys Add a device_acquire() for when we need to...



details:   https://anonhg.NetBSD.org/src/rev/be71de271218
branches:  pgoyette-localcount
changeset: 852856:be71de271218
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sun Jul 24 05:39:28 2016 +0000

description:
Add a device_acquire() for when we need to grab a reference and we
already have a pointer to the device.

diffstat:

 sys/kern/subr_autoconf.c |  21 +++++++++++++++++----
 sys/sys/device.h         |   3 ++-
 2 files changed, 19 insertions(+), 5 deletions(-)

diffs (73 lines):

diff -r f5c6c010c14c -r be71de271218 sys/kern/subr_autoconf.c
--- a/sys/kern/subr_autoconf.c  Sun Jul 24 00:14:08 2016 +0000
+++ b/sys/kern/subr_autoconf.c  Sun Jul 24 05:39:28 2016 +0000
@@ -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 @@
 }
 
 /*
+ * 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 @@
        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_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)
diff -r f5c6c010c14c -r be71de271218 sys/sys/device.h
--- a/sys/sys/device.h  Sun Jul 24 00:14:08 2016 +0000
+++ b/sys/sys/device.h  Sun Jul 24 05:39:28 2016 +0000
@@ -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 @@
 
 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);



Home | Main Index | Thread Index | Old Index