diff options
author | Marco Peereboom <marco@cvs.openbsd.org> | 2006-12-21 05:53:36 +0000 |
---|---|---|
committer | Marco Peereboom <marco@cvs.openbsd.org> | 2006-12-21 05:53:36 +0000 |
commit | 28e2f582b32dda0147c218c163f66db1440571a9 (patch) | |
tree | cd979ab296854e20a0200981a53b52a23572f813 /sys | |
parent | 87ffd5ba5dae15650d85cc789836ddb8f9da13b7 (diff) |
Remove some more remnants of old acpiec_wait function.
Rename acpiec_wait_nosleep to acpiec_wait since the old sleeping function is
gone anyway.
Redo waiting loop to shave some more bytes of.
Tabing, spacing and some more KNF.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/acpi/acpiec.c | 106 |
1 files changed, 52 insertions, 54 deletions
diff --git a/sys/dev/acpi/acpiec.c b/sys/dev/acpi/acpiec.c index de85850edee..719eb433d12 100644 --- a/sys/dev/acpi/acpiec.c +++ b/sys/dev/acpi/acpiec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpiec.c,v 1.12 2006/12/21 05:24:25 marco Exp $ */ +/* $OpenBSD: acpiec.c,v 1.13 2006/12/21 05:53:35 marco Exp $ */ /* * Copyright (c) 2006 Can Erkin Acar <canacar@openbsd.org> * @@ -32,30 +32,30 @@ #include <sys/sensors.h> -int acpiec_match(struct device *, void *, void *); -void acpiec_attach(struct device *, struct device *, void *); +int acpiec_match(struct device *, void *, void *); +void acpiec_attach(struct device *, struct device *, void *); -u_int8_t acpiec_status(struct acpiec_softc *); -u_int8_t acpiec_read_data(struct acpiec_softc *); -void acpiec_write_cmd(struct acpiec_softc *, u_int8_t); -void acpiec_write_data(struct acpiec_softc *, u_int8_t); -void acpiec_burst_enable(struct acpiec_softc *sc); +u_int8_t acpiec_status(struct acpiec_softc *); +u_int8_t acpiec_read_data(struct acpiec_softc *); +void acpiec_write_cmd(struct acpiec_softc *, u_int8_t); +void acpiec_write_data(struct acpiec_softc *, u_int8_t); +void acpiec_burst_enable(struct acpiec_softc *sc); -u_int8_t acpiec_read_1(struct acpiec_softc *, u_int8_t); -void acpiec_write_1(struct acpiec_softc *, u_int8_t, u_int8_t); +u_int8_t acpiec_read_1(struct acpiec_softc *, u_int8_t); +void acpiec_write_1(struct acpiec_softc *, u_int8_t, u_int8_t); -void acpiec_read(struct acpiec_softc *, u_int8_t, int, u_int8_t *); -void acpiec_write(struct acpiec_softc *, u_int8_t, int, u_int8_t *); +void acpiec_read(struct acpiec_softc *, u_int8_t, int, u_int8_t *); +void acpiec_write(struct acpiec_softc *, u_int8_t, int, u_int8_t *); -int acpiec_getcrs(struct acpiec_softc *, struct acpi_attach_args *); -int acpiec_getregister(const u_int8_t *, int, int *, bus_size_t *); +int acpiec_getcrs(struct acpiec_softc *, struct acpi_attach_args *); +int acpiec_getregister(const u_int8_t *, int, int *, bus_size_t *); -void acpiec_wait_nosleep(struct acpiec_softc *, u_int8_t, u_int8_t); -void acpiec_sci_event(struct acpiec_softc *); +void acpiec_wait(struct acpiec_softc *, u_int8_t, u_int8_t); +void acpiec_sci_event(struct acpiec_softc *); -void acpiec_get_events(struct acpiec_softc *); +void acpiec_get_events(struct acpiec_softc *); -int acpiec_gpehandler(struct acpi_softc *, int, void *); +int acpiec_gpehandler(struct acpi_softc *, int, void *); struct aml_node *aml_find_name(struct acpi_softc *, struct aml_node *, const char *); @@ -75,7 +75,10 @@ struct aml_node *aml_find_name(struct acpi_softc *, struct aml_node *, #define EC_CMD_BD 0x83 /* Burst Disable */ #define EC_CMD_QR 0x84 /* Query */ +#define REG_TYPE_EC 3 + #define ACPIEC_MAX_EVENTS 256 + struct acpiec_event { struct aml_node *event; }; @@ -113,14 +116,12 @@ struct cfdriver acpiec_cd = { int acpiec_intr(struct acpiec_softc *sc) { - u_int8_t stat; + u_int8_t stat; stat = acpiec_status(sc); dnprintf(40, "%s: EC interrupt, stat: %b\n", DEVNAME(sc), (int)stat, "\20\x8IGN\x7SMI\x6SCI\05BURST\04CMD\03IGN\02IBF\01OBF"); - if (stat & (EC_STAT_IBF | EC_STAT_OBF | EC_STAT_BURST )) - wakeup(sc); if ((stat & EC_STAT_SCI_EVT) != 0 && sc->sc_locked == 0) acpiec_sci_event(sc); @@ -128,18 +129,16 @@ acpiec_intr(struct acpiec_softc *sc) } void -acpiec_wait_nosleep(struct acpiec_softc *sc, u_int8_t mask, u_int8_t val) +acpiec_wait(struct acpiec_softc *sc, u_int8_t mask, u_int8_t val) { - u_int8_t stat; + u_int8_t stat; dnprintf(40, "%s: EC wait_ns for: %b == %02x\n", DEVNAME(sc), (int)mask, "\20\x8IGN\x7SMI\x6SCI\05BURST\04CMD\03IGN\02IBF\01OBF", (int)val); - for (;;) { - if (((stat = acpiec_status(sc)) & mask) == val) - break; + while (((stat = acpiec_status(sc)) & mask) != val) delay(1); - } + dnprintf(40, "%s: EC wait_ns, stat: %b\n", DEVNAME(sc), (int)stat, "\20\x8IGN\x7SMI\x6SCI\05BURST\04CMD\03IGN\02IBF\01OBF"); } @@ -147,13 +146,13 @@ acpiec_wait_nosleep(struct acpiec_softc *sc, u_int8_t mask, u_int8_t val) u_int8_t acpiec_status(struct acpiec_softc *sc) { - return bus_space_read_1(sc->sc_cmd_bt, sc->sc_cmd_bh, 0); + return (bus_space_read_1(sc->sc_cmd_bt, sc->sc_cmd_bh, 0)); } void acpiec_write_data(struct acpiec_softc *sc, u_int8_t val) { - acpiec_wait_nosleep(sc, EC_STAT_IBF, 0); + acpiec_wait(sc, EC_STAT_IBF, 0); dnprintf(40, "acpiec: write_data -- %d\n", (int) val); bus_space_write_1(sc->sc_data_bt, sc->sc_data_bh, 0, val); } @@ -161,7 +160,7 @@ acpiec_write_data(struct acpiec_softc *sc, u_int8_t val) void acpiec_write_cmd(struct acpiec_softc *sc, u_int8_t val) { - acpiec_wait_nosleep(sc, EC_STAT_IBF, 0); + acpiec_wait(sc, EC_STAT_IBF, 0); dnprintf(40, "acpiec: write_cmd -- %d\n", (int) val); bus_space_write_1(sc->sc_cmd_bt, sc->sc_cmd_bh, 0, val); } @@ -169,23 +168,24 @@ acpiec_write_cmd(struct acpiec_softc *sc, u_int8_t val) u_int8_t acpiec_read_data(struct acpiec_softc *sc) { - u_int8_t val; - acpiec_wait_nosleep(sc, EC_STAT_OBF, EC_STAT_OBF); + u_int8_t val; + + acpiec_wait(sc, EC_STAT_OBF, EC_STAT_OBF); dnprintf(40, "acpiec: read_data\n", (int) val); val = bus_space_read_1(sc->sc_data_bt, sc->sc_data_bh, 0); - return val; + return (val); } void acpiec_sci_event(struct acpiec_softc *sc) { - u_int8_t evt; + u_int8_t evt; - acpiec_wait_nosleep(sc, EC_STAT_IBF, 0); + acpiec_wait(sc, EC_STAT_IBF, 0); bus_space_write_1(sc->sc_cmd_bt, sc->sc_cmd_bh, 0, EC_CMD_QR); - acpiec_wait_nosleep(sc, EC_STAT_OBF, EC_STAT_OBF); + acpiec_wait(sc, EC_STAT_OBF, EC_STAT_OBF); evt = bus_space_read_1(sc->sc_data_bt, sc->sc_data_bh, 0); dnprintf(10, "%s: sci_event: 0x%02x\n", DEVNAME(sc), (int) evt); @@ -202,7 +202,7 @@ acpiec_sci_event(struct acpiec_softc *sc) u_int8_t acpiec_read_1(struct acpiec_softc *sc, u_int8_t addr) { - u_int8_t val; + u_int8_t val; if ((acpiec_status(sc) & EC_STAT_SCI_EVT) == EC_STAT_SCI_EVT) acpiec_sci_event(sc); @@ -212,7 +212,7 @@ acpiec_read_1(struct acpiec_softc *sc, u_int8_t addr) val = acpiec_read_data(sc); - return val; + return (val); } void @@ -236,7 +236,7 @@ acpiec_burst_enable(struct acpiec_softc *sc) void acpiec_read(struct acpiec_softc *sc, u_int8_t addr, int len, u_int8_t *buffer) { - int reg; + int reg; /* * this works because everything runs in the acpi thread context. @@ -257,7 +257,7 @@ acpiec_read(struct acpiec_softc *sc, u_int8_t addr, int len, u_int8_t *buffer) void acpiec_write(struct acpiec_softc *sc, u_int8_t addr, int len, u_int8_t *buffer) { - int reg; + int reg; /* * this works because everything runs in the acpi thread context. @@ -330,8 +330,8 @@ acpiec_attach(struct device *parent, struct device *self, void *aux) void acpiec_get_events(struct acpiec_softc *sc) { - int idx; - char name[16]; + int idx; + char name[16]; memset(sc->sc_events, 0, sizeof(sc->sc_events)); for (idx = 0; idx < ACPIEC_MAX_EVENTS; idx++) { @@ -345,8 +345,8 @@ acpiec_get_events(struct acpiec_softc *sc) int acpiec_gpehandler(struct acpi_softc *acpi_sc, int gpe, void *arg) { - struct acpiec_softc *sc = arg; - uint8_t mask; + struct acpiec_softc *sc = arg; + u_int8_t mask; dnprintf(10, "ACPIEC: got gpe\n"); acpiec_intr(sc); @@ -363,7 +363,7 @@ acpiec_gpehandler(struct acpi_softc *acpi_sc, int gpe, void *arg) int acpiec_getregister(const u_int8_t *buf, int size, int *type, bus_size_t *addr) { - int len, hlen; + int len, hlen; #define RES_TYPE_MASK 0x80 #define RES_LENGTH_MASK 0x07 @@ -402,11 +402,11 @@ acpiec_getregister(const u_int8_t *buf, int size, int *type, bus_size_t *addr) int acpiec_getcrs(struct acpiec_softc *sc, struct acpi_attach_args *aa) { - struct aml_value res; - bus_size_t ec_sc, ec_data; - int type1, type2; - char *buf; - int size, ret; + struct aml_value res; + bus_size_t ec_sc, ec_data; + int type1, type2; + char *buf; + int size, ret; if (aml_evalname(sc->sc_acpi, sc->sc_devnode, "_GPE", 0, NULL, &res)) { dnprintf(10, "%s: no _GPE\n", DEVNAME(sc)); @@ -494,13 +494,11 @@ acpiec_getcrs(struct acpiec_softc *sc, struct acpi_attach_args *aa) int acpiec_reg(struct acpiec_softc *sc) { - struct aml_value arg[2]; - struct aml_node *root; + struct aml_value arg[2]; + struct aml_node *root; memset(&arg, 0, sizeof(arg)); -#define REG_TYPE_EC 3 - arg[0].type = AML_OBJTYPE_INTEGER; arg[0].v_integer = REG_TYPE_EC; arg[1].type = AML_OBJTYPE_INTEGER; |