summaryrefslogtreecommitdiffstats
path: root/sys/dev/aac
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2010-09-15 14:24:21 +0000
committerattilio <attilio@FreeBSD.org>2010-09-15 14:24:21 +0000
commit2eb7a3903b20124b8ceeb1f1e6ad876cb0c59610 (patch)
treedfe56a0618424f9d7219c9f0cbd2ef0b62fb9d2d /sys/dev/aac
parent02ebb2e3c38267fc34892380ab39bf7a031c073b (diff)
downloadFreeBSD-src-2eb7a3903b20124b8ceeb1f1e6ad876cb0c59610.zip
FreeBSD-src-2eb7a3903b20124b8ceeb1f1e6ad876cb0c59610.tar.gz
Fix bogus busying mechanism from cdevsw callbacks:
- D_TRACKCLOSE may be used there as d_close() are expected to match up d_open() calls - Replace the hand-crafted counter and flag with the device_busy()/device_unbusy() proper usage. Sponsored by: Sandvine Incorporated Reported by: Mark Johnston <mjohnston at sandvine dot com> Tested by: Mark Johnston Reviewed by: emaste MFC after: 10 days
Diffstat (limited to 'sys/dev/aac')
-rw-r--r--sys/dev/aac/aac.c13
-rw-r--r--sys/dev/aac/aacvar.h3
2 files changed, 4 insertions, 12 deletions
diff --git a/sys/dev/aac/aac.c b/sys/dev/aac/aac.c
index 3699617..4ff1640 100644
--- a/sys/dev/aac/aac.c
+++ b/sys/dev/aac/aac.c
@@ -212,7 +212,7 @@ static struct aac_mntinforesp *
static struct cdevsw aac_cdevsw = {
.d_version = D_VERSION,
- .d_flags = D_NEEDGIANT,
+ .d_flags = D_NEEDGIANT | D_TRACKCLOSE,
.d_open = aac_open,
.d_close = aac_close,
.d_ioctl = aac_ioctl,
@@ -660,9 +660,6 @@ aac_detach(device_t dev)
sc = device_get_softc(dev);
fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
- if (sc->aac_state & AAC_STATE_OPEN)
- return(EBUSY);
-
callout_drain(&sc->aac_daemontime);
/* Remove the child containers */
@@ -2804,8 +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, "");
- sc->aac_open_cnt++;
- sc->aac_state |= AAC_STATE_OPEN;
+ device_busy(sc->aac_dev);
return 0;
}
@@ -2817,10 +2813,7 @@ aac_close(struct cdev *dev, int flags, int fmt, struct thread *td)
sc = dev->si_drv1;
fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
- sc->aac_open_cnt--;
- /* Mark this unit as no longer open */
- if (sc->aac_open_cnt == 0)
- sc->aac_state &= ~AAC_STATE_OPEN;
+ device_unbusy(sc->aac_dev);
return 0;
}
diff --git a/sys/dev/aac/aacvar.h b/sys/dev/aac/aacvar.h
index 29eb816..192616b 100644
--- a/sys/dev/aac/aacvar.h
+++ b/sys/dev/aac/aacvar.h
@@ -319,10 +319,9 @@ struct aac_softc
/* controller features, limits and status */
int aac_state;
#define AAC_STATE_SUSPEND (1<<0)
-#define AAC_STATE_OPEN (1<<1)
+#define AAC_STATE_UNUSED0 (1<<1)
#define AAC_STATE_INTERRUPTS_ON (1<<2)
#define AAC_STATE_AIF_SLEEPER (1<<3)
- int aac_open_cnt;
struct FsaRevision aac_revision;
/* controller hardware interface */
OpenPOWER on IntegriCloud