Instead of directly referencing a parent device's code (ie, pcppi_bell()
routine), let the parent device pass a pointer to the code (in the aux config data). This allows us to load the spkr module without requiring the pcppi parent device to exist. (The spkr device can also have an audio as parent.)
This commit is contained in:
parent
388744f33f
commit
762cf1319c
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pcppi.c,v 1.44 2015/05/17 05:20:37 pgoyette Exp $ */
|
||||
/* $NetBSD: pcppi.c,v 1.45 2017/06/14 05:01:35 pgoyette Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
|
@ -28,7 +28,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: pcppi.c,v 1.44 2015/05/17 05:20:37 pgoyette Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: pcppi.c,v 1.45 2017/06/14 05:01:35 pgoyette Exp $");
|
||||
|
||||
#include "attimer.h"
|
||||
|
||||
|
@ -246,6 +246,7 @@ pcppi_rescan(device_t self, const char *ifattr, const int *flags)
|
|||
return 0;
|
||||
|
||||
pa.pa_cookie = sc;
|
||||
pa.pa_bell_func = pcppi_bell;
|
||||
config_search_loc(pcppisearch, sc->sc_dv, "pcppi", NULL, &pa);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pcppivar.h,v 1.11 2011/11/23 23:07:32 jmcneill Exp $ */
|
||||
/* $NetBSD: pcppivar.h,v 1.12 2017/06/14 05:01:35 pgoyette Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||
|
@ -34,6 +34,7 @@ typedef void *pcppi_tag_t;
|
|||
|
||||
struct pcppi_attach_args {
|
||||
pcppi_tag_t pa_cookie;
|
||||
void (*pa_bell_func)(pcppi_tag_t, int, int, int);
|
||||
};
|
||||
|
||||
struct pcppi_softc {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: spkr_pcppi.c,v 1.10 2017/06/11 21:54:22 pgoyette Exp $ */
|
||||
/* $NetBSD: spkr_pcppi.c,v 1.11 2017/06/14 05:01:35 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.10 2017/06/11 21:54:22 pgoyette Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: spkr_pcppi.c,v 1.11 2017/06/14 05:01:35 pgoyette Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -66,6 +66,7 @@ __KERNEL_RCSID(0, "$NetBSD: spkr_pcppi.c,v 1.10 2017/06/11 21:54:22 pgoyette Exp
|
|||
struct spkr_pcppi_softc {
|
||||
struct spkr_softc sc_spkr;
|
||||
pcppi_tag_t sc_pcppicookie;
|
||||
void (*sc_bell_func)(pcppi_tag_t, int, int, int);
|
||||
};
|
||||
|
||||
static int spkr_pcppi_probe(device_t, cfdata_t, void *);
|
||||
|
@ -88,7 +89,7 @@ spkr_pcppi_tone(device_t self, u_int xhz, u_int ticks)
|
|||
aprint_debug_dev(self, "%s: %u %u\n", __func__, xhz, ticks);
|
||||
#endif /* SPKRDEBUG */
|
||||
struct spkr_pcppi_softc *sc = device_private(self);
|
||||
pcppi_bell(sc->sc_pcppicookie, xhz, ticks, PCPPI_BELL_SLEEP);
|
||||
(*sc->sc_bell_func)(sc->sc_pcppicookie, xhz, ticks, PCPPI_BELL_SLEEP);
|
||||
}
|
||||
|
||||
/* rest for given number of ticks */
|
||||
|
@ -123,6 +124,7 @@ spkr_pcppi_attach(device_t parent, device_t self, void *aux)
|
|||
aprint_normal(": PC Speaker\n");
|
||||
|
||||
sc->sc_pcppicookie = pa->pa_cookie;
|
||||
sc->sc_bell_func = pa->pa_bell_func;
|
||||
spkr_attach(self, spkr_pcppi_tone, spkr_pcppi_rest);
|
||||
if (!pmf_device_register(self, NULL, NULL))
|
||||
aprint_error_dev(self, "couldn't establish power handler\n");
|
||||
|
|
Loading…
Reference in New Issue