diff options
Diffstat (limited to 'sys/dev/bktr/bktr_os.c')
-rw-r--r-- | sys/dev/bktr/bktr_os.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/dev/bktr/bktr_os.c b/sys/dev/bktr/bktr_os.c index 327c4bbdb959..1fd458cd3c10 100644 --- a/sys/dev/bktr/bktr_os.c +++ b/sys/dev/bktr/bktr_os.c @@ -597,7 +597,9 @@ bktr_open( struct cdev *dev, int flags, int fmt, struct thread *td ) return( ENXIO ); /* Record that the device is now busy */ + newbus_xlock(); device_busy(devclass_get_device(bktr_devclass, unit)); + newbus_xunlock(); if (bt848_card != -1) { @@ -668,8 +670,11 @@ bktr_open( struct cdev *dev, int flags, int fmt, struct thread *td ) } /* If there was an error opening the device, undo the busy status */ - if (result != 0) + if (result != 0) { + newbus_xlock(); device_unbusy(devclass_get_device(bktr_devclass, unit)); + newbus_xunlock(); + } return( result ); } @@ -689,6 +694,7 @@ bktr_close( struct cdev *dev, int flags, int fmt, struct thread *td ) /* Get the device data */ bktr = (struct bktr_softc*)devclass_get_softc(bktr_devclass, unit); if (bktr == NULL) { + /* the device is no longer valid/functioning */ return (ENXIO); } @@ -705,10 +711,11 @@ bktr_close( struct cdev *dev, int flags, int fmt, struct thread *td ) break; default: return (ENXIO); - break; } + newbus_xlock(); device_unbusy(devclass_get_device(bktr_devclass, unit)); + newbus_xunlock(); return( result ); } |