Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/acpi Use branch annotations in couple of places. Add...
details: https://anonhg.NetBSD.org/src/rev/0527dd7fce98
branches: trunk
changeset: 759915:0527dd7fce98
user: jruoho <jruoho%NetBSD.org@localhost>
date: Mon Dec 20 08:13:04 2010 +0000
description:
Use branch annotations in couple of places. Add two comments.
diffstat:
sys/dev/acpi/acpi_cpu_pstate.c | 29 +++++++++++++++++++----------
sys/dev/acpi/acpi_cpu_tstate.c | 20 ++++++++++----------
2 files changed, 29 insertions(+), 20 deletions(-)
diffs (185 lines):
diff -r 9155a3c7fa63 -r 0527dd7fce98 sys/dev/acpi/acpi_cpu_pstate.c
--- a/sys/dev/acpi/acpi_cpu_pstate.c Mon Dec 20 04:56:18 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu_pstate.c Mon Dec 20 08:13:04 2010 +0000
@@ -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 <jruohonen%iki.fi@localhost>
@@ -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;
diff -r 9155a3c7fa63 -r 0527dd7fce98 sys/dev/acpi/acpi_cpu_tstate.c
--- a/sys/dev/acpi/acpi_cpu_tstate.c Mon Dec 20 04:56:18 2010 +0000
+++ b/sys/dev/acpi/acpi_cpu_tstate.c Mon Dec 20 08:13:04 2010 +0000
@@ -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 <jruohonen%iki.fi@localhost>
@@ -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;
Home |
Main Index |
Thread Index |
Old Index