Implement xxx_rescan() and xxx_childdet() functions; these will be

needed when child device wsbell(4) becomes a separately-loadable
module.
This commit is contained in:
pgoyette 2017-06-11 21:54:22 +00:00
parent 5b782bb9ef
commit 42ce32175a
4 changed files with 78 additions and 17 deletions

View File

@ -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 <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 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);
}

View File

@ -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 <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)(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)
{

View File

@ -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>
@ -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,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);
}

View File

@ -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 */