Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Simplify these device-activation hooks using the fol...



details:   https://anonhg.NetBSD.org/src/rev/d248c6d7b0a3
branches:  trunk
changeset: 749735:d248c6d7b0a3
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Sun Dec 06 22:42:48 2009 +0000

description:
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);
}

diffstat:

 sys/dev/audio.c |  17 +++++++----------
 sys/dev/midi.c  |  12 +++++-------
 sys/dev/radio.c |  12 +++++-------
 sys/dev/video.c |  15 ++++++---------
 4 files changed, 23 insertions(+), 33 deletions(-)

diffs (154 lines):

diff -r 0cbca958874b -r d248c6d7b0a3 sys/dev/audio.c
--- a/sys/dev/audio.c   Sun Dec 06 22:40:56 2009 +0000
+++ b/sys/dev/audio.c   Sun Dec 06 22:42:48 2009 +0000
@@ -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;
-
-       sc = device_private(self);
+       struct audio_softc *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
diff -r 0cbca958874b -r d248c6d7b0a3 sys/dev/midi.c
--- a/sys/dev/midi.c    Sun Dec 06 22:40:56 2009 +0000
+++ b/sys/dev/midi.c    Sun Dec 06 22:42:48 2009 +0000
@@ -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
diff -r 0cbca958874b -r d248c6d7b0a3 sys/dev/radio.c
--- a/sys/dev/radio.c   Sun Dec 06 22:40:56 2009 +0000
+++ b/sys/dev/radio.c   Sun Dec 06 22:42:48 2009 +0000
@@ -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);
 }
diff -r 0cbca958874b -r d248c6d7b0a3 sys/dev/video.c
--- a/sys/dev/video.c   Sun Dec 06 22:40:56 2009 +0000
+++ b/sys/dev/video.c   Sun Dec 06 22:42:48 2009 +0000
@@ -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 <pat%polycrystal.org@localhost>
@@ -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;
 }
 
 



Home | Main Index | Thread Index | Old Index