Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Implement xxx_rescan() and xxx_childdet() functions; ...



details:   https://anonhg.NetBSD.org/src/rev/f72bbae79d08
branches:  trunk
changeset: 824623:f72bbae79d08
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sun Jun 11 21:54:22 2017 +0000

description:
Implement xxx_rescan() and xxx_childdet() functions; these will be
needed when child device wsbell(4) becomes a separately-loadable
module.

diffstat:

 sys/dev/isa/spkr_pcppi.c |  25 +++++++++++++++++++++----
 sys/dev/spkr.c           |  39 +++++++++++++++++++++++++++++++--------
 sys/dev/spkr_audio.c     |  25 +++++++++++++++++++++----
 sys/dev/spkrvar.h        |   6 +++++-
 4 files changed, 78 insertions(+), 17 deletions(-)

diffs (193 lines):

diff -r 5c6b9c9f31fe -r f72bbae79d08 sys/dev/isa/spkr_pcppi.c
--- a/sys/dev/isa/spkr_pcppi.c  Sun Jun 11 21:45:28 2017 +0000
+++ b/sys/dev/isa/spkr_pcppi.c  Sun Jun 11 21:54:22 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spkr_pcppi.c,v 1.9 2017/01/06 09:32:08 pgoyette Exp $  */
+/*     $NetBSD: spkr_pcppi.c,v 1.10 2017/06/11 21:54:22 pgoyette Exp $ */
 
 /*
  * Copyright (c) 1990 Eric S. Raymond (esr%snark.thyrsus.com@localhost)
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spkr_pcppi.c,v 1.9 2017/01/06 09:32:08 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spkr_pcppi.c,v 1.10 2017/06/11 21:54:22 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -71,9 +71,12 @@
 static int spkr_pcppi_probe(device_t, cfdata_t, void *);
 static void spkr_pcppi_attach(device_t, device_t, void *);
 static int spkr_pcppi_detach(device_t, int);
+static int spkr_pcppi_rescan(device_t, const char *, const int *);
+static void spkr_pcppi_childdet(device_t, device_t);
 
-CFATTACH_DECL_NEW(spkr_pcppi, sizeof(struct spkr_pcppi_softc),
-    spkr_pcppi_probe, spkr_pcppi_attach, spkr_pcppi_detach, NULL);
+CFATTACH_DECL3_NEW(spkr_pcppi, sizeof(struct spkr_pcppi_softc),
+    spkr_pcppi_probe, spkr_pcppi_attach, spkr_pcppi_detach, NULL,
+    spkr_pcppi_rescan, spkr_pcppi_childdet, 0);
 
 #define SPKRPRI (PZERO - 1)
 
@@ -138,3 +141,17 @@
        pmf_device_deregister(self);
        return 0;
 }
+
+static int
+spkr_pcppi_rescan(device_t self, const char *iattr, const int *locators)
+{
+
+       return spkr_rescan(self, iattr, locators);
+}
+
+static void
+spkr_pcppi_childdet(device_t self, device_t child)
+{
+
+       spkr_childdet(self, child);
+}
diff -r 5c6b9c9f31fe -r f72bbae79d08 sys/dev/spkr.c
--- a/sys/dev/spkr.c    Sun Jun 11 21:45:28 2017 +0000
+++ b/sys/dev/spkr.c    Sun Jun 11 21:54:22 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spkr.c,v 1.11 2017/06/11 09:41:40 pgoyette Exp $       */
+/*     $NetBSD: spkr.c,v 1.12 2017/06/11 21:54:22 pgoyette Exp $       */
 
 /*
  * Copyright (c) 1990 Eric S. Raymond (esr%snark.thyrsus.com@localhost)
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spkr.c,v 1.11 2017/06/11 09:41:40 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spkr.c,v 1.12 2017/06/11 21:54:22 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "wsmux.h"
@@ -372,13 +372,9 @@
        sc->sc_tone = tone;
        sc->sc_rest = rest;
        sc->sc_inbuf = NULL;
-
-#if (NWSMUX > 0)
-       struct wsbelldev_attach_args a;
+       sc->sc_wsbelldev = NULL;
 
-       a.accesscookie = sc;
-       sc->sc_wsbelldev = config_found(self, &a, wsbelldevprint);
-#endif
+       spkr_rescan(self, "", NULL);
 }
 
 int
@@ -397,6 +393,33 @@
        return 0;
 }
 
+/* ARGSUSED */
+int
+spkr_rescan(device_t self, const char *iattr, const int *locators)
+{
+#if NWSMUX > 0
+       struct spkr_softc *sc = device_private(self);
+       struct wsbelldev_attach_args a;
+
+       if (sc->sc_wsbelldev == NULL) {
+               a.accesscookie = sc;
+               sc->sc_wsbelldev = config_found(self, &a, wsbelldevprint);
+       }
+#endif
+       return 0;
+}
+
+int
+spkr_childdet(device_t self, device_t child)
+{
+       struct spkr_softc *sc = device_private(self);
+
+       if (sc->sc_wsbelldev == child)
+               sc->sc_wsbelldev = NULL;
+
+       return 0;
+}
+
 int
 spkropen(dev_t dev, int        flags, int mode, struct lwp *l)
 {
diff -r 5c6b9c9f31fe -r f72bbae79d08 sys/dev/spkr_audio.c
--- a/sys/dev/spkr_audio.c      Sun Jun 11 21:45:28 2017 +0000
+++ b/sys/dev/spkr_audio.c      Sun Jun 11 21:54:22 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spkr_audio.c,v 1.5 2017/06/11 03:33:48 nat Exp $       */
+/*     $NetBSD: spkr_audio.c,v 1.6 2017/06/11 21:54:22 pgoyette Exp $  */
 
 /*-
  * Copyright (c) 2016 Nathanial Sloss <nathanialsloss%yahoo.com.au@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spkr_audio.c,v 1.5 2017/06/11 03:33:48 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spkr_audio.c,v 1.6 2017/06/11 21:54:22 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -51,14 +51,17 @@
 static int spkr_audio_probe(device_t, cfdata_t, void *);
 static void spkr_audio_attach(device_t, device_t, void *);
 static int spkr_audio_detach(device_t, int);
+static int spkr_audio_rescan(device_t, const char *, const int *);
+static void spkr_audio_childdet(device_t, device_t);
 
 struct spkr_audio_softc {
        struct spkr_softc sc_spkr;
        device_t                sc_audiodev;
 };
 
-CFATTACH_DECL_NEW(spkr_audio, sizeof(struct spkr_audio_softc),
-    spkr_audio_probe, spkr_audio_attach, spkr_audio_detach, NULL);
+CFATTACH_DECL3_NEW(spkr_audio, sizeof(struct spkr_audio_softc),
+    spkr_audio_probe, spkr_audio_attach, spkr_audio_detach, NULL,
+    spkr_audio_rescan, spkr_audio_childdet, 0);
 
 static void
 spkr_audio_tone(device_t self, u_int xhz, u_int ticks)
@@ -121,3 +124,17 @@
 
        return 0;
 }
+
+static int 
+spkr_audio_rescan(device_t self, const char *iattr, const int *locators)
+{
+
+       return spkr_rescan(self, iattr, locators);
+}
+
+static void 
+spkr_audio_childdet(device_t self, device_t child)
+{
+ 
+       spkr_childdet(self, child);
+}
diff -r 5c6b9c9f31fe -r f72bbae79d08 sys/dev/spkrvar.h
--- a/sys/dev/spkrvar.h Sun Jun 11 21:45:28 2017 +0000
+++ b/sys/dev/spkrvar.h Sun Jun 11 21:54:22 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: spkrvar.h,v 1.8 2017/06/11 03:55:56 nat Exp $ */
+/* $NetBSD: spkrvar.h,v 1.9 2017/06/11 21:54:22 pgoyette Exp $ */
 
 #ifndef _SYS_DEV_SPKRVAR_H
 #define _SYS_DEV_SPKRVAR_H
@@ -27,4 +27,8 @@
 
 int spkr_detach(device_t, int);
 
+int spkr_rescan(device_t, const char *, const int *);
+
+int spkr_childdet(device_t, device_t);
+
 #endif /* _SYS_DEV_SPKRVAR_H */



Home | Main Index | Thread Index | Old Index