svn commit: r214336 - stable/8/sys/dev/aac
Attilio Rao
attilio at FreeBSD.org
Mon Oct 25 13:01:20 UTC 2010
Author: attilio
Date: Mon Oct 25 13:01:19 2010
New Revision: 214336
URL: http://svn.freebsd.org/changeset/base/214336
Log:
MFC r212661 and r212756:
Implement correct refcounting of cdevsw open/close pair and detach
stopping for it.
Sponsored by: Sandvine Incorporated
Modified:
stable/8/sys/dev/aac/aac.c
stable/8/sys/dev/aac/aacvar.h
Directory Properties:
stable/8/sys/ (props changed)
stable/8/sys/amd64/include/xen/ (props changed)
stable/8/sys/cddl/contrib/opensolaris/ (props changed)
stable/8/sys/contrib/dev/acpica/ (props changed)
stable/8/sys/contrib/pf/ (props changed)
stable/8/sys/dev/xen/xenpci/ (props changed)
Modified: stable/8/sys/dev/aac/aac.c
==============================================================================
--- stable/8/sys/dev/aac/aac.c Mon Oct 25 11:16:50 2010 (r214335)
+++ stable/8/sys/dev/aac/aac.c Mon Oct 25 13:01:19 2010 (r214336)
@@ -189,9 +189,9 @@ static char *aac_describe_code(struct aa
/* 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,
@@ -214,7 +214,6 @@ static struct cdevsw aac_cdevsw = {
.d_version = D_VERSION,
.d_flags = D_NEEDGIANT,
.d_open = aac_open,
- .d_close = aac_close,
.d_ioctl = aac_ioctl,
.d_poll = aac_poll,
.d_name = "aac",
@@ -660,9 +659,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,23 +2800,8 @@ aac_open(struct cdev *dev, int flags, in
sc = dev->si_drv1;
fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
- sc->aac_open_cnt++;
- sc->aac_state |= AAC_STATE_OPEN;
-
- 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, "");
- sc->aac_open_cnt--;
- /* Mark this unit as no longer open */
- if (sc->aac_open_cnt == 0)
- sc->aac_state &= ~AAC_STATE_OPEN;
+ device_busy(sc->aac_dev);
+ devfs_set_cdevpriv(sc, aac_cdevpriv_dtor);
return 0;
}
@@ -3208,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.
*/
Modified: stable/8/sys/dev/aac/aacvar.h
==============================================================================
--- stable/8/sys/dev/aac/aacvar.h Mon Oct 25 11:16:50 2010 (r214335)
+++ stable/8/sys/dev/aac/aacvar.h Mon Oct 25 13:01:19 2010 (r214336)
@@ -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 */
More information about the svn-src-stable
mailing list