Simplify the device-activation hook. Move some of the device
deactivation to the detachment routine, where it belongs.
This commit is contained in:
parent
43bac9730d
commit
3dedfc004f
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sscom.c,v 1.30 2009/11/21 20:32:28 rmind Exp $ */
|
||||
/* $NetBSD: sscom.c,v 1.31 2009/12/06 21:35:05 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002, 2003 Fujitsu Component Limited
|
||||
|
@ -98,7 +98,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sscom.c,v 1.30 2009/11/21 20:32:28 rmind Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sscom.c,v 1.31 2009/12/06 21:35:05 dyoung Exp $");
|
||||
|
||||
#include "opt_sscom.h"
|
||||
#include "opt_ddb.h"
|
||||
|
@ -509,41 +509,28 @@ sscom_attach_subr(struct sscom_softc *sc)
|
|||
}
|
||||
|
||||
int
|
||||
sscom_detach(struct device *self, int flags)
|
||||
sscom_detach(device_t self, int flags)
|
||||
{
|
||||
if (sc->sc_hwflags & (SSCOM_HW_CONSOLE|SSCOM_HW_KGDB))
|
||||
return EBUSY;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
sscom_activate(struct device *self, enum devact act)
|
||||
sscom_activate(device_t self, enum devact act)
|
||||
{
|
||||
#ifdef notyet
|
||||
struct sscom_softc *sc = (struct sscom_softc *)self;
|
||||
int s, rv = 0;
|
||||
struct sscom_softc *sc = device_private(self);
|
||||
|
||||
s = splserial();
|
||||
SSCOM_LOCK(sc);
|
||||
switch (act) {
|
||||
case DVACT_ACTIVATE:
|
||||
rv = EOPNOTSUPP;
|
||||
break;
|
||||
|
||||
case DVACT_DEACTIVATE:
|
||||
if (sc->sc_hwflags & (SSCOM_HW_CONSOLE|SSCOM_HW_KGDB)) {
|
||||
rv = EBUSY;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef notyet
|
||||
sc->enabled = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
SSCOM_UNLOCK(sc);
|
||||
splx(s);
|
||||
return rv;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
return 0;
|
||||
default:
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sa11x0_com.c,v 1.45 2009/05/29 14:15:44 rjs Exp $ */
|
||||
/* $NetBSD: sa11x0_com.c,v 1.46 2009/12/06 21:33:45 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999, 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -64,7 +64,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sa11x0_com.c,v 1.45 2009/05/29 14:15:44 rjs Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sa11x0_com.c,v 1.46 2009/12/06 21:33:45 dyoung Exp $");
|
||||
|
||||
#include "opt_com.h"
|
||||
#include "opt_ddb.h"
|
||||
|
@ -352,6 +352,14 @@ sacom_detach(device_t dev, int flags)
|
|||
struct sacom_softc *sc = device_private(dev);
|
||||
int maj, mn;
|
||||
|
||||
if (sc->sc_hwflags & (COM_HW_CONSOLE|COM_HW_KGDB))
|
||||
return EBUSY;
|
||||
|
||||
if (sc->disable != NULL && sc->enabled != 0) {
|
||||
(*sc->disable)(sc);
|
||||
sc->enabled = 0;
|
||||
}
|
||||
|
||||
/* locate the major number */
|
||||
maj = cdevsw_lookup_major(&sacom_cdevsw);
|
||||
|
||||
|
@ -417,31 +425,14 @@ int
|
|||
sacom_activate(device_t dev, enum devact act)
|
||||
{
|
||||
struct sacom_softc *sc = device_private(dev);
|
||||
int s, rv = 0;
|
||||
|
||||
s = splserial();
|
||||
COM_LOCK(sc);
|
||||
switch (act) {
|
||||
case DVACT_ACTIVATE:
|
||||
rv = EOPNOTSUPP;
|
||||
break;
|
||||
|
||||
case DVACT_DEACTIVATE:
|
||||
if (sc->sc_hwflags & (COM_HW_CONSOLE|COM_HW_KGDB)) {
|
||||
rv = EBUSY;
|
||||
break;
|
||||
}
|
||||
|
||||
if (sc->disable != NULL && sc->enabled != 0) {
|
||||
(*sc->disable)(sc);
|
||||
sc->enabled = 0;
|
||||
}
|
||||
break;
|
||||
sc->enabled = 0;
|
||||
return 0;
|
||||
default:
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
COM_UNLOCK(sc);
|
||||
splx(s);
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: plcom.c,v 1.30 2009/11/21 20:32:28 rmind Exp $ */
|
||||
/* $NetBSD: plcom.c,v 1.31 2009/12/06 21:38:42 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 ARM Ltd
|
||||
|
@ -94,7 +94,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.30 2009/11/21 20:32:28 rmind Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: plcom.c,v 1.31 2009/12/06 21:38:42 dyoung Exp $");
|
||||
|
||||
#include "opt_plcom.h"
|
||||
#include "opt_ddb.h"
|
||||
|
@ -471,6 +471,14 @@ plcom_detach(struct device *self, int flags)
|
|||
struct plcom_softc *sc = (struct plcom_softc *)self;
|
||||
int maj, mn;
|
||||
|
||||
if (sc->sc_hwflags & (PLCOM_HW_CONSOLE|PLCOM_HW_KGDB))
|
||||
return EBUSY;
|
||||
|
||||
if (sc->disable != NULL && sc->enabled != 0) {
|
||||
(*sc->disable)(sc);
|
||||
sc->enabled = 0;
|
||||
}
|
||||
|
||||
/* locate the major number */
|
||||
maj = cdevsw_lookup_major(&plcom_cdevsw);
|
||||
|
||||
|
@ -500,34 +508,17 @@ plcom_detach(struct device *self, int flags)
|
|||
}
|
||||
|
||||
int
|
||||
plcom_activate(struct device *self, enum devact act)
|
||||
plcom_activate(device_t self, enum devact act)
|
||||
{
|
||||
struct plcom_softc *sc = (struct plcom_softc *)self;
|
||||
int s, rv = 0;
|
||||
struct plcom_softc *sc = device_private(self);
|
||||
|
||||
s = splserial();
|
||||
PLCOM_LOCK(sc);
|
||||
switch (act) {
|
||||
case DVACT_ACTIVATE:
|
||||
rv = EOPNOTSUPP;
|
||||
break;
|
||||
|
||||
case DVACT_DEACTIVATE:
|
||||
if (sc->sc_hwflags & (PLCOM_HW_CONSOLE|PLCOM_HW_KGDB)) {
|
||||
rv = EBUSY;
|
||||
break;
|
||||
}
|
||||
|
||||
if (sc->disable != NULL && sc->enabled != 0) {
|
||||
(*sc->disable)(sc);
|
||||
sc->enabled = 0;
|
||||
}
|
||||
break;
|
||||
sc->enabled = 0;
|
||||
return 0;
|
||||
default:
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
PLCOM_UNLOCK(sc);
|
||||
splx(s);
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue