Module Name:    src
Committed By:   dyoung
Date:           Sun Dec  6 21:33:45 UTC 2009

Modified Files:
        src/sys/arch/arm/sa11x0: sa11x0_com.c

Log Message:
Simplify the device-activation hook.  Move some of the device
deactivation to the detachment routine, where it belongs.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/arm/sa11x0/sa11x0_com.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/sa11x0/sa11x0_com.c
diff -u src/sys/arch/arm/sa11x0/sa11x0_com.c:1.45 src/sys/arch/arm/sa11x0/sa11x0_com.c:1.46
--- src/sys/arch/arm/sa11x0/sa11x0_com.c:1.45	Fri May 29 14:15:44 2009
+++ src/sys/arch/arm/sa11x0/sa11x0_com.c	Sun Dec  6 21:33:45 2009
@@ -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

Reply via email to