Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Simplify the device-activation hook. Move some of ...
details: https://anonhg.NetBSD.org/src/rev/08554ff1b112
branches: trunk
changeset: 749730:08554ff1b112
user: dyoung <dyoung%NetBSD.org@localhost>
date: Sun Dec 06 21:33:45 2009 +0000
description:
Simplify the device-activation hook. Move some of the device
deactivation to the detachment routine, where it belongs.
diffstat:
sys/arch/arm/s3c2xx0/sscom.c | 39 ++++++++++++-------------------------
sys/arch/arm/sa11x0/sa11x0_com.c | 37 +++++++++++++----------------------
sys/arch/evbarm/dev/plcom.c | 41 +++++++++++++++------------------------
3 files changed, 43 insertions(+), 74 deletions(-)
diffs (214 lines):
diff -r b7cc2461f626 -r 08554ff1b112 sys/arch/arm/s3c2xx0/sscom.c
--- a/sys/arch/arm/s3c2xx0/sscom.c Sun Dec 06 20:26:55 2009 +0000
+++ b/sys/arch/arm/s3c2xx0/sscom.c Sun Dec 06 21:33:45 2009 +0000
@@ -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 @@
}
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;
+#endif
+ return 0;
+ default:
+ return EOPNOTSUPP;
}
-
- SSCOM_UNLOCK(sc);
- splx(s);
- return rv;
-#else
- return 0;
-#endif
}
void
diff -r b7cc2461f626 -r 08554ff1b112 sys/arch/arm/sa11x0/sa11x0_com.c
--- a/sys/arch/arm/sa11x0/sa11x0_com.c Sun Dec 06 20:26:55 2009 +0000
+++ b/sys/arch/arm/sa11x0/sa11x0_com.c Sun Dec 06 21:33:45 2009 +0000
@@ -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 @@
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 @@
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
diff -r b7cc2461f626 -r 08554ff1b112 sys/arch/evbarm/dev/plcom.c
--- a/sys/arch/evbarm/dev/plcom.c Sun Dec 06 20:26:55 2009 +0000
+++ b/sys/arch/evbarm/dev/plcom.c Sun Dec 06 21:33:45 2009 +0000
@@ -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 @@
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 @@
}
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
Home |
Main Index |
Thread Index |
Old Index