diff options
| author | cube <cube@NetBSD.org> | 2008-03-07 21:45:07 +0000 |
|---|---|---|
| committer | cube <cube@NetBSD.org> | 2008-03-07 21:45:07 +0000 |
| commit | 3c5e53b4e205a4d4623da25edbf2df40bbbbb931 (patch) | |
| tree | f08a7234f4ee76861869f0e7128c1e2b6f6690eb /sys/dev | |
| parent | 4f831ae35acb2902da1b69556547d25e2a2aa40f (diff) | |
Split device_t/softc for i386's apm(4), and other related cosmetic changes.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/acpi/acpi_apm.c | 20 | ||||
| -rw-r--r-- | sys/dev/apm/apm.c | 47 | ||||
| -rw-r--r-- | sys/dev/apm/apmvar.h | 4 |
3 files changed, 35 insertions, 36 deletions
diff --git a/sys/dev/acpi/acpi_apm.c b/sys/dev/acpi/acpi_apm.c index e69b2772356..b2ea96ac34c 100644 --- a/sys/dev/acpi/acpi_apm.c +++ b/sys/dev/acpi/acpi_apm.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_apm.c,v 1.12 2007/12/09 20:27:52 jmcneill Exp $ */ +/* $NetBSD: acpi_apm.c,v 1.13 2008/03/07 21:45:08 cube Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_apm.c,v 1.12 2007/12/09 20:27:52 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_apm.c,v 1.13 2008/03/07 21:45:08 cube Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -105,27 +105,27 @@ static int acpiapm_node = CTL_EOL, standby_node = CTL_EOL; struct acpi_softc; extern ACPI_STATUS acpi_enter_sleep_state(struct acpi_softc *, int); -static int acpiapm_match(struct device *, struct cfdata *, void *); -static void acpiapm_attach(struct device *, struct device *, void *); +static int acpiapm_match(device_t, cfdata_t , void *); +static void acpiapm_attach(device_t, device_t, void *); static int sysctl_state(SYSCTLFN_PROTO); -CFATTACH_DECL(acpiapm, sizeof(struct apm_softc), +CFATTACH_DECL_NEW(acpiapm, sizeof(struct apm_softc), acpiapm_match, acpiapm_attach, NULL, NULL); static int /*ARGSUSED*/ -acpiapm_match(struct device *parent, - struct cfdata *match, void *aux) +acpiapm_match(device_t parent, cfdata_t match, void *aux) { return apm_match(); } static void /*ARGSUSED*/ -acpiapm_attach(struct device *parent, struct device *self, void *aux) +acpiapm_attach(device_t parent, device_t self, void *aux) { - struct apm_softc *sc = (struct apm_softc *)self; + struct apm_softc *sc = device_private(self); + sc->sc_dev = self; sc->sc_ops = &acpiapm_accessops; sc->sc_cookie = parent; sc->sc_vers = 0x0102; @@ -239,7 +239,7 @@ acpiapm_enable(void *opaque, int onoff) static int acpiapm_set_powstate(void *opaque, u_int devid, u_int powstat) { - struct acpi_softc *sc = opaque; + struct acpi_softc *sc = device_private((device_t)opaque); if (devid != APM_DEV_ALLDEVS) return APM_ERR_UNRECOG_DEV; diff --git a/sys/dev/apm/apm.c b/sys/dev/apm/apm.c index 4ce4b1afeb4..be6ee1de858 100644 --- a/sys/dev/apm/apm.c +++ b/sys/dev/apm/apm.c @@ -1,4 +1,4 @@ -/* $NetBSD: apm.c,v 1.18 2008/03/01 14:16:50 rmind Exp $ */ +/* $NetBSD: apm.c,v 1.19 2008/03/07 21:45:08 cube Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: apm.c,v 1.18 2008/03/01 14:16:50 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: apm.c,v 1.19 2008/03/07 21:45:08 cube Exp $"); #include "opt_apm.h" @@ -234,10 +234,11 @@ apm_power_print(struct apm_softc *sc, struct apm_power_info *pi) { if (pi->battery_life != APM_BATT_LIFE_UNKNOWN) { - printf("%s: battery life expectancy: %d%%\n", - sc->sc_dev.dv_xname, pi->battery_life); + aprint_normal_dev(sc->sc_dev, + "battery life expectancy: %d%%\n", + pi->battery_life); } - printf("%s: A/C state: ", sc->sc_dev.dv_xname); + aprint_normal_dev(sc->sc_dev, "A/C state: "); switch (pi->ac_state) { case APM_AC_OFF: printf("off\n"); @@ -253,7 +254,7 @@ apm_power_print(struct apm_softc *sc, struct apm_power_info *pi) printf("unknown\n"); break; } - printf("%s: battery charge state:", sc->sc_dev.dv_xname); + aprint_normal_dev(sc->sc_dev, "battery charge state:"); if (apm_minver == 0) switch (pi->battery_state) { case APM_BATT_HIGH: @@ -290,7 +291,7 @@ apm_power_print(struct apm_softc *sc, struct apm_power_info *pi) } printf("\n"); if (pi->minutes_valid) { - printf("%s: estimated ", sc->sc_dev.dv_xname); + aprint_normal_dev(sc->sc_dev, "estimated "); if (pi->minutes_left / 60) printf("%dh ", pi->minutes_left / 60); printf("%dm\n", pi->minutes_left % 60); @@ -307,8 +308,8 @@ apm_suspend(struct apm_softc *sc) if (sc->sc_power_state == PWR_SUSPEND) { #ifdef APMDEBUG - printf("%s: apm_suspend: already suspended?\n", - sc->sc_dev.dv_xname); + aprint_debug_dev(sc->sc_dev, + "apm_suspend: already suspended?\n"); #endif return; } @@ -333,8 +334,8 @@ apm_standby(struct apm_softc *sc) if (sc->sc_power_state == PWR_STANDBY) { #ifdef APMDEBUG - printf("%s: apm_standby: already standing by?\n", - sc->sc_dev.dv_xname); + aprint_debug_dev(sc->sc_dev, + "apm_standby: already standing by?\n"); #endif return; } @@ -356,8 +357,7 @@ apm_resume(struct apm_softc *sc, u_int event_type, u_int event_info) if (sc->sc_power_state == PWR_RESUME) { #ifdef APMDEBUG - printf("%s: apm_resume: already running?\n", - sc->sc_dev.dv_xname); + aprint_debug_dev(sc->sc_dev, "apm_resume: already running?\n"); #endif return; } @@ -676,19 +676,18 @@ apm_attach(struct apm_softc *sc) * and notify other subsystems when they occur. */ if (kthread_create(PRI_NONE, 0, NULL, apm_thread, sc, - &sc->sc_thread, "%s", sc->sc_dev.dv_xname) != 0) { + &sc->sc_thread, "%s", device_xname(sc->sc_dev)) != 0) { /* * We were unable to create the APM thread; bail out. */ if (sc->sc_ops->aa_disconnect) (*sc->sc_ops->aa_disconnect)(sc->sc_cookie); - printf("%s: unable to create thread, " - "kernel APM support disabled\n", - sc->sc_dev.dv_xname); + aprint_error_dev(sc->sc_dev, "unable to create thread, " + "kernel APM support disabled\n"); } - if (!pmf_device_register(&sc->sc_dev, NULL, NULL)) - aprint_error_dev(&sc->sc_dev, "couldn't establish power handler\n"); + if (!pmf_device_register(sc->sc_dev, NULL, NULL)) + aprint_error_dev(sc->sc_dev, "couldn't establish power handler\n"); } void @@ -717,7 +716,7 @@ apmopen(dev_t dev, int flag, int mode, struct lwp *l) if (unit >= apm_cd.cd_ndevs) return ENXIO; - sc = apm_cd.cd_devs[unit]; + sc = device_private(apm_cd.cd_devs[unit]); if (!sc) return ENXIO; @@ -760,7 +759,7 @@ int apmclose(dev_t dev, int flag, int mode, struct lwp *l) { - struct apm_softc *sc = apm_cd.cd_devs[APMUNIT(dev)]; + struct apm_softc *sc = device_private(apm_cd.cd_devs[APMUNIT(dev)]); int ctl = APM(dev); DPRINTF(APMDEBUG_DEVICE, @@ -787,7 +786,7 @@ int apmioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) { - struct apm_softc *sc = apm_cd.cd_devs[APMUNIT(dev)]; + struct apm_softc *sc = device_private(apm_cd.cd_devs[APMUNIT(dev)]); struct apm_power_info *powerp; struct apm_event_info *evp; #if 0 @@ -886,7 +885,7 @@ apmioctl(dev_t dev, u_long cmd, void *data, int flag, int apmpoll(dev_t dev, int events, struct lwp *l) { - struct apm_softc *sc = apm_cd.cd_devs[APMUNIT(dev)]; + struct apm_softc *sc = device_private(apm_cd.cd_devs[APMUNIT(dev)]); int revents = 0; APM_LOCK(sc); @@ -926,7 +925,7 @@ static const struct filterops apmread_filtops = int apmkqfilter(dev_t dev, struct knote *kn) { - struct apm_softc *sc = apm_cd.cd_devs[APMUNIT(dev)]; + struct apm_softc *sc = device_private(apm_cd.cd_devs[APMUNIT(dev)]); struct klist *klist; switch (kn->kn_filter) { diff --git a/sys/dev/apm/apmvar.h b/sys/dev/apm/apmvar.h index b27bcb07d4a..744ce99d072 100644 --- a/sys/dev/apm/apmvar.h +++ b/sys/dev/apm/apmvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: apmvar.h,v 1.5 2007/12/05 07:58:29 ad Exp $ */ +/* $NetBSD: apmvar.h,v 1.6 2008/03/07 21:45:08 cube Exp $ */ /*- * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. * All rights reserved. @@ -54,7 +54,7 @@ struct apm_accessops { #define APM_NEVENTS 16 struct apm_softc { - struct device sc_dev; + device_t sc_dev; struct selinfo sc_rsel; struct selinfo sc_xsel; int sc_flags; |
