From b2e0398cd4e9df66122a5b03ea6d880b1893db58 Mon Sep 17 00:00:00 2001 From: Fredrik Holmqvist Date: Fri, 24 Aug 2018 13:51:48 +0200 Subject: [PATCH] ps2_dev encapsulate TRACING code Avoid doing system_time() calls in a loop. Is this even needed anymore? --- src/add-ons/kernel/bus_managers/ps2/ps2_dev.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/bus_managers/ps2/ps2_dev.cpp b/src/add-ons/kernel/bus_managers/ps2/ps2_dev.cpp index faf7829b44..4fa5e55a3a 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_dev.cpp +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_dev.cpp @@ -368,7 +368,9 @@ standard_command_timeout(ps2_dev* dev, uint8 cmd, const uint8* out, int out_count, uint8* in, int in_count, bigtime_t timeout) { status_t res; +#ifdef TRACE_PS2 bigtime_t start; +#endif int32 sem_count; int i; @@ -426,16 +428,18 @@ standard_command_timeout(ps2_dev* dev, uint8 cmd, const uint8* out, } release_sem(gControllerSem); - +#ifdef TRACE_PS2 start = system_time(); +#endif res = acquire_sem_etc(dev->result_sem, 1, B_RELATIVE_TIMEOUT, timeout); if (res != B_OK) atomic_and(&dev->flags, ~PS2_FLAG_CMD); +#ifdef TRACE_PS2 TRACE("ps2: ps2_dev_command wait for ack res 0x%08" B_PRIx32 ", " "wait-time %" B_PRId64 "\n", res, system_time() - start); - +#endif if (atomic_get(&dev->flags) & PS2_FLAG_ACK) { TRACE("ps2: ps2_dev_command got ACK\n"); } @@ -454,7 +458,9 @@ standard_command_timeout(ps2_dev* dev, uint8 cmd, const uint8* out, if (in_count == 0) { atomic_and(&dev->flags, ~PS2_FLAG_CMD); } else { +#ifdef TRACE_PS2 start = system_time(); +#endif res = acquire_sem_etc(dev->result_sem, 1, B_RELATIVE_TIMEOUT, timeout); @@ -468,11 +474,12 @@ standard_command_timeout(ps2_dev* dev, uint8 cmd, const uint8* out, res = B_IO_ERROR; } +#ifdef TRACE_PS2 TRACE("ps2: ps2_dev_command wait for input res 0x%08" B_PRIx32 ", " "wait-time %" B_PRId64 "\n", res, system_time() - start); - for (i = 0; i < in_count; i++) TRACE("ps2: ps2_dev_command rx: 0x%02x\n", in[i]); +#endif } }