Implement device unbusying via a cdevpriv destructor.

Suggested by:	jhb
Tested by:	Mark Johnston <mjohnston at sandvine dot com>
Reviewed by:	emaste, jhb
MFC after:	10 days
X-MFC:		r212661
This commit is contained in:
Attilio Rao 2010-09-16 17:49:10 +00:00
parent 767c3593eb
commit dfe2c294f3

View File

@ -189,9 +189,9 @@ static char *aac_describe_code(struct aac_code_lookup *table,
/* Management Interface */
static d_open_t aac_open;
static d_close_t aac_close;
static d_ioctl_t aac_ioctl;
static d_poll_t aac_poll;
static void aac_cdevpriv_dtor(void *arg);
static int aac_ioctl_sendfib(struct aac_softc *sc, caddr_t ufib);
static int aac_ioctl_send_raw_srb(struct aac_softc *sc, caddr_t arg);
static void aac_handle_aif(struct aac_softc *sc,
@ -212,9 +212,8 @@ static struct aac_mntinforesp *
static struct cdevsw aac_cdevsw = {
.d_version = D_VERSION,
.d_flags = D_NEEDGIANT | D_TRACKCLOSE,
.d_flags = D_NEEDGIANT,
.d_open = aac_open,
.d_close = aac_close,
.d_ioctl = aac_ioctl,
.d_poll = aac_poll,
.d_name = "aac",
@ -2802,18 +2801,7 @@ aac_open(struct cdev *dev, int flags, int fmt, struct thread *td)
sc = dev->si_drv1;
fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
device_busy(sc->aac_dev);
return 0;
}
static int
aac_close(struct cdev *dev, int flags, int fmt, struct thread *td)
{
struct aac_softc *sc;
sc = dev->si_drv1;
fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
device_unbusy(sc->aac_dev);
devfs_set_cdevpriv(sc, aac_cdevpriv_dtor);
return 0;
}
@ -3200,6 +3188,21 @@ aac_ioctl_send_raw_srb(struct aac_softc *sc, caddr_t arg)
return(error);
}
/*
* cdevpriv interface private destructor.
*/
static void
aac_cdevpriv_dtor(void *arg)
{
struct aac_softc *sc;
sc = arg;
fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
mtx_lock(&Giant);
device_unbusy(sc->aac_dev);
mtx_unlock(&Giant);
}
/*
* Handle an AIF sent to us by the controller; queue it for later reference.
* If the queue fills up, then drop the older entries.