Module Name:    src
Committed By:   jruoho
Date:           Sun Jan 31 19:49:29 UTC 2010

Modified Files:
        src/sys/dev/acpi: dalb_acpi.c

Log Message:
Add a detachment routine.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/acpi/dalb_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/acpi/dalb_acpi.c
diff -u src/sys/dev/acpi/dalb_acpi.c:1.5 src/sys/dev/acpi/dalb_acpi.c:1.6
--- src/sys/dev/acpi/dalb_acpi.c:1.5	Fri Jan  8 20:40:41 2010
+++ src/sys/dev/acpi/dalb_acpi.c	Sun Jan 31 19:49:29 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: dalb_acpi.c,v 1.5 2010/01/08 20:40:41 dyoung Exp $	*/
+/*	$NetBSD: dalb_acpi.c,v 1.6 2010/01/31 19:49:29 jruoho Exp $	*/
 
 /*-
  * Copyright (c) 2008 Christoph Egger <[email protected]>
@@ -27,7 +27,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dalb_acpi.c,v 1.5 2010/01/08 20:40:41 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dalb_acpi.c,v 1.6 2010/01/31 19:49:29 jruoho Exp $");
 
 /*
  * Direct Application Launch Button:
@@ -68,6 +68,7 @@
 
 static int	acpi_dalb_match(device_t, cfdata_t, void *);
 static void	acpi_dalb_attach(device_t, device_t, void *);
+static int	acpi_dalb_detach(device_t, int);
 static void	acpi_dalb_notify_handler(ACPI_HANDLE, UINT32, void *);
 static bool	acpi_dalb_resume(device_t, pmf_qual_t);
 
@@ -75,7 +76,7 @@
 static void	acpi_dalb_get_runtime_hotkeys(void *opaque);
 
 CFATTACH_DECL_NEW(acpidalb, sizeof(struct acpi_dalb_softc),
-    acpi_dalb_match, acpi_dalb_attach, NULL, NULL);
+    acpi_dalb_match, acpi_dalb_attach, acpi_dalb_detach, NULL);
 
 static const char * const acpi_dalb_ids[] = {
         "PNP0C32", /* Direct Application Launch Button */
@@ -190,6 +191,24 @@
 		aprint_error_dev(self, "couldn't establish power handler\n");
 }
 
+static int
+acpi_dalb_detach(device_t self, int flags)
+{
+	struct acpi_dalb_softc *sc = device_private(self);
+	ACPI_STATUS rv;
+
+	rv = AcpiRemoveNotifyHandler(sc->sc_node->ad_handle,
+	    ACPI_ALL_NOTIFY, acpi_dalb_notify_handler);
+
+	if (ACPI_FAILURE(rv))
+		return EBUSY;
+
+	pmf_device_deregister(self);
+	sysmon_pswitch_unregister(&sc->sc_smpsw);
+
+	return 0;
+}
+
 static void
 acpi_dalb_notify_handler(ACPI_HANDLE hdl, UINT32 notify, void *opaque)
 {

Reply via email to