summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorjruoho <jruoho@NetBSD.org>2010-12-20 08:13:04 +0000
committerjruoho <jruoho@NetBSD.org>2010-12-20 08:13:04 +0000
commitcb35a858ff93a1c720c41dfe32bcacc4674934c1 (patch)
tree165376168399a21c7b85ba9d577e8bb8875f0b7c /sys/dev
parent0c43311b12ba732749a623ade89b9a55a393acda (diff)
Use branch annotations in couple of places. Add two comments.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/acpi/acpi_cpu_pstate.c29
-rw-r--r--sys/dev/acpi/acpi_cpu_tstate.c20
2 files changed, 29 insertions, 20 deletions
diff --git a/sys/dev/acpi/acpi_cpu_pstate.c b/sys/dev/acpi/acpi_cpu_pstate.c
index 858204d9ac3..8952b1a9ee7 100644
--- a/sys/dev/acpi/acpi_cpu_pstate.c
+++ b/sys/dev/acpi/acpi_cpu_pstate.c
@@ -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>
@@ -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 @@ acpicpu_pstate_get(struct acpicpu_softc *sc, uint32_t *freq)
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 @@ acpicpu_pstate_get(struct acpicpu_softc *sc, uint32_t *freq)
rv = acpicpu_md_pstate_get(sc, freq);
- if (rv != 0)
+ if (__predict_false(rv != 0))
goto fail;
break;
@@ -906,7 +909,7 @@ acpicpu_pstate_get(struct acpicpu_softc *sc, uint32_t *freq)
}
}
- if (__predict_false(ps == NULL)) {
+ if (ps == NULL) {
rv = EIO;
goto fail;
}
@@ -946,12 +949,12 @@ acpicpu_pstate_set(struct acpicpu_softc *sc, uint32_t freq)
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 @@ acpicpu_pstate_set(struct acpicpu_softc *sc, uint32_t freq)
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 @@ acpicpu_pstate_set(struct acpicpu_softc *sc, uint32_t freq)
rv = acpicpu_md_pstate_set(ps);
- if (rv != 0)
+ if (__predict_false(rv != 0))
goto fail;
break;
diff --git a/sys/dev/acpi/acpi_cpu_tstate.c b/sys/dev/acpi/acpi_cpu_tstate.c
index 1de255b2c7d..6e82180f71d 100644
--- a/sys/dev/acpi/acpi_cpu_tstate.c
+++ b/sys/dev/acpi/acpi_cpu_tstate.c
@@ -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>
@@ -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 @@ acpicpu_tstate_get(struct acpicpu_softc *sc, uint32_t *percent)
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 @@ acpicpu_tstate_get(struct acpicpu_softc *sc, uint32_t *percent)
rv = acpicpu_md_tstate_get(sc, percent);
- if (rv != 0)
+ if (__predict_false(rv != 0))
goto fail;
break;
@@ -689,7 +689,7 @@ acpicpu_tstate_get(struct acpicpu_softc *sc, uint32_t *percent)
}
}
- if (__predict_false(ts == NULL)) {
+ if (ts == NULL) {
rv = EIO;
goto fail;
}
@@ -729,12 +729,12 @@ acpicpu_tstate_set(struct acpicpu_softc *sc, uint32_t percent)
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 @@ acpicpu_tstate_set(struct acpicpu_softc *sc, uint32_t percent)
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 @@ acpicpu_tstate_set(struct acpicpu_softc *sc, uint32_t percent)
rv = acpicpu_md_tstate_set(ts);
- if (rv != 0)
+ if (__predict_false(rv != 0))
goto fail;
break;