From ab8966e256429272331363b455c817899b0239a3 Mon Sep 17 00:00:00 2001 From: attilio Date: Thu, 16 Sep 2010 17:49:10 +0000 Subject: Implement device unbusying via a cdevpriv destructor. Suggested by: jhb Tested by: Mark Johnston Reviewed by: emaste, jhb MFC after: 10 days X-MFC: r212661 --- sys/dev/aac/aac.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'sys') diff --git a/sys/dev/aac/aac.c b/sys/dev/aac/aac.c index 4ff1640..3071ddf 100644 --- a/sys/dev/aac/aac.c +++ b/sys/dev/aac/aac.c @@ -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; } @@ -3201,6 +3189,21 @@ out: } /* + * 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. */ -- cgit v1.1