Module Name: src Committed By: pgoyette Date: Sun Jun 11 21:54:22 UTC 2017
Modified Files: src/sys/dev: spkr.c spkr_audio.c spkrvar.h src/sys/dev/isa: spkr_pcppi.c Log Message: Implement xxx_rescan() and xxx_childdet() functions; these will be needed when child device wsbell(4) becomes a separately-loadable module. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/spkr.c cvs rdiff -u -r1.5 -r1.6 src/sys/dev/spkr_audio.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/spkrvar.h cvs rdiff -u -r1.9 -r1.10 src/sys/dev/isa/spkr_pcppi.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/spkr.c diff -u src/sys/dev/spkr.c:1.11 src/sys/dev/spkr.c:1.12 --- src/sys/dev/spkr.c:1.11 Sun Jun 11 09:41:40 2017 +++ src/sys/dev/spkr.c Sun Jun 11 21:54:22 2017 @@ -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 (e...@snark.thyrsus.com) @@ -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 @@ spkr_attach(device_t self, void (*tone)( sc->sc_tone = tone; sc->sc_rest = rest; sc->sc_inbuf = NULL; + sc->sc_wsbelldev = NULL; -#if (NWSMUX > 0) - struct wsbelldev_attach_args a; - - a.accesscookie = sc; - sc->sc_wsbelldev = config_found(self, &a, wsbelldevprint); -#endif + spkr_rescan(self, "", NULL); } int @@ -397,6 +393,33 @@ spkr_detach(device_t self, int flags) 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) { Index: src/sys/dev/spkr_audio.c diff -u src/sys/dev/spkr_audio.c:1.5 src/sys/dev/spkr_audio.c:1.6 --- src/sys/dev/spkr_audio.c:1.5 Sun Jun 11 03:33:48 2017 +++ src/sys/dev/spkr_audio.c Sun Jun 11 21:54:22 2017 @@ -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 <nathanialsl...@yahoo.com.au> @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: spkr_audio.c 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 @@ spkr_audio_detach(device_t self, int fla 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); +} Index: src/sys/dev/spkrvar.h diff -u src/sys/dev/spkrvar.h:1.8 src/sys/dev/spkrvar.h:1.9 --- src/sys/dev/spkrvar.h:1.8 Sun Jun 11 03:55:56 2017 +++ src/sys/dev/spkrvar.h Sun Jun 11 21:54:22 2017 @@ -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 @@ void spkr_attach(device_t, 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 */ Index: src/sys/dev/isa/spkr_pcppi.c diff -u src/sys/dev/isa/spkr_pcppi.c:1.9 src/sys/dev/isa/spkr_pcppi.c:1.10 --- src/sys/dev/isa/spkr_pcppi.c:1.9 Fri Jan 6 09:32:08 2017 +++ src/sys/dev/isa/spkr_pcppi.c Sun Jun 11 21:54:22 2017 @@ -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 (e...@snark.thyrsus.com) @@ -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 @@ struct spkr_pcppi_softc { 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 @@ spkr_pcppi_detach(device_t self, int fla 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); +}