Module Name:    src
Committed By:   dyoung
Date:           Sun Dec  6 22:42:48 UTC 2009

Modified Files:
        src/sys/dev: audio.c midi.c radio.c video.c

Log Message:
Simplify these device-activation hooks using the following semantic
patch.

XXX sc_dying must die.

@@
type device_t;

identifier act, midi_softc, midiactivate, sc, self;
@@

int
midiactivate(device_t self, enum devact act)
{
(
        struct midi_softc *sc = device_private(self);
|
-       struct midi_softc *sc;
+       struct midi_softc *sc = device_private(self);
...
-       sc = device_private(self);
)
...
        switch (act) {
-       case DVACT_ACTIVATE:
-               return (EOPNOTSUPP);
-
        case DVACT_DEACTIVATE:
(
        sc->dying
|
        sc->sc_dying
)
                =
(
        1
|
        true
)
                ;
-               break;
+               return 0;
+       default:
+               return EOPNOTSUPP;
        }
-       return (0);
}


To generate a diff of this commit:
cvs rdiff -u -r1.248 -r1.249 src/sys/dev/audio.c
cvs rdiff -u -r1.70 -r1.71 src/sys/dev/midi.c
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/radio.c src/sys/dev/video.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/dev/audio.c
diff -u src/sys/dev/audio.c:1.248 src/sys/dev/audio.c:1.249
--- src/sys/dev/audio.c:1.248	Tue Sep 29 15:58:54 2009
+++ src/sys/dev/audio.c	Sun Dec  6 22:42:48 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.248 2009/09/29 15:58:54 sborrill Exp $	*/
+/*	$NetBSD: audio.c,v 1.249 2009/12/06 22:42:48 dyoung Exp $	*/
 
 /*
  * Copyright (c) 1991-1993 Regents of the University of California.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.248 2009/09/29 15:58:54 sborrill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.249 2009/12/06 22:42:48 dyoung Exp $");
 
 #include "audio.h"
 #if NAUDIO > 0
@@ -538,18 +538,15 @@
 int
 audioactivate(device_t self, enum devact act)
 {
-	struct audio_softc *sc;
+	struct audio_softc *sc = device_private(self);
 
-	sc = device_private(self);
 	switch (act) {
-	case DVACT_ACTIVATE:
-		return EOPNOTSUPP;
-
 	case DVACT_DEACTIVATE:
 		sc->sc_dying = true;
-		break;
+		return 0;
+	default:
+		return EOPNOTSUPP;
 	}
-	return 0;
 }
 
 int

Index: src/sys/dev/midi.c
diff -u src/sys/dev/midi.c:1.70 src/sys/dev/midi.c:1.71
--- src/sys/dev/midi.c:1.70	Sun Aug 23 15:56:07 2009
+++ src/sys/dev/midi.c	Sun Dec  6 22:42:48 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: midi.c,v 1.70 2009/08/23 15:56:07 jmcneill Exp $	*/
+/*	$NetBSD: midi.c,v 1.71 2009/12/06 22:42:48 dyoung Exp $	*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.70 2009/08/23 15:56:07 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.71 2009/12/06 22:42:48 dyoung Exp $");
 
 #include "midi.h"
 #include "sequencer.h"
@@ -175,14 +175,12 @@
 	struct midi_softc *sc = device_private(self);
 
 	switch (act) {
-	case DVACT_ACTIVATE:
-		return (EOPNOTSUPP);
-
 	case DVACT_DEACTIVATE:
 		sc->dying = 1;
-		break;
+		return 0;
+	default:
+		return EOPNOTSUPP;
 	}
-	return (0);
 }
 
 int

Index: src/sys/dev/radio.c
diff -u src/sys/dev/radio.c:1.22 src/sys/dev/radio.c:1.23
--- src/sys/dev/radio.c:1.22	Wed Jul  9 13:12:54 2008
+++ src/sys/dev/radio.c	Sun Dec  6 22:42:48 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: radio.c,v 1.22 2008/07/09 13:12:54 joerg Exp $ */
+/* $NetBSD: radio.c,v 1.23 2009/12/06 22:42:48 dyoung Exp $ */
 /* $OpenBSD: radio.c,v 1.2 2001/12/05 10:27:06 mickey Exp $ */
 /* $RuOBSD: radio.c,v 1.7 2001/12/04 06:03:05 tm Exp $ */
 
@@ -30,7 +30,7 @@
 /* This is the /dev/radio driver from OpenBSD */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: radio.c,v 1.22 2008/07/09 13:12:54 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radio.c,v 1.23 2009/12/06 22:42:48 dyoung Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -202,12 +202,10 @@
 	struct radio_softc *sc = device_private(self);
 
 	switch (act) {
-	case DVACT_ACTIVATE:
-		return (EOPNOTSUPP);
-
 	case DVACT_DEACTIVATE:
 		sc->sc_dying = 1;
-		break;
+		return 0;
+	default:
+		return EOPNOTSUPP;
 	}
-	return (0);
 }
Index: src/sys/dev/video.c
diff -u src/sys/dev/video.c:1.22 src/sys/dev/video.c:1.23
--- src/sys/dev/video.c:1.22	Tue Aug 18 02:17:09 2009
+++ src/sys/dev/video.c	Sun Dec  6 22:42:48 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: video.c,v 1.22 2009/08/18 02:17:09 christos Exp $ */
+/* $NetBSD: video.c,v 1.23 2009/12/06 22:42:48 dyoung Exp $ */
 
 /*
  * Copyright (c) 2008 Patrick Mahoney <p...@polycrystal.org>
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: video.c,v 1.22 2009/08/18 02:17:09 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: video.c,v 1.23 2009/12/06 22:42:48 dyoung Exp $");
 
 #include "video.h"
 #if NVIDEO > 0
@@ -322,19 +322,16 @@
 static int
 video_activate(device_t self, enum devact act)
 {
-	struct video_softc *sc;
+	struct video_softc *sc = device_private(self);
 
-	sc = device_private(self);
 	DPRINTF(("video_activate: sc=%p\n", sc));
 	switch (act) {
-	case DVACT_ACTIVATE:
-		return EOPNOTSUPP;
-		
 	case DVACT_DEACTIVATE:
 		sc->sc_dying = true;
-		break;
+		return 0;
+	default:
+		return EOPNOTSUPP;
 	}
-	return 0;
 }
 
 

Reply via email to