> Date: Wed, 9 Feb 2022 15:24:19 +0000
> From: Visa Hankala <[email protected]>
>
> This embeds klist head in struct acpi_softc so that explicit malloc is
> not needed. The head is initialized as part of acpi_softc allocation.
>
> OK?
ok kettenis@
> Index: dev/acpi/acpi.c
> ===================================================================
> RCS file: src/sys/dev/acpi/acpi.c,v
> retrieving revision 1.410
> diff -u -p -r1.410 acpi.c
> --- dev/acpi/acpi.c 8 Feb 2022 17:25:12 -0000 1.410
> +++ dev/acpi/acpi.c 9 Feb 2022 15:12:22 -0000
> @@ -1016,16 +1016,6 @@ acpi_attach_common(struct acpi_softc *sc
> SIMPLEQ_INIT(&sc->sc_pwrresdevs);
> #endif /* NACPIPWRRES > 0 */
>
> -
> -#ifndef SMALL_KERNEL
> - sc->sc_note = malloc(sizeof(struct klist), M_DEVBUF, M_NOWAIT | M_ZERO);
> - if (sc->sc_note == NULL) {
> - printf(": can't allocate memory\n");
> - acpi_unmap(&handle);
> - return;
> - }
> -#endif /* SMALL_KERNEL */
> -
> if (acpi_loadtables(sc, rsdp)) {
> printf(": can't load tables\n");
> acpi_unmap(&handle);
> @@ -3467,7 +3457,7 @@ acpi_record_event(struct acpi_softc *sc,
> return (1);
>
> acpi_evindex++;
> - KNOTE(sc->sc_note, APM_EVENT_COMPOSE(type, acpi_evindex));
> + KNOTE(&sc->sc_note, APM_EVENT_COMPOSE(type, acpi_evindex));
> return (0);
> }
>
> @@ -3478,7 +3468,7 @@ acpi_filtdetach(struct knote *kn)
> int s;
>
> s = splbio();
> - klist_remove_locked(sc->sc_note, kn);
> + klist_remove_locked(&sc->sc_note, kn);
> splx(s);
> }
>
> @@ -3512,7 +3502,7 @@ acpikqfilter(dev_t dev, struct knote *kn
> kn->kn_hook = sc;
>
> s = splbio();
> - klist_insert_locked(sc->sc_note, kn);
> + klist_insert_locked(&sc->sc_note, kn);
> splx(s);
>
> return (0);
> Index: dev/acpi/acpivar.h
> ===================================================================
> RCS file: src/sys/dev/acpi/acpivar.h,v
> retrieving revision 1.118
> diff -u -p -r1.118 acpivar.h
> --- dev/acpi/acpivar.h 8 Feb 2022 17:25:12 -0000 1.118
> +++ dev/acpi/acpivar.h 9 Feb 2022 15:12:22 -0000
> @@ -23,6 +23,7 @@
>
> #ifndef _ACPI_WAKECODE
>
> +#include <sys/event.h>
> #include <sys/timeout.h>
> #include <sys/rwlock.h>
>
> @@ -45,7 +46,6 @@ extern int acpi_debug;
> extern int acpi_hasprocfvs;
> extern int acpi_haspci;
>
> -struct klist;
> struct acpiec_softc;
> struct acpipwrres_softc;
>
> @@ -239,7 +239,7 @@ struct acpi_softc {
> */
> struct acpi_facs *sc_facs; /* Shared with firmware! */
>
> - struct klist *sc_note;
> + struct klist sc_note;
> struct acpi_reg_map sc_pmregs[ACPIREG_MAXREG];
> bus_space_handle_t sc_ioh_pm1a_evt;
>
>
>