diff options
author | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2010-12-30 05:10:36 +0000 |
---|---|---|
committer | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2010-12-30 05:10:36 +0000 |
commit | f6a5099b44f1218b8b9e6a7c28b5646e4f277942 (patch) | |
tree | 4fc2fbb1913473a71d51900df162170e95c3bdd6 /sys/dev/usb/usbdi.c | |
parent | e707938ee54d291657561650400fae34c1403b14 (diff) |
* add a process reference counting variable to struct usbd_device
* add functions to increment and decrement the reference count, and a
function to wait until the reference count is zero
ok martynas@
Diffstat (limited to 'sys/dev/usb/usbdi.c')
-rw-r--r-- | sys/dev/usb/usbdi.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c index 01e88d93a03..78e80e7c882 100644 --- a/sys/dev/usb/usbdi.c +++ b/sys/dev/usb/usbdi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdi.c,v 1.41 2010/12/06 04:25:27 jakemsr Exp $ */ +/* $OpenBSD: usbdi.c,v 1.42 2010/12/30 05:10:35 jakemsr Exp $ */ /* $NetBSD: usbdi.c,v 1.103 2002/09/27 15:37:38 provos Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */ @@ -97,6 +97,26 @@ usbd_deactivate(usbd_device_handle dev) dev->dying = 1; } +void +usbd_ref_incr(usbd_device_handle dev) +{ + dev->ref_cnt++; +} + +void +usbd_ref_decr(usbd_device_handle dev) +{ + if (--dev->ref_cnt == 0 && dev->dying) + wakeup(&dev->ref_cnt); +} + +void +usbd_ref_wait(usbd_device_handle dev) +{ + while (dev->ref_cnt > 0) + tsleep(&dev->ref_cnt, PWAIT, "usbref", hz * 60); +} + static __inline int usbd_xfer_isread(usbd_xfer_handle xfer) { |