Module Name:    src
Committed By:   jruoho
Date:           Mon Jun  7 13:04:31 UTC 2010

Modified Files:
        src/sys/dev/acpi: acpi.c acpi_power.c acpi_power.h

Log Message:
Build the power resource queue dynamically. This eliminates the need to call
acpi_power_res_add() in the main scan function, also saving few bytes of
memory.


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.201 src/sys/dev/acpi/acpi.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/acpi/acpi_power.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/acpi/acpi_power.h

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/acpi.c
diff -u src/sys/dev/acpi/acpi.c:1.200 src/sys/dev/acpi/acpi.c:1.201
--- src/sys/dev/acpi/acpi.c:1.200	Mon Jun  7 01:45:27 2010
+++ src/sys/dev/acpi/acpi.c	Mon Jun  7 13:04:31 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi.c,v 1.200 2010/06/07 01:45:27 pgoyette Exp $	*/
+/*	$NetBSD: acpi.c,v 1.201 2010/06/07 13:04:31 jruoho Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.200 2010/06/07 01:45:27 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.201 2010/06/07 13:04:31 jruoho Exp $");
 
 #include "opt_acpi.h"
 #include "opt_pcifixup.h"
@@ -1002,18 +1002,11 @@
 		/*
 		 * Handled internally.
 		 */
-		if (di->Type == ACPI_TYPE_PROCESSOR)
+		if (di->Type == ACPI_TYPE_POWER ||
+		    di->Type == ACPI_TYPE_PROCESSOR)
 			continue;
 
 		/*
-		 * Ditto, but bind power resources.
-		 */
-		if (di->Type == ACPI_TYPE_POWER) {
-			acpi_power_res_add(ad);
-			continue;
-		}
-
-		/*
 		 * Skip ignored HIDs.
 		 */
 		if (acpi_match_hid(di, acpi_ignored_ids))

Index: src/sys/dev/acpi/acpi_power.c
diff -u src/sys/dev/acpi/acpi_power.c:1.14 src/sys/dev/acpi/acpi_power.c:1.15
--- src/sys/dev/acpi/acpi_power.c:1.14	Sat Jun  5 07:59:13 2010
+++ src/sys/dev/acpi/acpi_power.c	Mon Jun  7 13:04:31 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_power.c,v 1.14 2010/06/05 07:59:13 jruoho Exp $ */
+/* $NetBSD: acpi_power.c,v 1.15 2010/06/07 13:04:31 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_power.c,v 1.14 2010/06/05 07:59:13 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_power.c,v 1.15 2010/06/07 13:04:31 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -120,21 +120,6 @@
 static int		 acpi_power_sysctl(SYSCTLFN_ARGS);
 static const char	*acpi_xname(ACPI_HANDLE);
 
-void
-acpi_power_res_add(struct acpi_devnode *ad)
-{
-	struct acpi_power_res *res;
-
-	KASSERT(ad != NULL && ad->ad_root != NULL);
-	KASSERT(ad->ad_devinfo->Type == ACPI_TYPE_POWER);
-
-	res = acpi_power_res_init(ad->ad_handle);
-
-	if (res == NULL)
-		aprint_error_dev(ad->ad_root, "failed to "
-		    "add power resource %s\n", ad->ad_name);
-}
-
 static struct acpi_power_res *
 acpi_power_res_init(ACPI_HANDLE hdl)
 {
@@ -190,6 +175,9 @@
 	if (tmp == NULL)
 		TAILQ_INSERT_TAIL(&res_head, res, res_list);
 
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s added to the "
+		"power resource queue\n", res->res_name));
+
 out:
 	if (buf.Pointer != NULL)
 		ACPI_FREE(buf.Pointer);

Index: src/sys/dev/acpi/acpi_power.h
diff -u src/sys/dev/acpi/acpi_power.h:1.3 src/sys/dev/acpi/acpi_power.h:1.4
--- src/sys/dev/acpi/acpi_power.h:1.3	Sat Apr 24 06:31:44 2010
+++ src/sys/dev/acpi/acpi_power.h	Mon Jun  7 13:04:31 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_power.h,v 1.3 2010/04/24 06:31:44 jruoho Exp $ */
+/* $NetBSD: acpi_power.h,v 1.4 2010/06/07 13:04:31 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -34,7 +34,6 @@
 
 #define ACPI_STATE_ERROR	-1
 
-void	acpi_power_res_add(struct acpi_devnode *);
 bool	acpi_power_register(struct acpi_devnode *);
 void	acpi_power_deregister(struct acpi_devnode *);
 void	acpi_power_deregister_from_handle(ACPI_HANDLE);

Reply via email to