Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add detach function for hpet(4) at amdpcib(4).
details: https://anonhg.NetBSD.org/src/rev/182c34fcdfa0
branches: trunk
changeset: 766078:182c34fcdfa0
user: jruoho <jruoho%NetBSD.org@localhost>
date: Wed Jun 15 04:20:47 2011 +0000
description:
Add detach function for hpet(4) at amdpcib(4).
diffstat:
sys/arch/x86/pci/amdpcib_hpet.c | 39 +++++++++++++++++++++++++++++++--------
sys/dev/acpi/hpet_acpi.c | 10 +++++++---
2 files changed, 38 insertions(+), 11 deletions(-)
diffs (112 lines):
diff -r fdf5c771a032 -r 182c34fcdfa0 sys/arch/x86/pci/amdpcib_hpet.c
--- a/sys/arch/x86/pci/amdpcib_hpet.c Wed Jun 15 03:30:15 2011 +0000
+++ b/sys/arch/x86/pci/amdpcib_hpet.c Wed Jun 15 04:20:47 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: amdpcib_hpet.c,v 1.4 2008/03/21 13:25:27 xtraeme Exp $ */
+/* $NetBSD: amdpcib_hpet.c,v 1.5 2011/06/15 04:20:47 jruoho Exp $ */
/*
* Copyright (c) 2006 Nicolas Joly
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdpcib_hpet.c,v 1.4 2008/03/21 13:25:27 xtraeme Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdpcib_hpet.c,v 1.5 2011/06/15 04:20:47 jruoho Exp $");
#include <sys/systm.h>
#include <sys/device.h>
@@ -45,12 +45,12 @@
#include <dev/ic/hpetvar.h>
-
static int amdpcib_hpet_match(device_t , cfdata_t , void *);
static void amdpcib_hpet_attach(device_t, device_t, void *);
+static int amdpcib_hpet_detach(device_t, int);
-CFATTACH_DECL_NEW(amdpcib_hpet, sizeof(struct hpet_softc), amdpcib_hpet_match,
- amdpcib_hpet_attach, NULL, NULL);
+CFATTACH_DECL_NEW(amdpcib_hpet, sizeof(struct hpet_softc),
+ amdpcib_hpet_match, amdpcib_hpet_attach, amdpcib_hpet_detach, NULL);
static int
amdpcib_hpet_match(device_t parent, cfdata_t match, void *aux)
@@ -68,20 +68,43 @@
aprint_naive("\n");
aprint_normal(": HPET timer\n");
+ sc->sc_mapped = false;
conf = pci_conf_read(pa->pa_pc, pa->pa_tag, 0xa0);
+
if ((conf & 1) == 0) {
aprint_normal_dev(self, "HPET timer is disabled\n");
return;
}
+ sc->sc_mems = 1024;
sc->sc_memt = pa->pa_memt;
addr = conf & 0xfffffc00;
- if (bus_space_map(sc->sc_memt, addr, 1024, 0,
- &sc->sc_memh)) {
- aprint_error_dev(self, "failed to map mem\n");
+
+ if (bus_space_map(sc->sc_memt, addr, sc->sc_mems, 0, &sc->sc_memh)) {
+ aprint_error_dev(self, "failed to map mem space\n");
return;
}
+ sc->sc_mapped = true;
hpet_attach_subr(self);
}
+
+static int
+amdpcib_hpet_detach(device_t self, int flags)
+{
+ struct hpet_softc *sc = device_private(self);
+ int rv;
+
+ if (sc->sc_mapped != true)
+ return 0;
+
+ rv = hpet_detach(self, flags);
+
+ if (rv != 0)
+ return rv;
+
+ bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_mems);
+
+ return 0;
+}
diff -r fdf5c771a032 -r 182c34fcdfa0 sys/dev/acpi/hpet_acpi.c
--- a/sys/dev/acpi/hpet_acpi.c Wed Jun 15 03:30:15 2011 +0000
+++ b/sys/dev/acpi/hpet_acpi.c Wed Jun 15 04:20:47 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hpet_acpi.c,v 1.7 2011/06/14 16:33:51 jruoho Exp $ */
+/* $NetBSD: hpet_acpi.c,v 1.8 2011/06/15 04:20:47 jruoho Exp $ */
/*
* Copyright (c) 2006, 2011 Nicolas Joly
@@ -28,7 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hpet_acpi.c,v 1.7 2011/06/14 16:33:51 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpet_acpi.c,v 1.8 2011/06/15 04:20:47 jruoho Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -183,7 +183,11 @@
return 0;
rv = hpet_detach(self, flags);
+
+ if (rv != 0)
+ return rv;
+
bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_mems);
- return rv;
+ return 0;
}
Home |
Main Index |
Thread Index |
Old Index