From 42ce32175acb0ae5a90d24fc4b798c23bebfbd34 Mon Sep 17 00:00:00 2001 From: pgoyette Date: Sun, 11 Jun 2017 21:54:22 +0000 Subject: [PATCH] Implement xxx_rescan() and xxx_childdet() functions; these will be needed when child device wsbell(4) becomes a separately-loadable module. --- 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(-) diff --git a/sys/dev/isa/spkr_pcppi.c b/sys/dev/isa/spkr_pcppi.c index 39e3c3ed8b3e..ce0117e4eb2c 100644 --- a/sys/dev/isa/spkr_pcppi.c +++ b/sys/dev/isa/spkr_pcppi.c @@ -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) @@ -43,7 +43,7 @@ */ #include -__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 #include @@ -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 flags) 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 --git a/sys/dev/spkr.c b/sys/dev/spkr.c index 48a85221a3b3..f8e85a1884b6 100644 --- a/sys/dev/spkr.c +++ b/sys/dev/spkr.c @@ -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) @@ -43,7 +43,7 @@ */ #include -__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)(device_t, u_int, u_int), 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) { diff --git a/sys/dev/spkr_audio.c b/sys/dev/spkr_audio.c index 769df5fa7c77..c2820c7348c6 100644 --- a/sys/dev/spkr_audio.c +++ b/sys/dev/spkr_audio.c @@ -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 @@ -27,7 +27,7 @@ */ #include -__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 #include @@ -51,14 +51,17 @@ __KERNEL_RCSID(0, "$NetBSD: spkr_audio.c,v 1.5 2017/06/11 03:33:48 nat Exp $"); 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 flags) 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 --git a/sys/dev/spkrvar.h b/sys/dev/spkrvar.h index fdf6bd897613..5a473aec32dc 100644 --- a/sys/dev/spkrvar.h +++ b/sys/dev/spkrvar.h @@ -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 */