Module Name:    src
Committed By:   jruoho
Date:           Mon Dec 20 08:13:04 UTC 2010

Modified Files:
        src/sys/dev/acpi: acpi_cpu_pstate.c acpi_cpu_tstate.c

Log Message:
Use branch annotations in couple of places. Add two comments.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/acpi/acpi_cpu_pstate.c
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/acpi/acpi_cpu_tstate.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/acpi_cpu_pstate.c
diff -u src/sys/dev/acpi/acpi_cpu_pstate.c:1.34 src/sys/dev/acpi/acpi_cpu_pstate.c:1.35
--- src/sys/dev/acpi/acpi_cpu_pstate.c:1.34	Thu Oct 28 04:27:40 2010
+++ src/sys/dev/acpi/acpi_cpu_pstate.c	Mon Dec 20 08:13:04 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_pstate.c,v 1.34 2010/10/28 04:27:40 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_pstate.c,v 1.35 2010/12/20 08:13:04 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2010 Jukka Ruohonen <[email protected]>
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.34 2010/10/28 04:27:40 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_pstate.c,v 1.35 2010/12/20 08:13:04 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/evcnt.h>
@@ -852,18 +852,21 @@
 	uint8_t width;
 	int rv;
 
-	if (sc->sc_cold != false) {
+	if (__predict_false(sc->sc_cold != false)) {
 		rv = EBUSY;
 		goto fail;
 	}
 
-	if ((sc->sc_flags & ACPICPU_FLAG_P) == 0) {
+	if (__predict_false((sc->sc_flags & ACPICPU_FLAG_P) == 0)) {
 		rv = ENODEV;
 		goto fail;
 	}
 
 	mutex_enter(&sc->sc_mtx);
 
+	/*
+	 * Use the cached value, if available.
+	 */
 	if (sc->sc_pstate_current != ACPICPU_P_STATE_UNKNOWN) {
 		*freq = sc->sc_pstate_current;
 		mutex_exit(&sc->sc_mtx);
@@ -878,7 +881,7 @@
 
 		rv = acpicpu_md_pstate_get(sc, freq);
 
-		if (rv != 0)
+		if (__predict_false(rv != 0))
 			goto fail;
 
 		break;
@@ -906,7 +909,7 @@
 			}
 		}
 
-		if (__predict_false(ps == NULL)) {
+		if (ps == NULL) {
 			rv = EIO;
 			goto fail;
 		}
@@ -946,12 +949,12 @@
 	uint8_t width;
 	int rv;
 
-	if (sc->sc_cold != false) {
+	if (__predict_false(sc->sc_cold != false)) {
 		rv = EBUSY;
 		goto fail;
 	}
 
-	if ((sc->sc_flags & ACPICPU_FLAG_P) == 0) {
+	if (__predict_false((sc->sc_flags & ACPICPU_FLAG_P) == 0)) {
 		rv = ENODEV;
 		goto fail;
 	}
@@ -963,9 +966,15 @@
 		return 0;
 	}
 
+	/*
+	 * Verify that the requested frequency is available.
+	 *
+	 * The access needs to be protected since the currently
+	 * available maximum and minimum may change dynamically.
+	 */
 	for (i = sc->sc_pstate_max; i <= sc->sc_pstate_min; i++) {
 
-		if (sc->sc_pstate[i].ps_freq == 0)
+		if (__predict_false(sc->sc_pstate[i].ps_freq == 0))
 			continue;
 
 		if (sc->sc_pstate[i].ps_freq == freq) {
@@ -987,7 +996,7 @@
 
 		rv = acpicpu_md_pstate_set(ps);
 
-		if (rv != 0)
+		if (__predict_false(rv != 0))
 			goto fail;
 
 		break;

Index: src/sys/dev/acpi/acpi_cpu_tstate.c
diff -u src/sys/dev/acpi/acpi_cpu_tstate.c:1.16 src/sys/dev/acpi/acpi_cpu_tstate.c:1.17
--- src/sys/dev/acpi/acpi_cpu_tstate.c:1.16	Sat Aug 21 18:25:45 2010
+++ src/sys/dev/acpi/acpi_cpu_tstate.c	Mon Dec 20 08:13:04 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_cpu_tstate.c,v 1.16 2010/08/21 18:25:45 jruoho Exp $ */
+/* $NetBSD: acpi_cpu_tstate.c,v 1.17 2010/12/20 08:13:04 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2010 Jukka Ruohonen <[email protected]>
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_tstate.c,v 1.16 2010/08/21 18:25:45 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_cpu_tstate.c,v 1.17 2010/12/20 08:13:04 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/evcnt.h>
@@ -638,12 +638,12 @@
 	uint64_t addr;
 	int rv;
 
-	if (sc->sc_cold != false) {
+	if (__predict_false(sc->sc_cold != false)) {
 		rv = EBUSY;
 		goto fail;
 	}
 
-	if ((sc->sc_flags & ACPICPU_FLAG_T) == 0) {
+	if (__predict_false((sc->sc_flags & ACPICPU_FLAG_T) == 0)) {
 		rv = ENODEV;
 		goto fail;
 	}
@@ -664,7 +664,7 @@
 
 		rv = acpicpu_md_tstate_get(sc, percent);
 
-		if (rv != 0)
+		if (__predict_false(rv != 0))
 			goto fail;
 
 		break;
@@ -689,7 +689,7 @@
 			}
 		}
 
-		if (__predict_false(ts == NULL)) {
+		if (ts == NULL) {
 			rv = EIO;
 			goto fail;
 		}
@@ -729,12 +729,12 @@
 	uint64_t addr;
 	int rv;
 
-	if (sc->sc_cold != false) {
+	if (__predict_false(sc->sc_cold != false)) {
 		rv = EBUSY;
 		goto fail;
 	}
 
-	if ((sc->sc_flags & ACPICPU_FLAG_T) == 0) {
+	if (__predict_false((sc->sc_flags & ACPICPU_FLAG_T) == 0)) {
 		rv = ENODEV;
 		goto fail;
 	}
@@ -748,7 +748,7 @@
 
 	for (i = sc->sc_tstate_max; i <= sc->sc_tstate_min; i++) {
 
-		if (sc->sc_tstate[i].ts_percent == 0)
+		if (__predict_false(sc->sc_tstate[i].ts_percent == 0))
 			continue;
 
 		if (sc->sc_tstate[i].ts_percent == percent) {
@@ -770,7 +770,7 @@
 
 		rv = acpicpu_md_tstate_set(ts);
 
-		if (rv != 0)
+		if (__predict_false(rv != 0))
 			goto fail;
 
 		break;

Reply via email to