summaryrefslogtreecommitdiff
path: root/sys/dev/acpi
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2007-10-08 04:15:16 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2007-10-08 04:15:16 +0000
commitd0aa54a0d4ea6a5829f72c5d8e83be3a2600deca (patch)
tree00047cb58ad4a4453db399c255919b5bd3fad9b7 /sys/dev/acpi
parent5fe5ffe7fab12d593fcc5f9f1fe293422159975c (diff)
More simple memset(,0,) -> M_ZERO changes. In this batch move to
size(*p) as the first malloc() parameter where p is declared locally and thus easy to check. Add M_ZERO to gpe_table allocation in acpi.c even though there is no obvious bzero or memset nearby.
Diffstat (limited to 'sys/dev/acpi')
-rw-r--r--sys/dev/acpi/acpi.c15
-rw-r--r--sys/dev/acpi/acpicpu.c9
-rw-r--r--sys/dev/acpi/acpimadt.c8
-rw-r--r--sys/dev/acpi/acpiprt.c5
-rw-r--r--sys/dev/acpi/dsdt.c5
5 files changed, 15 insertions, 27 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index 57a782a2008..136170ad46e 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.90 2007/09/13 20:35:47 mk Exp $ */
+/* $OpenBSD: acpi.c,v 1.91 2007/10/08 04:15:15 krw Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -391,13 +391,12 @@ acpi_attach(struct device *parent, struct device *self, void *aux)
sc->sc_powerbtn = 0;
sc->sc_sleepbtn = 0;
- sc->sc_note = malloc(sizeof(struct klist), M_DEVBUF, M_NOWAIT);
+ 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;
}
- memset(sc->sc_note, 0, sizeof(struct klist));
if (acpi_loadtables(sc, rsdp)) {
printf(": can't load tables\n");
@@ -595,15 +594,12 @@ acpi_attach(struct device *parent, struct device *self, void *aux)
SLIST_INIT(&sc->sc_bat);
TAILQ_FOREACH(dev, &alldevs, dv_list) {
if (!strncmp(dev->dv_xname, "acpiac", strlen("acpiac"))) {
- ac = malloc(sizeof(struct acpi_ac), M_DEVBUF, M_WAITOK);
- memset(ac, 0, sizeof(struct acpi_ac));
+ ac = malloc(sizeof(*ac), M_DEVBUF, M_WAITOK | M_ZERO);
ac->aac_softc = (struct acpiac_softc *)dev;
SLIST_INSERT_HEAD(&sc->sc_ac, ac, aac_link);
}
if (!strncmp(dev->dv_xname, "acpibat", strlen("acpibat"))) {
- bat = malloc(sizeof(struct acpi_bat), M_DEVBUF,
- M_WAITOK);
- memset(bat, 0, sizeof(struct acpi_bat));
+ bat = malloc(sizeof(*bat), M_DEVBUF, M_WAITOK | M_ZERO);
bat->aba_softc = (struct acpibat_softc *)dev;
SLIST_INSERT_HEAD(&sc->sc_bat, bat, aba_link);
}
@@ -1074,8 +1070,7 @@ acpi_init_gpes(struct acpi_softc *sc)
/* Allocate GPE table */
sc->gpe_table = malloc(sc->sc_lastgpe * sizeof(struct gpe_block),
- M_DEVBUF, M_WAITOK);
- memset(sc->gpe_table, 0, sc->sc_lastgpe * sizeof(struct gpe_block));
+ M_DEVBUF, M_WAITOK | M_ZERO);
ngpe = 0;
diff --git a/sys/dev/acpi/acpicpu.c b/sys/dev/acpi/acpicpu.c
index 151f1acd775..95834f2c659 100644
--- a/sys/dev/acpi/acpicpu.c
+++ b/sys/dev/acpi/acpicpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpicpu.c,v 1.26 2007/06/15 22:37:40 gwk Exp $ */
+/* $OpenBSD: acpicpu.c,v 1.27 2007/10/08 04:15:15 krw Exp $ */
/*
* Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
*
@@ -181,8 +181,7 @@ acpicpu_add_cstate(struct acpicpu_softc *sc, int type,
break;
}
- cx = malloc(sizeof(struct acpi_cstate), M_DEVBUF, M_WAITOK);
- memset(cx, 0, sizeof(struct acpi_cstate));
+ cx = malloc(sizeof(*cx), M_DEVBUF, M_WAITOK | M_ZERO);
cx->type = type;
cx->power = power;
@@ -455,9 +454,7 @@ acpicpu_getpss(struct acpicpu_softc *sc)
free(sc->sc_pss, M_DEVBUF);
sc->sc_pss = malloc(res.length * sizeof *sc->sc_pss, M_DEVBUF,
- M_WAITOK);
-
- memset(sc->sc_pss, 0, res.length * sizeof *sc->sc_pss);
+ M_WAITOK | M_ZERO);
for (i = 0; i < res.length; i++) {
sc->sc_pss[i].pss_core_freq = aml_val2int(
diff --git a/sys/dev/acpi/acpimadt.c b/sys/dev/acpi/acpimadt.c
index 195685e1e69..5ab8dd69d53 100644
--- a/sys/dev/acpi/acpimadt.c
+++ b/sys/dev/acpi/acpimadt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpimadt.c,v 1.10 2007/02/21 19:17:23 kettenis Exp $ */
+/* $OpenBSD: acpimadt.c,v 1.11 2007/10/08 04:15:15 krw Exp $ */
/*
* Copyright (c) 2006 Mark Kettenis <kettenis@openbsd.org>
*
@@ -237,11 +237,10 @@ acpimadt_attach(struct device *parent, struct device *self, void *aux)
pin = entry->madt_override.global_int;
apic = ioapic_find_bybase(pin);
- map = malloc(sizeof (struct mp_intr_map), M_DEVBUF, M_NOWAIT);
+ map = malloc(sizeof(*map), M_DEVBUF, M_NOWAIT | M_ZERO);
if (map == NULL)
return;
- memset(map, 0, sizeof *map);
map->ioapic = apic;
map->ioapic_pin = pin - apic->sc_apic_vecbase;
map->bus_pin = entry->madt_override.source;
@@ -293,11 +292,10 @@ acpimadt_attach(struct device *parent, struct device *self, void *aux)
if (apic->sc_pins[pin].ip_map != NULL)
continue;
- map = malloc(sizeof (struct mp_intr_map), M_DEVBUF, M_NOWAIT);
+ map = malloc(sizeof(*map), M_DEVBUF, M_NOWAIT | M_ZERO);
if (map == NULL)
return;
- memset(map, 0, sizeof *map);
map->ioapic = apic;
map->ioapic_pin = pin;
map->bus_pin = pin;
diff --git a/sys/dev/acpi/acpiprt.c b/sys/dev/acpi/acpiprt.c
index 3f5c2658101..5b0d0d4b515 100644
--- a/sys/dev/acpi/acpiprt.c
+++ b/sys/dev/acpi/acpiprt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpiprt.c,v 1.17 2007/09/07 19:48:58 kettenis Exp $ */
+/* $OpenBSD: acpiprt.c,v 1.18 2007/10/08 04:15:15 krw Exp $ */
/*
* Copyright (c) 2006 Mark Kettenis <kettenis@openbsd.org>
*
@@ -215,11 +215,10 @@ acpiprt_prt_add(struct acpiprt_softc *sc, struct aml_value *v)
return;
}
- map = malloc(sizeof (struct mp_intr_map), M_DEVBUF, M_NOWAIT);
+ map = malloc(sizeof(*map), M_DEVBUF, M_NOWAIT | M_ZERO);
if (map == NULL)
return;
- memset(map, 0, sizeof *map);
map->ioapic = apic;
map->ioapic_pin = irq - apic->sc_apic_vecbase;
map->bus_pin = ((addr >> 14) & 0x7c) | (pin & 0x3);
diff --git a/sys/dev/acpi/dsdt.c b/sys/dev/acpi/dsdt.c
index d3e1b34605c..5b3a16d4e01 100644
--- a/sys/dev/acpi/dsdt.c
+++ b/sys/dev/acpi/dsdt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dsdt.c,v 1.89 2007/09/13 03:43:22 weingart Exp $ */
+/* $OpenBSD: dsdt.c,v 1.90 2007/10/08 04:15:15 krw Exp $ */
/*
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
*
@@ -419,12 +419,11 @@ _acpi_os_malloc(size_t size, const char *fn, int line)
{
struct acpi_memblock *sptr;
- sptr = malloc(size+sizeof(*sptr), M_DEVBUF, M_WAITOK);
+ sptr = malloc(size+sizeof(*sptr), M_DEVBUF, M_WAITOK | M_ZERO);
dnprintf(99, "alloc: %x %s:%d\n", sptr, fn, line);
if (sptr) {
acpi_nalloc += size;
sptr->size = size;
- memset(&sptr[1], 0, size);
return &sptr[1];
}
return NULL;